Repository navigation
fix(security): make the spored signature gate able to fail (#813) - #823
Merged
Merged
Conversation
Emptying sporedSigningPublicKeyPEM is a one-literal, cleanly-compiling edit — and the documented way to disable signing. It makes every launch download and run spored UNVERIFIED from the same bucket that serves its checksum, which is precisely the gap #440 closed. Both gates passed against that revert. ## Why they could not fail bootstrap.go:201 SPORED_SIG_VERIFY=1 <- the real assignment bootstrap.go:391 # ... SPORED_SIG_VERIFY=1 <- shell COMMENT bootstrap.go:464 # ... SPORED_SIG_VERIFY=1 <- shell COMMENT bootstrap.go:263 appends linuxBootstrapBody UNCONDITIONALLY, so that string is in every bootstrap whether signing is on or off. TestBuildLinuxBootstrap_SigAwareFallback matched it with strings.Contains, so it was satisfied by the comment. TestBootstrap_SignatureEnabled injects its own TESTKEY and never reads production's value. And NO test asserted the production key existed at all — which is the gap that actually mattered. This is rule 3 from CLAUDE.md for the sixth time in this repo, in the one place that most needed to be unfakeable: the authenticity invariant is that the binary running as root on every instance is provably ours. ## Three changes 1. Match the ASSIGNMENT, anchored: `(?m)^SPORED_SIG_VERIFY=1$`. The two comment occurrences start with `#`, and the three runtime guards are `if [ "${SPORED_SIG_VERIFY:-0}" = "1" ]`, so only the real assignment matches. 2. TestProductionSigningKeyIsRealAndUsable asserts the compiled-in key is non-empty AND parses as an ECDSA P-256 public key. Parsing rather than length-checking is deliberate: a truncated or placeholder value satisfies a length check while failing openssl at boot on every instance — the same silent-downgrade shape one layer down. The curve is pinned to P-256 to match the KMS key spec (ECC_NIST_P256 / ECDSA_SHA_256). 3. The disabled path asserts the enabling assignment is ABSENT, not just that `=0` is present — a script emitting both would have passed. ## A test that could only skip TestBootstrap_SignatureDisabledByDefault opened with if signatureVerificationEnabled() { t.Skip(...) } and a key IS compiled in, so it skipped on every run while counting as coverage for the disabled path. sporedSigningPublicKeyPEM is a var precisely so a test can exercise that path, so it now sets it, asserts, and restores via t.Cleanup. Renamed to say what it tests. ## Verified against compiling reverts empty key -> 2 tests fail, including the newly-anchored one ("every launch would download and run spored unverified") REPLACE_ME key -> fails the PEM parse, which a length check misses Both build and vet clean before failing, so the gates actually ran. make check green across all 9 nested modules, check-docs, changelog, semgrep 0 findings.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #813
Emptying
sporedSigningPublicKeyPEMis a one-literal, cleanly-compiling edit —and the documented way to disable signing. It makes every launch download and run
spored unverified, from the same bucket that serves its checksum, which is
precisely the gap #440 closed.
Both gates passed against that revert.
Why they could not fail
bootstrap.go:263appendslinuxBootstrapBodyunconditionally, so thatstring is in every bootstrap whether signing is on or off.
TestBuildLinuxBootstrap_SigAwareFallbackmatched it withstrings.Contains, sothe comment satisfied it.
TestBootstrap_SignatureEnabledinjects its ownTESTKEYand never readsproduction's value. And no test asserted the production key existed at all —
the gap that actually mattered.
This is
CLAUDE.mdrule 3 for the sixth time in this repo, in the one placethat most needed to be unfakeable: the authenticity invariant is that the binary
running as root on every instance is provably ours.
Three changes
(?m)^SPORED_SIG_VERIFY=1$. The twocomment occurrences start with
#, and the three runtime guards areif [ "${SPORED_SIG_VERIFY:-0}" = "1" ], so only the real assignment matches.TestProductionSigningKeyIsRealAndUsableasserts the compiled-in key isnon-empty and parses as an ECDSA P-256 public key. Parsing rather than
length-checking is deliberate: a truncated or placeholder value satisfies a
length check while failing
opensslat boot on every instance — the samesilent-downgrade shape one layer down. The curve is pinned to P-256 to match
the KMS key spec (
ECC_NIST_P256/ECDSA_SHA_256).that
=0is present — a script emitting both would have passed.A test that could only skip
TestBootstrap_SignatureDisabledByDefaultopened withand a key is compiled in, so it skipped on every run while counting as
coverage for the disabled path.
sporedSigningPublicKeyPEMis avarpreciselyso a test can exercise that path — so it now sets it, asserts, and restores via
t.Cleanup. Renamed to say what it actually tests.Verified against compiling reverts
REPLACE_MEplaceholder keyBoth build and
go vetclean before failing, so the gates actually ran.Verification
make checkgreen across all 9 nested modules,check-docs, the changelog gate,and
semgrep(0 findings).