Repository navigation
fix(security): build images from hashed lock files (Fixes #121) - #215
Merged
Merged
Conversation
- requirements.lock and middleware/requirements.lock pin every package (transitive included) with sha256 hashes, generated by scripts/lock.sh (uv pip compile --universal --generate-hashes; agent for Python 3.10+, middleware 3.12+). Re-running keeps existing pins, so output is stable. - Both Dockerfiles install with pip --require-hashes --no-deps from the lock: a tampered or re-published package fails the build. - CI "Dependency Lock" job: lock must match requirements.txt, hash-enforced install + pip check, full test suite on the locked versions, and blocking pip-audit on both locks. - Weekly lock-refresh workflow runs scripts/lock.sh --upgrade and opens a PR; Dependabot keeps actions and base images (pip entries removed). - CONTRIBUTING: how to change dependencies and regenerate the lock. Fixes #121
Merged
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.
Fixes #121.
Problem
Every image build installed
requirements.txt's open>=ranges, so it pulled whatever was newest on PyPI that day, unpinned and unhashed. A malicious release live for even two hours (the LiteLLM 1.107.0 incident) would have gone straight into our images, and two builds of the same commit could differ.Change
requirements.lock,middleware/requirements.lockscripts/lock.shuv pip compile --universal --generate-hashes. A plain run keeps existing pins and is stable (checked: same output twice).--upgrademoves to the newest allowed versions.docker/Dockerfile,middleware/Dockerfilepip install --require-hashes --no-deps -r requirements.lock: nothing outside the lock, and every file must match its hash.requirements.txt; installs with hashes enforced pluspip check; runs the full test suite on the locked versions; runspip-audit --stricton both locks (blocking)..github/workflows/lock-refresh.ymlscripts/lock.sh --upgrade, then opens or updates adeps/lock-refreshPR, so upgrades are reviewed.dependabot.ymlCONTRIBUTING.mdVerified locally
--require-hashes --no-deps -r requirements.lock, andpip checkis clean. 1429 passed, 4 skipped against the locked versions.THESE PACKAGES DO NOT MATCH THE HASHESand installs nothing.pip-audit -r … --require-hashes --strict: no known vulnerabilities in either lock.Notes
safety check || truestep for Make CI lint and security scans fail the build #18 to decide.requirements.txt(for example fix(api): report the installed or source package version #203, which addstomlifor Python 3.10) need to runscripts/lock.shand commit the lock, or the new job fails with that instruction.GITHUB_TOKEN, which doesn't trigger CI by itself. The PR body says to close and reopen it.