Assert secret-bearing paths are not Nix store paths - #106
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (8)
WalkthroughThe NixOS modules now reject secret-bearing files stored under ChangesRuntime secret path validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nixos/frost-gate.nix`:
- Around line 838-840: Update the runtime-path prefix guards in
nixos/frost-gate.nix lines 838-840, nixos/ingress.nix lines 108-114, and
nixos/vault-replication.nix line 206 to check against "${builtins.storeDir}/"
rather than builtins.storeDir, preventing similarly prefixed paths such as
/nix/storehouse from being rejected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2fc6c62e-2e5d-450a-a233-f65846d80e80
📒 Files selected for processing (8)
nixos/frost-gate.nixnixos/ingress.nixnixos/vault-replication.nixtests/ha-failover.nixtests/ingress.nixtests/mesh-replication.nixtests/oprf-gate-2of3.nixtests/oprf-gate.nix
d1c8801 to
0cc962a
Compare
|
Valid, fixed, and applied beyond the four assertions this PR added.
So the boundary form is strictly better: it still rejects every real store path, which is the security property, and stops rejecting paths that merely share the prefix. The failure was in the fail-closed direction, refusing valid input rather than accepting invalid input, which is why it is a correctness bug rather than a hole. Fixed all nine sites, not just the four added here. The pre-existing guards on
|
Summary
Four options document that they need a runtime path and nothing enforced it. Adds the same
hasPrefix builtins.storeDirassertion the sibling options already carry, and restages the five test fixtures that were deliberately passing store paths.Why it matters
keepNode.vaultReplication.rsaKeyFile = "${./secrets/rsa_key.pem}"type-checks. It copies the cluster-wide Vaultwarden JWT signing key into/nix/storeat 0444, where every local user can read it. CI'swarmjob then pushes store paths to the public privkey Cachix cache, so this is not only a local-permissions problem.Unenforced until now:
vaultReplication.rsaKeyFileingress.tlsKeyFileingress.tlsCertFilefrostGate.keepPasswordEnvFileKEEP_PASSWORDkeepWeb.{passwordFile,authTokenFile,stateIdentityFile,storageKeyFile}andmesh.identityDiralready assert exactly this for identical wording. These four were the gap.Test fixtures
Five VM tests passed store paths on purpose, two with comments saying so. They now stage the fixture into
/runat boot and point the option at the runtime path, which is the patterntests/mesh-discovery.nixandtests/wisp-mesh.nixalready use foridentityDir:Ordering was checked rather than assumed. No consumer runs in initrd or sysinit: the OPRF provision unit is operator-run and explicitly not
wantedByboot, and the gate, nginx and vault-replication are ordinarymulti-user.targetservices, which order aftersysinit.targetand therefore aftersystemd-tmpfiles-setup.service. No explicitAfter=is needed.Test plan
builtins.storeDir, null-guarded where the option is nullablenix-instantiate --parsesystemd-tmpfilesCcreates missing parent directories, so the staged files land even though nodrule precedes them. Verified against a scratch root; the copied file keeps its declared 0600 while the auto-created parent is 0755, so the file mode is what protects the secret.full-ci, since the fast lane does not run these tests. The five previously-failing checks areingress,ha-failover,mesh-replication,oprf-gateandoprf-gate-2of3.A local
nix flake check --no-buildcannot complete here: it stops atfrost-group-fixture.drv is not validbecause the fixture is not realised in this store. That is an environment limitation, not an evaluation error in these changes.Found by the security review on #104 and split out so the CRNG fix was not held up by fixture rework.
Summary by CodeRabbit
Bug Fixes
Tests