Repository navigation
Verify spored on the Windows launch path, and fail closed (#879) - #881
Conversation
The Windows launch bootstrap copied spored-windows-amd64.exe out of S3 and registered it as a SYSTEM service with no checksum or signature check, and carried on when the download failed. GHSA-3x4q-99gh-fxhx covered two such paths; this was a third, and the only one on a live launch path. It now downloads .sha256 and .sig beside the binary from the same source, verifies both, and only then installs. A failing source is skipped; if none verifies, nothing is installed and the console says so. Targets Windows PowerShell 5.1 on Windows 11+, not PowerShell 7: EC2Launch runs user-data with the built-in powershell.exe, and requiring 7 would mean downloading an unverified installer first. The key is embedded as P-256 X/Y coordinates derived from the same SigningKeyPEM Linux uses (.NET Framework has no ImportSubjectPublicKeyInfo), and the DER signature is converted to P1363. Executed in tests rather than string-matched: CI runs pwsh, and a fake aws lets the whole generated install run against signed fixtures and the real v0.128.0 artifact. The rendered <powershell> block is also parse-checked. install-spored.sh is deleted (spawn upgrade-spored is the verified replacement); install-spored.ps1 is regenerated from the same verifier, since Windows has no upgrade-spored yet (#234). Closes #879
…c key (#879) TestWindowsAcceptsEveryDERIntegerShape signed up to 400 times looking for a short (<32-byte) DER integer, which occurs about once per 256; it missed ~4% of the time and CI hit that. Now 5000 tries (~1e-17). gitleaks flagged the spored signing PUBLIC key's coordinates in the generated install-spored.ps1 as generic-api-key. Allowlisted by exact line shape rather than path, verified against two negative controls. The allowlists are now separate tables, because within one table paths and regexes combine with AND.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The previous commit validated the allowlist against gitleaks 8.30.1 locally and moved it to the [[allowlists]] form. CI pins 8.21.2, which does not know [[allowlists]] and so ignored the whole config — including the existing path allowlist, so CI failed with sixteen findings instead of two. In 8.21.2 a single legacy [allowlist] ORs its paths and regexes (later versions AND them), so the line regex goes back into that one table. Verified with the 8.21.2 binary: history clean, and a different secret in the same file and a non-hex value under the same variable name are both still caught. The config records the version sensitivity.
Validated on a real Windows instanceThe last open item. Windows Server 2025 ( Installed and running, verified at boot, read over SSM with Refusals, under the real .NET Framework, using the generated The third row is the one that matters: what someone able to write the bucket would produce, and only the .NET Framework ECDSA path can refuse it. PowerShell 7 in CI could not vouch for that path; this does. Cleaned up and leak-checked. Terminated; the launch-created security group deleted; then independently: root volume CI fixes since opening
Found by this validation, filed separately (none caused by this PR)
|
Closes #879 · advisory GHSA-q59f-6gc3-qj2p (private draft)
The defect
Every Windows
spawn launchran user-data that copiedspored-windows-amd64.exeout of S3 and registered it as a SYSTEM service — no checksum, no signature. The Linux bootstrap has verified both and failed closed since GHSA-3x4q-99gh-fxhx, which described two such paths; this was a third, and the only one on a live launch path. It also carried on when the download failed, leaving a Windows spore with no lifecycle at all.The material was always there: every release publishes the Windows binary's
.sha256and KMS.sig.The fix
The bootstrap now downloads binary,
.sha256and.sigfrom the same source, verifies both, and only then installs. A source that fails is skipped and the next tried; if none verifies, nothing is installed and the console says so.Windows PowerShell 5.1 on Windows 11+, deliberately not PowerShell 7. EC2Launch runs
<powershell>user-data with the built-inpowershell.exe, and PowerShell 7 isn't preinstalled even on Windows 11 — requiring it would mean downloading an unverified installer before verifying spored. Two consequences:ImportSubjectPublicKeyInfobut does haveECDsa.Create(ECParameters). They're derived at generation time from the sameSigningKeyPEMLinux uses, so Linux and Windows can't verify against different keys (TestWindowsKeyIsTheLinuxKey);VerifyHashtakes IEEE P1363r||s, so the script converts.The verifier lives in
pkg/sporedinstall/windows.gobeside the Linux one, and is spliced into the user-data afterSprintfso nothing in the PowerShell can be read as a format verb.Executed, not string-matched
CI can't run Windows PowerShell 5.1, but GitHub's
ubuntu-latestships PowerShell 7, and every API used exists in both. In PowerShell$awscan be a script block, so the test substitutes a fakeawsserving objects from a temp dir and runs the whole generated install — source order, refusal, fallback, fail-closed ending:.sha256, signature from a different key — the bucket-write case.sigmissing.sha256missingSPORED_SIG_VERIFY=0)In CI a missing
pwshfails rather than skips.Five reverts of the PowerShell, each failing as required: signature never checked; checksum mismatch ignored; fail-open install; a naive fixed-width DER converter; a refusal ending the search instead of trying the next source. A sixth — removing the download-time
.sigcheck — correctly passes, becauseTest-SporeBinarythen can't read the absent signature and refuses anyway.Against the real release: the generated verifier, run in
pwshwith the real key, accepts the actual v0.128.0spored.exefrom S3 and refuses a tampered copy.Two gates on the rendered user-data (
cmd/)service installmust be reachable only through a successful verification, must appear once, and the old straight-to-diskaws s3 cp $uri $exemust be gone. Both regressions — an ungated install and the verifier not being spliced — fail it.<powershell>block must parse under PowerShell's own parser. A syntax error in user-data fails nothing in spawn — EC2Launch logs it on the instance — and would leave every Windows spore without spored. An injected stray brace fails it.Rendered user-data is 8.4 KB, under EC2's 16 KB cap (also asserted).
The manual installers
scripts/install-spored.sh— deleted. It installed spored as root with no verification;spawn upgrade-sporedalready does the same job verified.scripts/install-spored.ps1— regenerated, not deleted. Windows has nospawn upgrade-sporedyet (Upgrade spored on a live instance in place (show latest available +spawn upgrade-spored), preserving state #234), so it's the only manual Windows path. It's now produced byWindowsStandaloneScriptfrom the same verifier, andTestInstallSporedPs1IsGeneratedfails on any hand-edit. It parses clean under PowerShell.Five comments that cited the deleted script were rewritten to name the callers that actually parse
spored version(spawn upgrade-spored, the release guard) — that output contract is still load-bearing.Not yet done: a real Windows launch
Everything above runs PowerShell 7 on .NET 10. It does not prove behaviour under Windows PowerShell 5.1 on .NET Framework on a real instance — the one thing CI can't do. I'd like to validate that before merging: a short-lived Windows instance launched with a locally built spawn, confirming spored is verified and installed from the console output, then terminated and leak-checked. That's a billable launch, so it waits for an OK.
🤖 Generated with Claude Code