Skip to content

[Security] Clear AWS Inspector CVE findings on Docker image - #27225

Merged
yuneng-berri merged 10 commits into
BerriAI:litellm_yj_may7from
stuxf:cve-sweep-2026-05
May 8, 2026
Merged

[Security] Clear AWS Inspector CVE findings on Docker image#27225
yuneng-berri merged 10 commits into
BerriAI:litellm_yj_may7from
stuxf:cve-sweep-2026-05

Conversation

@stuxf

@stuxf stuxf commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Relevant issues

N/A — driven by AWS Inspector v2 (ECR) findings on ghcr.io/berriai/litellm:v1.83.14-stable.patch.1.

Linear ticket

N/A

Pre-Submission checklist

  • Added tests/test_litellm/caching/test_disk_cache.py covering JSONDisk enforcement, dict / string round-trip, TTL, increment, delete/flush.
  • PR passes new tests locally (8/8 pass on pytest tests/test_litellm/caching/test_disk_cache.py).
  • PR scope is isolated to clearing scanner findings on the published Docker image.
  • Greptile review pending (will request after CI green).

CI (LiteLLM team)

  • Branch creation CI run — Link:
  • CI run for the last commit — Link:
  • Merge / cherry-pick CI run — Links:

Screenshots / Proof of Fix

Combined trivy fs + grype dir scan against the patched worktree:

