Skip to content

chore(security): move Docker image off EOL python:3.9 bullseye base - #290

Open
dex-the-ai wants to merge 2 commits into
mainfrom
security/2026-11-dockerfile-base-image
Open

dex-the-ai wants to merge 2 commits into
mainfrom
security/2026-11-dockerfile-base-image

Conversation

@dex-the-ai

Copy link
Copy Markdown
Contributor

Summary

The monthly security audit (Kanban t_3fb366b2, board couchbase-examples) found that the Python dependencies are clean. The Docker image is the problem:

  • Dockerfile uses python:3.9-slim-bullseye. Python 3.9 reached end of life in October 2025, and Debian 11 is past end of support (Trivy marks it EOSL: true). Trivy reports 7 CRITICAL and 164 HIGH OS CVEs in that base image, and many of them will never get a Debian fix.
  • The image no longer builds. fastapi==0.162.0 requires Python ≥3.10, so docker build fails at pip install on main today.
  • The image also never contained hotel_search_index.json. The app therefore logged No such file or directory: 'hotel_search_index.json' and could not create the hotel_search FTS index, so the hotel search/autocomplete endpoints returned 500.

This PR makes three changes:

  1. FROM python:3.9-slim-bullseye → FROM python:3.13-slim (Debian 13 "trixie").
  2. Copies hotel_search_index.json into the image.
  3. Updates the README Python prerequisite from 3.9 to 3.10, which is what the pinned requirements already need.

requirements.txt is unchanged. Python 3.13 is the newest version that couchbase 4.6.4 and all the other pins install on.

Advisories

Advisory Affected Current Fix Severity Path Source
CVE-2026-33845, CVE-2026-42010 libgnutls30 (OS) 3.7.1-5+deb11u7 Debian 13 base CRITICAL base image https://avd.aquasec.com/nvd/cve-2026-42010
CVE-2023-45853 zlib1g (OS) 1:1.2.11.dfsg-2+deb11u2 Debian 13 base (no deb11 fix) CRITICAL base image https://nvd.nist.gov/vuln/detail/CVE-2023-45853
CVE-2026-13221, CVE-2026-42496, CVE-2026-8376 perl-base (OS) 5.32.1-4+deb11u4 Debian 13 base (no deb11 fix) CRITICAL base image https://avd.aquasec.com/nvd/cve-2026-8376
CVE-2019-8457 libdb5.3 (OS) 5.3.28+dfsg1-0.8 Debian 13 base CRITICAL base image https://nvd.nist.gov/vuln/detail/CVE-2019-8457
CVE-2024-6345, CVE-2025-47273, CVE-2022-40897 setuptools (image tooling) 58.1.0 newer base HIGH base image https://nvd.nist.gov/vuln/detail/CVE-2024-6345
CVE-2026-24049 wheel (image tooling) 0.45.1 0.46.2 / newer base HIGH base image https://nvd.nist.gov/vuln/detail/CVE-2026-24049
(+164 HIGH OS CVEs across 74 unique IDs) Debian 11 packages Debian 13 base HIGH base image Trivy

Why it matters: anyone who follows the README's "Using Docker" path gets a broken build. Even after a fix to the build, the image would sit on an unsupported OS that will never receive patches for these CRITICAL CVEs in TLS (gnutls), compression (zlib) and perl.

Python packages: pip-audit -r requirements.txt found nothing. Inside the built image, pip-audit and pip freeze show anyio 4.16.0, certifi 2026.11.20 and idna 3.20, all clean. osv-scanner flagged anyio 4.9.0 (GHSA-82r6-8w77-94w6, CRITICAL), certifi 2026.7.22 (GHSA-6q48-6c7w-9gw2, CRITICAL) and idna 3.9.0, but those versions came from osv-scanner's own transitive resolver. pip installs the fixed versions, so these are not real exposures. The couchbase PYSEC-2023-235 hit is the known OSV false positive for the server CVE-2023-45875.

Before / after (Trivy HIGH,CRITICAL)

Image OS CRITICAL HIGH (OS) HIGH (py tooling)
python:3.9-slim-bullseye (main) Debian 11.11, EOSL 7 164 4
built image from this PR (python:3.13-slim) Debian 13.8 0 54 (1 with a fix available upstream) 5

Residual: the 5 Python HIGH findings are msgpack/urllib3 vendored inside pip 26.2.2 (the latest pip) plus a setuptools copy in the base image. They are image tooling and the app does not import them at runtime. They will clear as upstream pip and python images update.

Validation

  • docker build on main: fails (No matching distribution found for fastapi==0.162.0, Requires-Python >=3.10)
  • docker build on this branch: succeeds
  • Local Couchbase Enterprise 8.0.3 (kv, n1ql, index, fts) + travel-sample. App container started from the new image; the hotel_search FTS index was created at startup (917 docs indexed).
  • python -m pytest run inside the built image against the running app container: 54 passed (with the old COPY layout, the 8 hotel tests failed with 500 because the index JSON was missing)
  • Swagger UI at /docs and live GET /api/v1/hotel/autocomplete?name=sea → 200:

Commands:

pip-audit -r requirements.txt
osv-scanner scan source -r .
docker run aquasec/trivy image --severity HIGH,CRITICAL python:3.9-slim-bullseye | python:3.13-slim | <built image>
docker build -t fastapi-qs:new .
docker run --network container:<cb> fastapi-qs:new python -m pytest -q

CI (tests.yml) runs on the runner's system Python and does not use the Dockerfile, so it is unaffected by this change.

Risk / rollback

  • Low risk. The change touches only the container base and adds one COPY line, and nothing outside Docker uses the Dockerfile. To roll back, revert this PR (note that the old base does not build).
  • Open Dependabot PR Bump couchbase from 4.6.4 to 4.7.0 #289 (couchbase 4.7.0) requires Python ≥3.11, so it would also have broken a 3.9/3.10 image. It is compatible with this 3.13 base.

Kanban task: t_3fb366b2 (board couchbase-examples, idempotency key couchbase-security-review-monthly:couchbase-examples/python-quickstart-fastapi:2026-11)

🤖 Generated with Claude Code

dex-the-ai and others added 2 commits November 28, 2026 02:34
python:3.9-slim-bullseye is end-of-life (Python 3.9 EOL 2025-10, Debian 11
EOSL) and Trivy reports 7 CRITICAL / 164 HIGH OS CVEs in it. It also no
longer builds: fastapi==0.162.0 requires Python >=3.10.

Switch to python:3.13-slim (Debian 13) and copy hotel_search_index.json
into the image so the app can create the hotel_search FTS index at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dex-the-ai
dex-the-ai requested a review from nithishr November 28, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant