Skip to content

Security: delete setuptools from the image - #9

Merged
SandObserver merged 1 commit into
mainfrom
security/drop-setuptools-from-image
Aug 9, 2026
Merged

SandObserver merged 1 commit into
mainfrom
security/drop-setuptools-from-image

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Delete setuptools, setuptools-*.dist-info, _distutils_hack and distutils-precedence.pth from site-packages inside the same RUN that 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.
  • Assert the removal in the build: python3 -c 'import setuptools' must fail, and supervisord --version must still succeed, so a path that stops matching after a base image bump fails the build instead of silently removing nothing.
  • Add three tests to api/test/image-hardening.test.js covering the removed paths, the removal staying in the install layer, and the two build-time proofs.
  • Add a [Unreleased] → Security entry.

Why removal rather than an upgrade or an exception: apk del refuses 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 no pkg_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

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.
  • CHANGELOG.md updated under Unreleased if the change is user-visible.

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.
@SandObserver SandObserver added docker Pull requests that update docker code security Security fix labels Aug 9, 2026
@SandObserver
SandObserver merged commit 9ad9c40 into main Aug 9, 2026
4 checks passed
@SandObserver
SandObserver deleted the security/drop-setuptools-from-image branch August 9, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update docker code security Security fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant