Fix CVEs by removing unused OS packages and updating dependencies - #545
Conversation
Scanned both images with Trivy and remediated per policy: all CRITICAL and HIGH findings, plus MEDIUM findings older than 60 days. 50 of the 69 in-policy findings are resolved; the krr image goes from 4 CRITICAL / 33 HIGH / 191 total to 0 CRITICAL / 7 HIGH / 86 total. The enforcer image already scanned clean (0 findings across 39 Alpine and 64 Python packages) and is unchanged. Dependency bumps (requirements.txt, pyproject.toml, poetry.lock): - pillow 12.2.0 -> 12.3.0, clearing 10 HIGH and 3 MEDIUM - pyasn1 0.6.3 -> 0.6.4, clearing CVE-2026-59885 and CVE-2026-59886 (HIGH) - setuptools 80.9.0 -> 83.0.0. setuptools >=81 vendors jaraco.context 6.1.0 and wheel 0.46.3, which clears CVE-2026-23949 and CVE-2026-24049 (both HIGH, reachable only through setuptools' bundled copies) plus CVE-2026-59890 pillow and pyasn1 are transitive (via matplotlib and google-auth), so they are now pinned explicitly in pyproject.toml to hold the fixed floors. poetry.lock was regenerated with Poetry 1.8.5 to keep lock-version 2.0, matching the existing file; only these three package entries change. Dockerfile: the remaining OS findings all sit in Debian trixie packages with no fixed version published, and apt-get upgrade is a verified no-op, so the only remedy is to stop shipping the packages. perl-base (4 CRITICAL, 4 HIGH, 4 MEDIUM) and the util-linux family (CVE-2026-53615 HIGH plus 2 MEDIUM each) are unused by this pure-Python app and are now purged. dpkg exits non-zero on essential-package warnings even when every removal succeeds, so the layer verifies each removal explicitly and then smoke-tests the interpreter and bash rather than trusting the exit code. ncurses is deliberately kept: bash links libtinfo.so.6, and removing it leaves the image without a working shell for kubectl/docker exec. login cannot be removed at all (dpkg protected). Those account for 5 of the 7 remaining HIGH findings; gzip and libacl1 are the other two. Verified on linux/amd64: 55/55 tests pass, image builds, krr version and --help run, and numpy/pandas/matplotlib/pillow import and render. The purge layer and the three bumped packages were checked on linux/arm64 as well. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughUpdates Python dependency pins and adds a Docker build step that purges selected Debian packages, removes apt lists, verifies package removal, and runs runtime sanity checks. ChangesSecurity hardening
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Around line 50-54: Update the package-state validation loop in the Dockerfile
to query each package with dpkg-query’s ${db:Status-Status} field and accept
only an absent or not-installed result. Reject installed, config-files-only,
unpacked, half-configured, and any other non-absent state, while preserving the
existing failure message and exit behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c1b6188b-7a54-45eb-94d1-63c4a6b35e8d
⛔ Files ignored due to path filters (1)
poetry.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
Dockerfilepyproject.tomlrequirements.txt
Avi-Robusta
left a comment
There was a problem hiding this comment.
reminder to test before next release
Removing libuuid1 disables CPython's optional _uuid C accelerator; the stdlib uuid module falls back to its pure-Python implementation by design. Nothing in krr or its dependencies calls uuid1()/generate_time_safe (the only paths _uuid accelerates), and krr itself only imports the UUID class for parsing. The build-time verification now exercises uuid4/uuid1/getnode through the fallback so a future base-image change that breaks it fails the build instead of shipping. Also record why removing mount/util-linux cannot affect Kubernetes volume, secret or configmap mounts: the container runtime performs them on the host via mount(2) before the container rootfs starts, and never execs the in-image mount binary. Verified by running the purged image with bind, tmpfs and read-only-rootfs mounts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6
The previous grep on dpkg -l only matched ii/hi states, so a package left in a partial state (half-installed, unpacked) after the intentionally-ignored dpkg exit code could slip through. Query db:Status-Status and accept only absent or not-installed. Addresses the review comment on PR #545. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6
Summary
This PR addresses multiple CVEs in the krr container image and its dependencies by removing unused OS packages and updating vulnerable transitive dependencies to patched versions.
Key Changes
Dockerfile
perl-base(8 CVEs including CRITICAL severity)util-linux,bsdutils,mount, and related libraries (3+ CVEs each)ncurses- required by bash for debugging viakubectl exec/docker execlogin- dpkg-protected package that cannot be removedpyproject.toml
^80.9.0→^83.0.0(fixes CVE-2026-23949, CVE-2026-24049, CVE-2026-59890)^12.3.0(fixes 10 HIGH severity CVEs)^0.6.4(fixes 2 HIGH severity CVEs)requirements.txt
pillow: 12.2.0 → 12.3.0pyasn1: 0.6.3 → 0.6.4setuptools: 80.9.0 → 83.0.0Implementation Details
--force-remove-essential --force-dependsflags since dpkg exits non-zero on essential package warnings even when removals succeedhttps://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6