Skip to content

fix(image): upgrade vulnerable Python packages - #441

Merged
uniqueg merged 7 commits into
devfrom
fix/437-image-python-packages
Oct 23, 2026
Merged

uniqueg merged 7 commits into
devfrom
fix/437-image-python-packages

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Removes the fixable Python package findings from the FOCA images (all Python variants), so that apps get clean base images with 0.17.0.

  • pip (3.11: 24.0, 3.12: 25.0.1; CVE-2025-8869, CVE-2026-1703, CVE-2026-3219, CVE-2026-6357, CVE-2026-8643, CVE-2026-13346): the base stage of docker/Dockerfile upgrades pip to the latest release (pip>=26.2; 26.2.2 today, which the 3.13 and 3.14 images already ship). pip stays in the image, because apps built on it (cloud-registry, proTES, trs-filer, the petstore examples) run pip install on top.
  • setuptools 70.3.0 and urllib3 2.7.0, location "Python" (CVE-2026-59890, CVE-2026-97688, medium): these are copies vendored by pip itself, listed in pip/_vendor/bom.cdx.json. pip 26.2.2, the latest release, still vendors them, so upgrading can't fix them and removing pip would break the apps. They are accepted in .trivyignore.yaml like the existing (high) entries for the same copies: limited by purl, with a reason and an expiry date. pip vendors only pkg_resources from setuptools, and doesn't use it on Python 3.11+, while the setuptools CVE concerns sdist builds on macOS. The urllib3 CVE is a hang on malicious responses, and pip only runs at build time, against the configured index. The comment now gives the real location of pip's SBOM. The installed urllib3 is 2.8.0.
  • certifi (GHSA-6q48-6c7w-9gw2, critical; cloud-registry's weekly scan found 2026.10.18 in its image): new floor certifi>=2026.10.19. FOCA gets certifi through requests. The images built here have 2026.10.23, and pip's vendored copy is 2026.10.19.
  • Build requirement setuptools>=83, which fixes CVE-2026-59890 for FOCA's own sdists.
  • Migration guide: the latest pip in all images, the certifi floor and the setuptools build floor.

Not changed: the scan gate still fails only on fixable CRITICAL/HIGH findings. Failing on MEDIUM too would have caught the pip findings, but the scan action is kept identical in FOCA, cloud-registry and proTES. So that change belongs in all three together, as a follow-up. Fixable MEDIUM findings still appear in code scanning.

Verification

  • Built all four variants locally (docker build -f docker/Dockerfile --build-arg PY_IMAGE=<3.11|3.12|3.13|3.14>-slim-trixie). Each has pip 26.2.2, no setuptools or wheel, urllib3 2.8.0 and certifi 2026.10.23 (checked before the certifi floor, which doesn't change the resolved version).
  • Trivy 0.75.0 (aquasec/trivy:0.75.0, vulnerability scanner) with .trivyignore.yaml: 0 fixable findings on all four variants, at any severity. Without the ignore file, the only fixable findings are the six of pip's vendored copies (msgpack 1.1.2, setuptools 70.3.0, urllib3 2.7.0), all of them accepted.
  • Derived builds on the 3.11 and 3.14 images: pip install gunicorn and a pyproject (setuptools) package install as root work.
  • pre-commit run on the changed files passed. mkdocs build --strict passed. pytest tests -k "not mongodb": 1714 passed (the MongoDB-backed tests need a MongoDB service and run in CI).
  • CI: all checks pass, including Scan image for Python 3.11, 3.12, 3.13 and 3.14. The 3.11 build log shows pip 24.0 replaced by 26.2.2 and certifi 2026.10.23 installed, and Trivy reports 0 findings for both packages.

Declined review findings

  • Pin pip exactly, in a requirements file updated by Dependabot (adversarial, low). Declined: the base image tag floats too (no digest), so image builds aren't reproducible from a tag anyway. A floor always gets pip's latest fixes, including newer vendored copies, while a pin would lag behind until Dependabot updates it.
  • Shorten the CVE list in the Dockerfile comment (quality, low). Declined: listing the CVEs a floor fixes is the repo's convention, as in pyproject.toml.

Closes #437

🤖 Generated with Claude Code

Summary by Sourcery

Harden FOCA's Python images and build dependencies against fixable package vulnerabilities while retaining pip support for downstream application builds.

Bug Fixes:

  • Upgrade all FOCA Python images to pip 26.2+ and require newer certifi and setuptools versions to address known vulnerabilities.

Enhancements:

  • Document the updated image package requirements and migration considerations for derived images.
  • Clarify and narrowly scope accepted exceptions for vulnerabilities in pip-vendored packages.

Documentation:

  • Update the 0.17 migration guide with the latest pip behavior and new certifi and setuptools minimum versions.

uniqueg and others added 6 commits October 23, 2026 16:25
The Python 3.11 and 3.12 base images ship pip 24.0 and 25.0.1, with
known vulnerabilities (CVE-2025-8869, CVE-2026-1703, CVE-2026-3219,
CVE-2026-6357, CVE-2026-8643, CVE-2026-13346; fixed by 26.2). pip stays
in the image, as images built from FOCA's install their packages with
it, so upgrade it to the latest release, as the 3.13 and 3.14 images
already ship. Note the change in the migration guide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pip 26.2.2, the latest release, vendors setuptools 70.3.0 (only
pkg_resources) and urllib3 2.7.0, which Trivy reports with
CVE-2026-59890 and CVE-2026-97688 (medium). Accept them like the
other findings of these copies: pip only runs at build time, and the
setuptools one affects sdist builds on macOS. Correct the location of
pip's SBOM (`pip/_vendor/bom.cdx.json`) in the comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
setuptools 83 fixes CVE-2026-59890 (exclusions of MANIFEST.in bypassed
in sdists), so raise the floor of the build requirement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
List the new setuptools build floor in the migration guide, explain why
CVE-2026-97688 doesn't affect pip's vendored urllib3 at build time, and
use one date in the comment of the vendored copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
certifi 2026.10.18, found by cloud-registry's weekly scan in its image
(built on FOCA's), still trusts the emSign root CAs whose intermediate
CAs have compromised keys (GHSA-6q48-6c7w-9gw2, critical; fixed in
2026.10.19). FOCA uses certifi via requests; add a floor, so that the
images and installs of FOCA never get an affected version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR hardens all FOCA Python images by upgrading pip to at least 26.2, raises setuptools and certifi floors for source builds and runtime dependencies, and narrowly documents and suppresses only the remaining vulnerabilities in pip's vendored packages.

File-Level Changes

Change Details Files
Standardize the base images on a current pip release while retaining pip for downstream application builds.
  • Remove setuptools and wheel, then upgrade pip to a minimum of 26.2 across all Python variants.
  • Document the resulting pip behavior and compatibility considerations for derived images.
docker/Dockerfile
docs/migration-0.17.md
Add targeted vulnerability suppressions for pip's unavoidable vendored dependencies.
  • Correct the pip SBOM location in the explanatory comment.
  • Ignore the newly reported setuptools and urllib3 vendored-copy CVEs by exact package URL, with usage rationale and expiry dates.
.trivyignore.yaml
Raise project dependency floors to address build-time and runtime vulnerabilities.
  • Require setuptools 83 or newer for source builds.
  • Require certifi 2026.10.19 or newer through the project's dependency set.
pyproject.toml
docs/migration-0.17.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4721f68) to head (ba376ac).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #441   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         2869      2869           
=========================================
  Hits          2869      2869           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 23, 2026 15:06

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docker/Dockerfile" line_range="25" />
<code_context>
+# upgrade it to the latest release (a no-op where the image already ships
+# that one)
+RUN pip uninstall --yes --no-cache-dir setuptools wheel && \
+    pip install --no-cache-dir --upgrade "pip>=26.2"

 # Build image
</code_context>
<issue_to_address>
**Malicious index stalls builds**

When a configured package index is compromised or otherwise serves a malicious chunked-deflate response, `pip install` uses pip’s vendored urllib3 2.7.0 to fetch from the configured package index; a malicious index response triggers its infinite loop, stalling image or derived-app builds and consuming CI capacity.

Use a pip release with patched vendored urllib3 when available, or otherwise prevent vulnerable pip from processing untrusted index responses.

Also at `.trivyignore.yaml:38`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the certifi minimum changes the CA bundle used for TLS verification, so a faulty bundle could allow a compromised certificate to pass and expose data in connections made before the image is corrected. Reverting restores the previous bundle, but it cannot undo any exposure that already occurred.

Blocking findings: docker/Dockerfile:25


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docker/Dockerfile Resolved
@uniqueg
uniqueg merged commit 9583ae8 into dev Oct 23, 2026
23 checks passed
@uniqueg
uniqueg deleted the fix/437-image-python-packages branch October 23, 2026 15:17
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