Skip to content

fix(security): pipeline stage instances install spored through the verified installer (#1173) - #1185

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1173-orchestrator-verified-install
Oct 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1173-orchestrator-verified-install

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Security fix. The pipeline orchestrator Lambda builds the user data for every pipeline stage instance (generatePipelineUserData, called from launchStage). That user data installed spored with its own inline snippet:

  • curl -f -o /usr/local/bin/spored … straight into the destination,
  • then a sha256 fetched from the same bucket, and chmod +x.

It never fetched a .sig or ran openssl dgst -verify. The sha256 proves the download wasn't corrupted. It does not prove the binary is authentic. So anyone who could write to a spawn-binaries-* bucket could run code as root on every pipeline stage instance. This is the class GHSA-3x4q-99gh-fxhx (#819) closed for the other install paths.

The fix:

  • The stage user data now embeds sporedinstall.KeySetupScript() + sporedinstall.VerifiedInstallFunc() and calls spore_install_verified_spored "$BINARY" <bases>, the same as pkg/launcher/bootstrap.go.
  • The four candidate bases are unchanged, in the same order.
  • The installer requires the checksum AND the signature against the key compiled into spawn. It downloads to a temp file and installs nothing on any failure. On any failure the script exits, and the existing EXIT trap writes the FAILED marker and terminates the instance.
  • The installer is passed as a %s argument, not spliced into the fmt.Sprintf format, because the generated shell contains %.

The orchestrator also gets the installer's EL8 curl and SELinux relabel fixes (#1056, #1052, from #1174) for free.

Two smaller defects in the old snippet, moot now:

  • It downloaded straight to /usr/local/bin/spored, so a failed checksum left the unverified binary in place.
  • It compared $(cat spored.sha256) against the bare hash. pkg/sporedinstall takes awk '{print $1}'. If the published .sha256 is in sha256sum format (hash filename), the old comparison could never pass. I have not checked the published format, because that needs an S3 fetch.

Module note. lambda/pipeline-orchestrator has no go.mod. It is part of the root module, not a nested one, so there was no go mod tidy to run. It already imported pkg/aws.

The gate, widened

TestEverySporedDownloaderUsesTheVerifiedInstaller walked only cmd/ and pkg/, so it never saw this file. Its discovery is now discoverSporedDownloaders, which walks every .go file in the repository, including the nested lambda modules and scripts/. It skips only .git, node_modules and vendor, and fails if it finds nothing.

Watched failing on the unmodified orchestrator before the fix. The only finding was:

lambda/pipeline-orchestrator/main.go downloads spored without calling spore_install_verified_spored. …

Two tightenings in the same gate:

  • It now matches an invocation, not the name (CLAUDE.md rule 3). The pattern is ^\s*(if ! )?spore_install_verified_spored ". The old strings.Contains(FuncName) was satisfied by a comment. Tried: the old orchestrator plus a Go comment naming spore_install_verified_spored and sporedinstall.KeySetupScript(). The old check would pass that. The new one fails it.
  • It now requires a sporedinstall.KeySetupScript() call. Without one, SPORED_SIG_VERIFY is unset and the installer silently checks only the sha256. That is the fail-open variant of this exact fix.

TestNoCallSiteSwallowsTheInstallerFailure used a hard-coded list of three files. It now iterates the discovered set, with a floor of 3.

Behaviour tests (orchestrator, executed)

execUserData now runs the verified installer for real:

  • It swaps a fresh P-256 test key into sporedinstall.SigningKeyPEM for the render.
  • The fake bucket serves a real base64-DER signature of the fake spored.
  • Real openssl verifies it.
  • /etc/spawn is rooted in the temp dir, and systemctl is faked.

New tests in verified_install_test.go:

  • TestUserData_InstallsASporedSignedByTheEmbeddedKey: the positive control. It installs and runs spored run-pipeline-stage.
  • TestUserData_RefusesASporedSignedByAnotherKey: the checksum matches but the signer is foreign. spored is never run, FAILED is written, and the instance self-terminates.
  • TestUserData_RefusesAnUnsignedSpored: no .sig at any base. Refused the same way.
  • TestUserData_EmbedsTheSporeHostSigningKey: the production render carries SPORED_SIG_VERIFY=1 and the real key, and stays under the 16 KB user-data cap.

Reverts tried. Both compile (go vet clean) and both fail:

revert fails
orchestrator main.go restored from origin/main foreign-key refusal, unsigned refusal, embeds-key, and the repo-wide gate
KeySetupScript() dropped, only VerifiedInstallFunc() the same four tests, because the install degrades to sha256-only

All existing orchestrator tests pass against the new harness, including the stage-runner end-to-end ones.

Checks

  • GOTOOLCHAIN=go1.26.9 make check: fmt, vet (all GOOS), staticcheck, hermetic tests, the 9 nested modules and tidy all pass. check-build-tags fails with the same file list as unmodified origin/main on this machine (diffed; it's the /private/tmp path issue), so it's local-only.
  • make check-docs: clean, no help text changed.
  • semgrep scan --config=auto --error .: clean.

Deployment and advisory

  • This takes effect only when the pipeline-orchestrator Lambda is redeployed. Lambdas do not upgrade with the CLI, so a spawn release alone leaves the deployed orchestrator generating the unverified install.
  • I did not create a GitHub security advisory. The owner may want one, since this is the same class as GHSA-3x4q-99gh-fxhx and GHSA-q59f.

Not covered

  • No AWS calls. Not run on a real stage instance.
  • The published .sha256 format was not checked (see above).

Fixes #1173

@scttfrdmn scttfrdmn added this to the v0.135.2 milestone Oct 19, 2026
…rified installer (#1173)

The pipeline orchestrator's stage user data installed spored with its own
inline curl straight into /usr/local/bin and a sha256 from the same
bucket, never verifying the signature. It now embeds the signing key and
calls pkg/sporedinstall's fail-closed installer, like every other path.

TestEverySporedDownloaderUsesTheVerifiedInstaller now discovers every .go
file in the repo (it only walked cmd/ and pkg/), matches an invocation of
the installer rather than its name, and requires KeySetupScript so the
install cannot silently degrade to sha256-only.

Fixes #1173
@scttfrdmn
scttfrdmn force-pushed the fix/1173-orchestrator-verified-install branch from 9048bd3 to d601d48 Compare October 19, 2026 07:52
@codecov

codecov Bot commented Oct 19, 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 9e110c9 into main Oct 19, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1173-orchestrator-verified-install branch October 19, 2026 08:10
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.

pipeline-orchestrator installs spored without signature verification, outside the verified-installer gate

1 participant