Scanner Before After
trivy fs 6 findings (1 High next, 5 Medium: diskcache, postcss×2, hono, uuid) 0 in shipped code (1 in tests/.../Gemfile.lock, doesn't ship)
grype 17 findings (setuptools×2, python-3.13×4, langchain-text-splitters, diskcache, postcss×2, black, langchain-openai, pytest, gitpython×2, next, hono, uuid) 4 (all Wolfi python-3.13 CVEs, see Notes)

JSONDisk smoke test:

$ pytest tests/test_litellm/caching/test_disk_cache.py -v
test_disk_cache_uses_jsondisk PASSED
test_disk_cache_dict_round_trip PASSED
test_disk_cache_string_round_trip_decodes_json PASSED
test_disk_cache_string_round_trip_returns_raw_when_not_json PASSED
test_disk_cache_increment PASSED
test_disk_cache_ttl_expiry PASSED
test_disk_cache_delete_and_flush PASSED
test_disk_cache_missing_key_returns_none PASSED
======== 8 passed in 2.09s ========

Type

🚄 Infrastructure

Changes

Real logic (5 files)

  1. Dockerfile — Narrow COPY --from=builder /root/.cache /root/.cache to just /root/.cache/prisma and /root/.cache/prisma-python. Drops ~660 MB of uv build cache that was being copied into the runtime image and surfacing a cached setuptools-68.1.2.dist-info as CVE-2024-6345 / CVE-2025-47273 even though it was never on sys.path.

  2. litellm/caching/disk_cache.py — Use dc.Cache(..., disk=dc.JSONDisk) instead of the default pickle-backed Disk to neutralize CVE-2025-69872 (no upstream fix exists for diskcache). Cleaned up the now-dead json.loads(dict) exception-fallthrough in get_cache by adding an isinstance(cached, str) guard. Updated the install hint to pip install diskcache directly.

  3. pyproject.toml — Removed the diskcache==5.6.3 pin from the [caching] extra (CVE-2025-69872 has no fixed version). Kept caching = [] as a stub so pip install litellm[caching] doesn't emit a "no such extra" warning during the deprecation window. Bumped black==24.10.026.3.1 (CVE-2026-32274).

  4. uv.lock — Regenerated with uv lock --upgrade-package black --upgrade-package GitPython --upgrade-package langchain-text-splitters --upgrade-package langchain-openai. Picks up gitpython 3.1.46 → 3.1.49 (clears two High GHSAs) and langchain-text-splitters 1.1.1 → 1.1.2.

  5. ui/litellm-dashboard/package-lock.json + litellm-js/spend-logs/package-lock.json — Regenerated with npm install --package-lock-only. Picks up next 16.1.7 → 16.2.4, uuid 14.0.0, postcss 8.5.13, hono 4.12.16.

Mechanical churn (296 files)

  • Black 26.3.1 reformat. Coupled to the version bump (CI's black --check would otherwise fail on the new style). No semantic changes.

New tests (1 file)

  • tests/test_litellm/caching/test_disk_cache.py — Asserts JSONDisk is the active backend (regression guard for the CVE fix), exercises round-trip / TTL / counter / delete paths.

Notes

  • Existing on-disk caches: Users with a populated .litellm_cache/ directory written by the previous pickle-backed Disk will see silent cache misses after upgrade (JSONDisk can't read pickle blobs). DiskCache is intended to be ephemeral so impact is "rebuild on next write." Worth calling out in release notes.
  • litellm[caching] deprecation: Anyone with litellm[caching] in their requirements file will silently get the empty stub instead of diskcache. They'll see the friendlier ModuleNotFoundError (with pip install diskcache hint) on first Cache(type="disk") use.
  • 4 remaining Wolfi findings (out of scope): python-3.13 CVE-2025-15366, CVE-2025-15367, CVE-2025-12781 are upstream WONTFIX in CPython 3.14; CVE-2026-3298 is Windows-only (asyncio.ProactorEventLoop) and unreachable on Linux. Migrating from wolfi-base + apk add python3 to Chainguard's continuously-remediated cgr.dev/chainguard/python image would clear them but is a separate Dockerfile-restructuring change.

🤖 Generated with Claude Code

- Narrow /root/.cache COPY in Dockerfile to /root/.cache/prisma{,-python}
  only — drops ~660MB of uv build cache including a setuptools wheel
  that surfaced as CVE-2024-6345 / CVE-2025-47273 even though it was
  never on the runtime sys.path.
- DiskCache: switch to dc.JSONDisk to neutralize the pickle code path
  (CVE-2025-69872, no upstream fix). Values must be JSON-serializable;
  cleanup get_cache to skip the now-dead json.loads(dict) branch by
  guarding on isinstance(str).
- pyproject.toml: drop diskcache pin from [caching] extra (no fixed
  version exists). Stub kept so `pip install litellm[caching]` doesn't
  warn; users who want disk caching install diskcache themselves.
- Bump black 24.10.0 → 26.3.1 (CVE-2026-32274) + apply 296-file mechanical
  reformat. Black is dev-only (not in the runtime image), but bumping
  clears the manifest-scan finding.
- Refresh ui/litellm-dashboard/package-lock.json to pick up next 16.2.4
  (was 16.1.7, GHSA-q4gf-8mx6-v5v3), uuid 14.0.0, postcss 8.5.13.
- Refresh litellm-js/spend-logs/package-lock.json to pick up
  hono 4.12.16 (GHSA-458j-xx4x-4375).
- uv lock: gitpython 3.1.46 → 3.1.49 (clears two High GHSAs),
  langchain-text-splitters 1.1.1 → 1.1.2.
- Add tests/test_litellm/caching/test_disk_cache.py covering JSONDisk
  enforcement, dict/string round-trip, TTL, increment, delete/flush.

Net delta on combined trivy + grype scans: 17 findings → 4 (all
remaining 4 are Wolfi system python-3.13 CVEs marked WONTFIX upstream
in CPython 3.14; CVE-2026-3298 is Windows-unreachable on Linux).

Existing on-disk caches written by the previous pickle-format Disk
will silently miss after upgrade — diskcache is intended to be
ephemeral so impact is recreate-on-next-write.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stuxf
stuxf requested a review from a team May 5, 2026 20:22
@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

stuxf and others added 5 commits May 5, 2026 20:45
…ut diskcache

- Add black to liccheck.ini Authorized Packages (MIT-licensed).
- pytest.importorskip("diskcache") at top of test_disk_cache.py so
  the test skips cleanly when diskcache isn't installed (it's no longer
  pulled in by the dev group after the CVE-2025-69872 mitigation).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… cve-sweep-2026-05

# Conflicts:
#	tests/llm_responses_api_testing/conftest.py
#	tests/llm_translation/conftest.py
#	tests/logging_callback_tests/conftest.py
PR was blocked by .github/workflows/guard-fork-dependencies.yml: fork PRs
cannot modify uv.lock. Reverting:

- uv.lock + pyproject.toml black bump (24.10.0 -> 26.3.1) and the 295
  files of mechanical Black 26 reformat coupled to it
- pyproject.toml diskcache extra change (kept the runtime mitigation in
  litellm/caching/disk_cache.py via JSONDisk)

Kept:
- Dockerfile cache narrowing (drops ~660 MB of uv build cache that
  surfaced cached setuptools as CVE findings)
- litellm/caching/disk_cache.py: dc.JSONDisk to neutralize CVE-2025-69872
- ui/litellm-dashboard/package-lock.json + litellm-js/spend-logs/package-lock.json:
  next/postcss/hono/uuid CVE bumps (these are not blocked by the fork guard)
- tests/test_litellm/caching/test_disk_cache.py
- tests/code_coverage_tests/liccheck.ini: harmless black authorization

Black + gitpython + langchain dep upgrades will need a follow-up from a
maintainer pushing a branch in the canonical BerriAI/litellm repo.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pin the new digest published 2026-05-05:
sha256:31da6565... (from sha256:3258be47...).

Delta in baseline packages: zlib 1.3.2-r2 -> 1.3.2-r3. glibc stays at
2.43-r7 (still the latest available; whatever further glibc fixes for
CVE-2026-5450 / CVE-2026-5928 land in -r8+ from Chainguard, this PR
doesn't touch those).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yuneng-berri

Copy link
Copy Markdown
Contributor

@greptile

@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR clears AWS Inspector CVE findings on the published Docker image through a combination of Dockerfile hardening, dependency version bumps, and a diskcache backend switch. The visible diff covers the Dockerfile narrowing, and regenerated package-lock.json files for the dashboard and spend-logs UI.

  • Dockerfile: Replaces the broad COPY --from=builder /root/.cache /root/.cache with targeted copies of only /root/.cache/prisma and /root/.cache/prisma-python, eliminating ~660 MB of uv build cache (including a setuptools wheel that triggered CVE-2024-6345 / CVE-2025-47273) from the runtime image. The wolfi-base digest and npm version are also bumped.
  • ui/litellm-dashboard/package-lock.json: Regenerated to pick up next, postcss, uuid, hono, and various CSS-tooling bumps that resolve the scanner findings.
  • litellm-js/spend-logs/package-lock.json: Single get-tsconfig patch bump; otherwise unchanged.

Confidence Score: 5/5

Safe to merge; all changes in the visible diff are targeted security remediations with no logic modifications to production code paths.

The Dockerfile change is a straightforward scope reduction of an existing COPY instruction, and both targeted subdirectories are created unconditionally by prisma generate in the builder stage. The package-lock bumps are mechanical version upgrades with no production logic altered.

No files require special attention; the Dockerfile COPY narrowing carries a small build-fragility trade-off if prisma cache layout ever shifts.

Important Files Changed

Filename Overview
Dockerfile Narrows COPY from broad /root/.cache to specific prisma subdirs; bumps wolfi-base digest and npm version — clean security improvement with a minor build-fragility trade-off.
ui/litellm-dashboard/package-lock.json Mechanical dependency bumps (next, postcss, uuid, csstools, esbuild, emnapi, etc.) to clear CVE findings; no logic changes.
litellm-js/spend-logs/package-lock.json Single get-tsconfig version bump (4.13.0 → 4.14.0); purely mechanical.

Reviews (2): Last reviewed commit: "Drop liccheck black allowlist entry" | Re-trigger Greptile

Comment thread litellm/caching/disk_cache.py Outdated
Comment thread litellm/caching/disk_cache.py Outdated
stuxf and others added 3 commits May 7, 2026 23:56
Empirical grype scan of the built runtime image flagged
ip-address@10.1.0 (Medium) bundled inside /usr/local/lib/node_modules/npm.
npm@11.14.0 bundles ip-address@10.1.1 which carries the fix.

Verified by rebuilding the image and rescanning: ip-address finding gone.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Revert disk_cache.py JSONDisk swap + remove test_disk_cache.py. The
JSONDisk migration is backwards-incompatible (existing pickle caches
become unreadable; non-JSON values raise unguarded TypeError on set)
and warrants its own focused PR with a feature flag rather than riding
along with the CVE/dep-bump sweep.

CVE-2025-69872 remains unmitigated at the diskcache layer; users
concerned about pickle-RCE on cache-dir writers can avoid Cache(type="disk")
or pin a fork until upstream ships a fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The entry was added to cover the now-reverted black 24.10.0 -> 26.3.1
bump. With the bump dropped, upstream's existing liccheck setup is
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yuneng-berri

Copy link
Copy Markdown
Contributor

@greptile

@yuneng-berri
yuneng-berri changed the base branch from litellm_internal_staging to litellm_yj_may7 May 8, 2026 00:18
@yuneng-berri
yuneng-berri merged commit 5082f9b into BerriAI:litellm_yj_may7 May 8, 2026
30 of 31 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
[Security] Clear AWS Inspector CVE findings on Docker image
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.

2 participants