Skip to content

fix(docker): upgrade apt for CVE-2026-109518 - #698

Merged
uniqueg merged 2 commits into
devfrom
fix/apt-cve-2026-109518
Nov 4, 2026
Merged

uniqueg merged 2 commits into
devfrom
fix/apt-cve-2026-109518

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Upgrades apt and libapt-pkg7.0 to 3.0.4 in the base stage of docker/Dockerfile, which fixes CVE-2026-109518 (code scanning alerts #541 and #542). The pinned Python base images still have 3.0.3, and the newest upstream images checked today have the same digests.

The severity is UNKNOWN, so scans don't fail today. A rating of high or critical before the base images are rebuilt would fail the release scan of a tagged commit, after its images are pushed. The contributing guide now names this way of fixing a system package.

Closes #697

Verification

  • tests/test_image_requirements.py: the new test failed before the change, and 18 pass now.
  • docker build for Python 3.11 and 3.15 before and after the change: apt and libapt-pkg7.0 went from 3.0.3 to 3.0.4. The container runs as user 1000, reports the expected FOCA version, has the foca script and no pip, and /var/lib/apt/lists is empty.
  • Reviewers: adversarial-reviewer and quality-reviewer, one round.
  • CI builds and scans all five Python versions on this PR. The alerts can only close after the push to dev.

Declined review findings

  • Build-time check of the apt version in the Dockerfile (adversarial reviewer, low): the Trivy scan in CI already reports the package if the upgrade stops working, and the check would be one more line to remove later. The other half of that finding, the test's regex matching a commented-out line, is fixed.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Upgrade apt in the base Docker image to address CVE-2026-109518 until updated pinned base images are available.

Bug Fixes:

  • Upgrade the base image's apt and libapt-pkg7.0 packages to the CVE-2026-109518-fixed version.

Enhancements:

  • Document how to upgrade system packages when the pinned base image does not yet include a fix.

Tests:

  • Add coverage ensuring the base Docker stage upgrades apt for downstream image stages.

uniqueg and others added 2 commits November 4, 2026 23:14
The pinned Python base images have apt 3.0.3; the fix, 3.0.4, is in
trixie-security. Upgrade apt and libapt-pkg7.0 in the base stage, so
that a later rating of the CVE as high or critical can't fail the scan
of a tagged commit. The upgrade can go once all base images have it.

Closes #697

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg marked this pull request as ready for review November 4, 2026 22:17
@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #698   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           66        66           
  Lines         8588      8588           
=========================================
  Hits          8588      8588           
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 commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR mitigates CVE-2026-109518 by upgrading apt and libapt-pkg7.0 in the shared Docker base stage, cleans up package metadata, documents the workaround for stale pinned images, and adds a regression test to prevent the upgrade from being removed.

Flow diagram for the Docker apt vulnerability fix

flowchart TD
    A[Pinned Python base image] --> B[base stage]
    B --> C[apt-get update]
    C --> D[Upgrade apt and libapt-pkg7.0 to 3.0.4]
    D --> E[Remove /var/lib/apt/lists]
    E --> F[Derived FOCA images]
Loading

File-Level Changes

Change Details Files
Upgrade vulnerable APT packages in the shared Docker base stage before downstream image stages are built.
  • Run an update followed by an --only-upgrade of apt and libapt-pkg7.0 to version 3.0.4 or the repository-provided fixed version.
  • Remove APT package lists after installation to preserve the existing image hygiene and size characteristics.
  • Document the temporary system-package upgrade procedure for cases where pinned base images lack the fix.
docker/Dockerfile
docs/contributing/index.md
Add a structural regression test ensuring the base stage performs the required APT upgrade.
  • Extract the Dockerfile base stage and assert that it contains the expected non-commented install command for both packages.
tests/test_image_requirements.py

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

@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="tests/test_image_requirements.py" line_range="47-48" />
<code_context>
+    text = (ROOT / "docker/Dockerfile").read_text()
+    base_stage = text.partition(" AS base\n")[2].partition(" AS builder\n")[0]
+    assert re.search(
+        r"^\s*apt-get install -y --no-install-recommends --only-upgrade "
+        r"apt libapt-pkg7\.0\b",
+        base_stage,
+        re.M,
</code_context>
<issue_to_address>
**Disabled upgrade still passes**

When the matched command is present only in a non-executed shell branch, `test_base_stage_upgrades_apt`'s `re.search` at lines 46–50 matches the literal install command even inside a non-executed shell branch, so the test passes although the image does not upgrade apt.

Verify the built image's apt package version, or otherwise ensure the matched command is in an executed `RUN` path.
</issue_to_address>

Linked issues

#697 fix(docker): upgrade apt for CVE-2026-109518 · 2 of 2 met

# Requirement Status Notes
1 Upgrade apt and libapt-pkg7.0 in the base stage so the image has the fix regardless of the pinned base image. ✅ Met The base stage updates package metadata and upgrades both packages; the PR reports verifying version 3.0.4 in builds.
2 Ensure images built on the FOCA image also get the fixed apt. ✅ Met The upgrade is in base, which later stages inherit.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/test_image_requirements.py:48


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

Comment thread tests/test_image_requirements.py Resolved

@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 reviewed your changes and they look great!

Linked issues

#697 fix(docker): upgrade apt for CVE-2026-109518 · 3 of 3 met

# Requirement Status Notes
1 Upgrade apt and libapt-pkg7.0 in the base stage so the image has the fix regardless of the pinned base images. ✅ Met The base stage updates package lists and upgrades both packages.
2 Ensure images built on the FOCA image also get the fixed apt for their own package installs. ✅ Met Both the builder and final stages derive from base.
3 Make the temporary upgrade removable once all pinned base images have the fix. ✅ Met The Dockerfile comment records when the upgrade can be removed.

Sourcery assessment

Approved.


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

@uniqueg
uniqueg merged commit cd8cc2a into dev Nov 4, 2026
87 of 108 checks passed
@uniqueg
uniqueg deleted the fix/apt-cve-2026-109518 branch November 4, 2026 23:01
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.

fix(docker): upgrade apt for CVE-2026-109518

1 participant