fix(docker): purge uv wheel cache after opencv swap [security]#570
Merged
lawrence-u10d merged 1 commit intomainfrom Apr 22, 2026
Merged
fix(docker): purge uv wheel cache after opencv swap [security]#570lawrence-u10d merged 1 commit intomainfrom
lawrence-u10d merged 1 commit intomainfrom
Conversation
The 0.1.4 fix uninstalled opencv-python and installed the ffmpeg-free replacement, but the original wheel's extracted contents remained in ~/.cache/uv/archive-v0/.../opencv_python.libs/ (libavcodec.so.59.*, libavformat, libavutil, libswscale, libswresample, libavfilter, libavdevice). Image scanners walk the whole filesystem and still flagged the 14 ffmpeg CVEs from those cache files even though nothing links against them at runtime. Add `uv cache clean` at the end of the opencv replacement RUN so the vulnerable libs are evicted from the final image layer. Safe because UV_LINK_MODE=copy ensures installed files are independent copies, not cache hardlinks. Bumps service version 0.1.4 -> 0.1.5. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aballman
approved these changes
Apr 22, 2026
william-u10d
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #569 (v0.1.4). That PR replaced the PyPI
opencv-pythonwheel with an ffmpeg-free build, but image scanners were still flagging the 14 ffmpeg CVEs against v0.1.4. Root cause is scanner scope, not a broken replacement.Root cause
uv pip uninstallonly drops a package fromsite-packages. The extracted wheel archive stays in the uv cache. Inspecting the pushed v0.1.4 image:cv2.__version__reports4.12.0(our replacement wheel)site-packages/cv2/has no.libs/directory/home/notebook-user/.cache/uv/archive-v0/<hash>/opencv_python.libs/still contains the full extracted old wheel:libavcodec-*.so.59.37.100libavformat-*.so.59.27.100libavutil-*.so.57.28.100libavfilter,libavdevice,libswscale,libswresampleSO-version suffixes (avcodec 59.37 / avformat 59.27 / avutil 57.28) are ffmpeg 5.1.x — matching the CVE set the upstream PR called out. Scanners walk the whole filesystem and flag these even though nothing links against them at runtime.
UV_LINK_MODE=copy(set globally in this Dockerfile) compounds it — the cache keeps its own copy independent ofsite-packages.Fix
Add
uv cache cleanto the end of the opencv replacementRUNto wipe the cache (including the old opencv wheel archive) from the final image layer. Single minimal change — scoped to the opencv-fix RUN, not a broader image-slimming pass.Safe because
UV_LINK_MODE=copymeans the live venv copies files out of cache — wiping the cache doesn't affect the installed packages.False positives ignored (not fixed here)
Two other
libav*filenames in the image that are not ffmpeg and don't trigger these CVEs:/usr/lib/libreoffice/program/libavmedia{gst,lo}.so— LibreOffice's "avmedia" framework shimpillow.libs/libavif-*.so.16— AV1 image codecVersion / Changelog
0.1.4→0.1.5CHANGELOG.mdentry under0.1.5→ Securityuv lockchangesTest plan
make docker-buildsucceeds onamd64andarm64find / -name \"libavcodec*\" -o -name \"libavformat*\" -o -name \"libswscale*\"returns nothing under/home/notebook-user/.cache/uv/and nothing undersite-packages/cv2/.libs/cv2.__version__still reports4.12.0.88andimport cv2; cv2.imdecode(...)smoke check works🤖 Generated with Claude Code
Note
Low Risk
Low risk: a single Docker build-step cleanup (
uv cache clean) plus version/changelog bumps; main risk is unintended impact on Docker layer caching or build time, not runtime behavior.Overview
Removes leftover ffmpeg
.sofiles from the built image by addinguv cache cleanafter uninstalling/reinstalling OpenCV wheels in the Dockerfile, preventing scanners from flagging CVEs from cached wheel contents.Bumps the service version to
0.1.5and adds a matchingCHANGELOG.mdsecurity entry describing the cache purge.Reviewed by Cursor Bugbot for commit f73143d. Bugbot is set up for automated code reviews on this repo. Configure here.