Repository navigation
fix(images): restore pinned Python source integrity verification - #460
LukeSheard wants to merge 1 commit into
Conversation
Co-authored-by: LukePS <9877376+LukeSheard@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mangeshraut712
left a comment
There was a problem hiding this comment.
I checked both pins: I downloaded Python-3.14.8.tar.xz and Python-3.15.0.tar.xz from python.org/ftp and ran sha256sum, and they match the values in docker-bake.hcl. Verifying before bsdtar and before any build script runs is the right place for the check.
Outside this diff, the same class of issue is still open in the Node builds. images/node/Dockerfile and images/universal/Dockerfile (line ~12) pipe nodejs.org/dist/.../node-v${NODE_VERSION}-linux-x64.tar.xz straight into bsdtar with no digest. The fx step in universal checks a .sha256 fetched from the same release as the tarball, so it doesn't protect against a substituted upstream either. If the security finding is meant to cover image source integrity generally, a pinned NODE_SHA256 next to NODE_VERSION in the bake file would close it the same way. That could be a follow-up.
| # Build separately so compilers and headers are not shipped in the runtime image. | ||
| RUN curl -fsSL "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz" -o /tmp/python.tar.xz && \ | ||
| # Require a repository-pinned digest before downloading or extracting sources. | ||
| RUN test -n "${PYTHON_SHA256}" && \ |
There was a problem hiding this comment.
Nit: when the arg is missing, test -n fails the RUN with a bare exit status 1, which is hard to diagnose in a bake log. : "${PYTHON_SHA256:?PYTHON_SHA256 must be set for Python ${PYTHON_VERSION}}" && \ fails closed the same way and says why.
Why
The shared Python builder introduced in #418 removed the repository-pinned source checksum. A substituted upstream archive could therefore be extracted and execute build scripts as root, with its installed files copied into published images.
Fixes the Vercel security finding: Shared Python builder removes pinned source integrity verification.
This PR targets
luke/python-315-vmi, the affected branch of #418; the shared source builder is not onmainyet.Changes
PYTHON_SHA256and verify the downloaded bytes withsha256sum --check --strictbefore extraction or compilation. Missing, malformed, or mismatched digests fail closed; there is no default digest or network-fetched checksum.sandbox-image-python.Validation
A focused local reproduction exercised the actual Dockerfile source-download shell chain through extraction with a harmless XZ archive, a local curl fixture, and a tar-backed bsdtar shim:
prettier@3.5.3 --check) andgit diff --checkpassed.Full Docker image builds and runtime checks were not run because Docker is not installed in this environment. No images were published.