Skip to content

feat(security): sign spored binaries + verify at boot - #427

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/ws2-spored-signing
Jul 21, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/ws2-spored-signing

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Addresses #440 — the review's #1 security finding. spored's boot-time integrity was a .sha256 fetched from the same S3 bucket as the binary: that detects corruption but can't authenticate the publisher (an attacker who rewrites the bucket rewrites the checksum too). This moves the trust root out of the bucket.

How

  • spawn embeds a spore.host signing public key (pkg/launcher/spored_pubkey.go). The trust root becomes the spawn binary — already trusted via the Homebrew tap / signed GitHub release — not the S3 bucket.
  • Boot verification (pkg/launcher/bootstrap.go): when a key is compiled in, the generated user-data writes it to /etc/spawn, and after the sha256 check downloads a detached .sig and runs openssl dgst -sha256 -verify against the embedded key before executing spored. Fail closed on mismatch or a missing signature. The sha256 stays as a cheap corruption guard.
  • Release signing (.github/workflows/release.yaml): each spored binary is signed with an infra-account KMS asymmetric key (ECDSA_SHA_256 via kms:Sign — the private key never leaves KMS); base64-DER .sig files are published alongside the binary at every path the bootstrap reads.
  • Rollout-safe: gated on repo var SPORED_SIGNING_KEY_ID. Until the key is provisioned, signing is skipped and the bootstrap stays sha256-only with an honest log line (no false "verified" claim) — matching a spawn build with no key compiled in. This is the real fix behind the interim honest wording already merged in SECURITY.md (feat(dashboard-api): move Slack secrets to Secrets Manager #446).

Verification

  • Unit tests: disabled path (SPORED_SIG_VERIFY=0, no key written) + enabled path (embeds key, emits the openssl verify + fail-closed).
  • Crypto round-trip validated locally: a base64-DER ECDSA_SHA_256 signature (exactly KMS's sign --output text format) verifies with openssl dgst -sha256 -verify pub.pem; a tampered binary is rejected. So the bootstrap logic matches KMS output.

⚠️ Gated follow-ups before this is live (need your approval / infra)

  1. Provision the KMS asymmetric signing key in the infra account (966362334030).
  2. Grant the release role kms:Sign on it; set repo var SPORED_SIGNING_KEY_ID.
  3. Embed the real public key in spored_pubkey.go.
  4. Real-AWS boot smoke: launch → confirm the bootstrap verifies the signature and spored starts; negative-test a tampered binary is refused; leak-check + terminate.

Merging this PR is safe before those (signing stays off until the key/var exist). Refs #440.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The review's #1 security finding: spored's boot-time integrity was a same-bucket
sha256 (corruption detection, not publisher authentication). Move the trust root
out of the S3 bucket.

- pkg/launcher/spored_pubkey.go: embedded spore.host signing PUBLIC key (var, for
  rotation/tests) + signatureVerificationEnabled(). Empty until the KMS key is
  provisioned → verification stays off (honest sha256-only), no false claim.
- pkg/launcher/bootstrap.go: when a key is compiled in, the generated bootstrap
  writes it to /etc/spawn and, after the sha256 check, downloads the detached
  .sig and verifies it with  against the embedded
  key BEFORE exec — fail closed on mismatch or missing sig. Trust root = the
  spawn binary (Homebrew/GitHub-release trusted), not the bucket.
- .github/workflows/release.yaml: sign each spored binary with the infra KMS
  asymmetric key (ECDSA_SHA_256, kms:Sign — private key never leaves KMS) and
  publish base64-DER .sig alongside the binary at every path the bootstrap reads.
  Gated on repo var SPORED_SIGNING_KEY_ID; unset → sha256-only (rollout-safe).
- Tests: disabled-path (SPORED_SIG_VERIFY=0, no key written) + enabled-path
  (embeds key, openssl verify, fail-closed). Crypto round-trip validated locally:
  base64-DER ECDSA_SHA_256 sig verifies with openssl; tampered binary rejected.

Flips SECURITY.md's interim honest wording to signature-verified once released
with the key. Refs #440.

GATED FOLLOW-UPS (need approval / infra): provision the KMS key + grant the
release role kms:Sign + set SPORED_SIGNING_KEY_ID + embed the real pubkey; then
a real-AWS boot smoke (verify sig → spored runs; tamper negative).
@scttfrdmn
scttfrdmn force-pushed the feat/ws2-spored-signing branch from cbcaa0c to 10f76ef Compare July 21, 2026 18:15
@scttfrdmn
scttfrdmn merged commit 2f1230d into main Jul 21, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/ws2-spored-signing branch July 21, 2026 18:17
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.

1 participant