Skip to content

fix(security): make the spored signature gate able to fail (#813) - #823

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/813-signature-gate
Oct 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/813-signature-gate

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #813

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
the comment satisfied it.

TestBootstrap_SignatureEnabled injects its own TESTKEY and never reads
production's value. And no test asserted the production key existed at all —
the gap that actually mattered.

This is CLAUDE.md rule 3 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 merely
    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 actually tests.

Verified against compiling reverts

revert result
empty key 2 tests fail, including the newly-anchored one — "every launch would download and run spored unverified"
REPLACE_ME placeholder key fails the PEM parse, which a length check would miss

Both build and go vet clean before failing, so the gates actually ran.

Verification

make check green across all 9 nested modules, check-docs, the changelog gate,
and semgrep (0 findings).

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.
@scttfrdmn scttfrdmn added this to the Security audit 2026-10 milestone Oct 11, 2026
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit c9f19ad into main Oct 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/813-signature-gate branch October 11, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The spored signature-verification gate is satisfied by a shell comment: disabling signing passes both tests

1 participant