Skip to content

Fix CVEs by removing unused OS packages and updating dependencies - #545

Merged
moshemorad merged 4 commits into
mainfrom
claude/krr-enforcer-cve-patching-rcvkxt
Jul 27, 2026
Merged

Fix CVEs by removing unused OS packages and updating dependencies#545
moshemorad merged 4 commits into
mainfrom
claude/krr-enforcer-cve-patching-rcvkxt

Conversation

@moshemorad

Copy link
Copy Markdown
Contributor

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

  • Remove unused OS packages with unfixed CVEs that are not required at runtime:
    • perl-base (8 CVEs including CRITICAL severity)
    • util-linux, bsdutils, mount, and related libraries (3+ CVEs each)
    • Verification logic ensures packages are actually removed and core functionality (Python imports, bash) still works
  • Preserve essential packages despite CVEs:
    • ncurses - required by bash for debugging via kubectl exec/docker exec
    • login - dpkg-protected package that cannot be removed

pyproject.toml

  • setuptools: ^80.9.0^83.0.0 (fixes CVE-2026-23949, CVE-2026-24049, CVE-2026-59890)
  • pillow: Added pinned version ^12.3.0 (fixes 10 HIGH severity CVEs)
  • pyasn1: Added pinned version ^0.6.4 (fixes 2 HIGH severity CVEs)

requirements.txt

  • Updated transitive dependency versions to match pyproject.toml changes:
    • pillow: 12.2.0 → 12.3.0
    • pyasn1: 0.6.3 → 0.6.4
    • setuptools: 80.9.0 → 83.0.0

Implementation Details

  • The Dockerfile purge operation uses --force-remove-essential --force-depends flags since dpkg exits non-zero on essential package warnings even when removals succeed
  • Explicit verification loop confirms each package was actually removed before proceeding
  • Post-removal sanity checks verify Python imports and bash functionality remain intact

https://claude.ai/code/session_01HB2xE7yTmsQWues52YDqw6

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
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c00cacd3-b093-4976-8a6a-a41fa003a819

📥 Commits

Reviewing files that changed from the base of the PR and between 66e05db and dd66618.

📒 Files selected for processing (1)
  • Dockerfile
🚧 Files skipped from review as they are similar to previous changes (1)
  • Dockerfile

Walkthrough

Updates 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.

Changes

Security hardening

Layer / File(s) Summary
Python dependency pin updates
pyproject.toml, requirements.txt
Updates pinned versions of setuptools, pillow, and pyasn1 across project dependency declarations.
Docker package purge and validation
Dockerfile
Purges selected Debian packages, removes apt lists, verifies removal, and checks robusta_krr, Python uuid, and Bash execution.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing unused OS packages and updating dependencies to address CVEs.
Description check ✅ Passed The description is clearly related to the changeset and explains the Dockerfile and dependency updates in detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/krr-enforcer-cve-patching-rcvkxt

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e96b24 and e8a5422.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Dockerfile
  • pyproject.toml
  • requirements.txt

Comment thread Dockerfile
Avi-Robusta
Avi-Robusta previously approved these changes Jul 27, 2026

@Avi-Robusta Avi-Robusta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
claude added 2 commits July 27, 2026 09:06
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
@moshemorad
moshemorad merged commit d6baa74 into main Jul 27, 2026
3 checks passed
@moshemorad
moshemorad deleted the claude/krr-enforcer-cve-patching-rcvkxt branch July 27, 2026 09:40
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.

3 participants