Repository navigation
fix(image): bake explicit substituters/keys instead of accept-flake-config - #782
Merged
c-vigo merged 2 commits intoJun 30, 2026
Merged
Conversation
…onfig Baking accept-flake-config = true into /etc/nix/nix.conf let any in-container `nix run github:attacker/flake` silently accept that flake's substituters/trusted-public-keys, a cache-redirection supply-chain trapdoor. Drop it and pin the trusted caches explicitly (cache.nixos.org + the public vig-os Cachix cache) so normal builds still substitute, while a foreign flake's nixConfig now requires a per-invocation --accept-flake-config. Refs: #773
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.
Problem
accept-flake-config = truewas baked into the image's/etc/nix/nix.conf. That made any in-containernix run github:attacker/flakesilently accept that flake'ssubstituters/trusted-public-keys— the textbook Nix cache-redirection supply-chain attack (PR #670 roadmap thread A).Fix
accept-flake-config = truefrom the baked nix.conf.substituters+trusted-public-keysso normal builds still hit the caches, while a foreign flake'snixConfignow requires a per-invocation--accept-flake-config.experimental-featuresand the emptybuild-users-group =(fix(image): set empty build-users-group in baked nix.conf #750) intact.Keys/URLs are taken verbatim from the repo's existing source of truth,
CONTRIBUTE.md:44-45(the publicvig-osCachix cache + upstreamcache.nixos.org). These are PUBLIC keys, safe to bake.Baked
/etc/nix/nix.conf— before / afterBefore:
After (verified by extracting the built image tarball's bootstrap layer):
Cachix key source
vig-os.cachix.org-1:yoOYRi3bvnM6ThxO0joLt7vtzhTfkq3r6jykeUMg7Bk=—CONTRIBUTE.md:45(the documentedvig-osCachix substituter setup). Not invented.Tests
Extended
tests/test_image.py::TestNixConfiguration(alongside the existing #749build-users-groupassertions) with three testinfra checks against the baked nix.conf:test_nix_conf_does_not_accept_flake_config— assertsaccept-flake-config = trueis gone.test_nix_conf_bakes_explicit_substituters— asserts both cache URLs present.test_nix_conf_bakes_trusted_public_keys— asserts both public keys present.Verification
nix flake check --accept-flake-config— all checks passed.nix build .#devcontainerImage— succeeded, substituted from caches (no mass source rebuild); extracted the resulting tarball and confirmed the baked nix.conf matches the "after" block above.nixfmt --check flake.nix,ruff check/formaton the test, andpre-commit run --files ...— all relevant hooks pass.Branch note
The originally-suggested
security/branch prefix is rejected by the repo's mandatoryno-commit-to-branchhook (allowed types:feature|bugfix|hotfix|release|docs|test|refactor, pluschore/andworktree/). A security fix maps tobugfix, so this PR is onbugfix/773-explicit-substituters.Closes #773.