Skip to content

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

Closed

Description

@scttfrdmn

The authenticity invariant — spored must be signature-verified before it runs —
is guarded by two tests that cannot fail. Rule 3 from CLAUDE.md, in the most
load-bearing place it could be, and the sixth occurrence in this repo.

The hole

$ grep -n 'SPORED_SIG_VERIFY' pkg/launcher/bootstrap.go
201:SPORED_SIG_VERIFY=1                                  <- the real assignment
208:		script += "\nSPORED_SIG_VERIFY=0\n"              <- the disabled branch
391:# (SPORED_SIG_VERIFY=1), a matching .sig — otherwise we must fall through to the
414:    if [ "${SPORED_SIG_VERIFY:-0}" = "1" ]; then
429:    if [ "${SPORED_SIG_VERIFY:-0}" = "1" ]; then
464:# (SPORED_SIG_VERIFY=1) we download the detached signature and verify it against
467:if [ "${SPORED_SIG_VERIFY:-0}" = "1" ]; then

Lines 391 and 464 are shell comments inside const linuxBootstrapBody, which
bootstrap.go:263 appends unconditionally:

script += linuxBootstrapBody

So the literal string SPORED_SIG_VERIFY=1 is present in every generated
bootstrap, signed or not. And the gate is a bare substring check —
pkg/launcher/bootstrap_test.go:303:

if !strings.Contains(script, "SPORED_SIG_VERIFY=1") {

The compiling revert that escapes

pkg/launcher/spored_pubkey.go:26 — set sporedSigningPublicKeyPEM = "". That
is the documented disable switch, and it is a string-literal edit, so it builds
and vets cleanly.

Result: signatureVerificationEnabled() goes false, bootstrap.go:208 emits
SPORED_SIG_VERIFY=0, and every launch downloads and runs spored with no
signature check
— from the same bucket that serves the sha256, which is the
exact gap #440 closed.

Both gates stay green:

  • TestBuildLinuxBootstrap_SigAwareFallback passes on the comment at :391/:464.
  • TestBootstrap_SignatureEnabled (spored_signing_test.go:46) passes because it
    injects its own TESTKEY and never reads the production value; its five
    other expectations all live in the always-present static body.

No test anywhere asserts that the production key is non-empty.

A related permanently-dead test

TestBootstrap_SignatureDisabledByDefault (spored_signing_test.go:11) asserts
SPORED_SIG_VERIFY=0 when no key is compiled in — but a key is compiled in, so
it skips on every run. It is dead weight counted as coverage for the disabled
path.

Why this one matters more than the other five

This is the invariant behind the project's own authenticity design: no valid
signature → spore tools will not touch the instance. The whole point is that the
binary running as root on every instance is provably ours. A gate that passes
when verification is switched off is the one gate that most needed to be
unfakeable.

Suggested

Two assertions, both anchored:

// the ASSIGNMENT at line start, not the string anywhere
regexp.MustCompile(`(?m)^SPORED_SIG_VERIFY=1$`).MatchString(script)

// and the thing that makes it meaningful
len(strings.TrimSpace(sporedSigningPublicKeyPEM)) > 0

The second is the important half: the first alone still passes if the key is
emptied and someone later moves the assignment into the static body. Add a test
that the compiled-in key parses as a P-256 public key, so a truncated or
placeholder value fails too.

Then delete or invert TestBootstrap_SignatureDisabledByDefault — a test that
can only skip should not exist.

Related: #440 (the gap this was meant to close), CLAUDE.md rule 3 (match the
assignment, not the bare name), and the project's authenticity-key design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions