Repository navigation
Security: delete setuptools from the image - #9
Merged
Merged
Conversation
setuptools arrives as an apk dependency of supervisor and carries CVE-2026-59890 in the version Alpine 3.24 packages. apk refuses to remove it, but the dependency is packaging metadata, not a runtime need: supervisor has not required setuptools on Python 3.8 or newer, this image is 3.14, and the Alpine package ships no pkg_resources for anything to import. Delete it in the layer that installs supervisor, since a later layer would leave the files in this one, and prove both halves in the build: python3 can no longer import setuptools, and supervisord still reports its version.
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
setuptools,setuptools-*.dist-info,_distutils_hackanddistutils-precedence.pthfromsite-packagesinside the sameRUNthat installs nginx and supervisor. A later layer would leave the files present in the install layer, which is where the image and the scanner still carry them.python3 -c 'import setuptools'must fail, andsupervisord --versionmust still succeed, so a path that stops matching after a base image bump fails the build instead of silently removing nothing.api/test/image-hardening.test.jscovering the removed paths, the removal staying in the install layer, and the two build-time proofs.[Unreleased]→ Security entry.Why removal rather than an upgrade or an exception:
apk delrefuses because supervisor declares the dependency, but supervisor has not needed setuptools at runtime since Python 3.8 and this image is Python 3.14. The Alpine package was unpacked to confirm it ships nopkg_resources, so nothing can be importing it from there. Nothing in the image runs pip.Testing
All green. Added 3 tests; mutation-checked by moving the deletion into its own layer and by disabling the import check, each of which fails. The build-time assertions and the container boot are verified by CI: the docker build smoke test, and the e2e job, which starts the image and waits on
/health— supervisord failing to start would fail there.Checklist