Skip to content

fix(plugin): require sha256 on every fetch step; add size and arch (#838) - #1557

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/838-pin-plugin-artifacts
Nov 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/838-pin-plugin-artifacts

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #838

What

A plugin signature covers plugin.yaml, but sha256: on a fetch step was optional. A signed, verified spec could therefore download whatever its URL served, and spored ran it as root. The digest a fetch step carries is inside plugin.yaml, so the release manifest and its cosign signature already cover it. manifest.json doesn't change. What was missing was a requirement to set it, plus a way to pin per-architecture artifacts so plugins stop working around fetch with curl in run steps.

  • sha256: required on every remote fetch step. It is enforced in three places:
    • Validate, used by spawn plugin validate, by spawn plugin install before any local step, and by spored's push API.
    • plugin.CheckArtifactPins, which spored runs in InstallWithProvenance before any step. That covers launch-time declarations, which skip Validate.
    • RemoteExecutor.fetch, which refuses an unpinned step before making a request.
  • size: (optional): the exact byte length. spored reads at most one byte past it, and on any other length it deletes the file and fails.
  • arch: (optional): x86_64/amd64 or arm64/aarch64. The fetch runs only on that architecture, so a spec can pin a different artifact, with its own sha256, per architecture.
  • spawn plugin inspect shows arch, size and the sha256 prefix, and shows an unpinned fetch as REFUSED — no sha256.

Compatibility policy: refuse, no warning release

An unpinned fetch is refused for every source: official, github: and local. --insecure does not bypass it. I chose this over warn-then-refuse because a warning release keeps the hole open and protects no one. Measured 2026-11-08: none of the 12 tagged releases in spore-host/spore-plugins has a fetch step at all, so no official install breaks. Third-party and local specs with an unpinned fetch do break. validate names each step, and the fix is to add sha256:. The CHANGELOG states this under Security.

Third-party (github:) specs are held to the same rule, which settles #838's open question 3. The author's pin doesn't make the author trustworthy, but it does stop the URL's content changing underneath a spec someone reviewed. It also keeps spored's rule one rule, independent of where the spec came from.

Not covered (stated in the CHANGELOG)

A download inside a run step (curl … | sh, pip install) is opaque to spawn. spore-plugins now has CI that fails new ones and lists the ten plugins that still do this (spore-host/spore-plugins#33).

Release order

  1. fix(mountpoint-s3): verify the .deb; pin every artifact by sha256 + CI gate (#31) spore-plugins#34 first. It moves mountpoint-s3 to four pinned fetch steps (sha256 + size + arch). It validates and runs on the current spawn: an older spawn ignores arch:/size: and fetches all four, each still sha256-checked by spored ≥ v0.86.0. Merge it, then push the tag mountpoint-s3-v1.0.1 so the release workflow signs it.
  2. Then this PR, in the next spawn release (MINOR: it refuses specs that used to be accepted).

Strictly, neither order breaks an official install, because no tagged plugin has a fetch step. The order above makes sure the first spawn that enforces pins already has a pinned mountpoint-s3 to resolve as latest.

Tests

  • pkg/pluginruntime:
    • A tampered artifact is refused: the file is deleted, and the next step never runs.
    • An unpinned fetch is refused before any step, even one that comes before it, and the reason is recorded in state.
    • A good artifact is accepted.
    • Exact, short and long sizes.
    • arch: selects the right artifact on amd64 and on arm64.
  • pkg/plugin: a pin-problem table run through both Validate and CheckArtifactPins, every remote section, and StepRunsOnArch.
  • cmd: inspect output.
  • The step-schema gate (TestValidatorAcceptsExactlyWhatTheExecutorsRun) now builds a "bare" fetch with its required sha256, and covers size/arch.
  • Each new runtime and validator test was watched failing against a revert that compiles (the guard && false): the unpinned refusal, the arch filter, the install-time check, the size check, the hash check, and the Validate wiring.

Local runs:

  • make check (GOTOOLCHAIN=go1.27.3, AWS env stripped): gofmt, vet ×3 GOOS, staticcheck, golangci-lint and the hermetic short tests all pass. Two later steps failed locally only because the clone's path contains a space (/Volumes/External HD): lambda/dashboard-api TestSetupAllRunsEveryStepFromAnyDirectory and check-build-tags. Neither touches these files, and CI on Linux is authoritative.
  • semgrep scan --config=auto --error .: clean.
  • spawn plugin validate --strict on every spore-plugins spec (main and the spawn launch fails with "failed to parse JSON" when stdin is a pipe (non-interactive) #34 branch): passes with this build and with v0.161.0.

@scttfrdmn scttfrdmn added this to the Hardening milestone Nov 8, 2026
@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.58974% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pluginruntime/remote_executor.go 82.14% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

scttfrdmn commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Live EC2 verification: PASS, all 5 cases (spore-host-dev 435415984226, us-east-1, 2026-11-08)

Build and method.

  • CLI built from this PR's head dba6fb6 (0.161.1-0.20261108212917-dba6fb618764).
  • spored built from the same head with GOOS=linux GOARCH=arm64, sha256 26eb01d3…bc6f6600.
  • spawn launch live1557 --instance-type c7g.medium --ttl 1h --region us-east-1 --s3-read <scratch bucket> → i-0188e697c28d22c4e (AL2023, aarch64), launched 22:41:09Z.
  • The bootstrap installed the published spored 0.161.0. I swapped the branch spored in over SSM, using the same method as fix(spored): charge --cost-limit on Spot instances at the Spot price (#1497) #1555: a presigned GET from a scratch bucket I own in the dev account → sha256sum -c OK → atomic mv → systemctl restart spored. spored version then reported 0.161.1-0.20261108212917-dba6fb618764. Nothing was written to the infra spawn-binaries buckets.
  • Every install below went through the branch spored.
# case result
1 signed official plugin installs, only this arch fetched, hashes verified PASS
2 tampered artifact refused, file deleted, next step not run PASS (sha256, and size too)
3 unpinned fetch refused before any step: validate, install, push API, launch-time declaration PASS (all four paths)
4 --insecure does not bypass the pin check PASS
5 regression: registry plugin with no fetch steps PASS (docker)

1. spawn plugin install mountpoint-s3 --config bucket=<scratch>

Installing mountpoint-s3 v1.0.1 on i-0188e697c28d22c4e...
  pinned to commit 6de86bd37e8425e255bd18cb9fa32c27f4780556 (sha256 277a52ed59ae)
  signature verified (official release)
...
Plugin mountpoint-s3 installed on i-0188e697c28d22c4e.
  • The bare name resolved to the signed release mountpoint-s3-v1.0.1. That tag is commit 6de86bd, which is also spore-plugins main. spawn plugin inspect shows each fetch as (x86_64 only | arm64 only, sha256 …, N bytes).
  • spored log: both x86_64 steps were skipped, and both arm64 steps (.rpm and .deb) were fetched. The install step then picked the .rpm (dnf):
    22:42:21 Plugin fetch https://s3.amazonaws.com/mountpoint-s3-release/1.19.0/x86_64/mount-s3-1.19.0-x86_64.rpm: skipped (arch x86_64; this instance is arm64)
    22:42:21 Plugin fetch https://s3.amazonaws.com/mountpoint-s3-release/1.19.0/x86_64/mount-s3-1.19.0-x86_64.deb: skipped (arch x86_64; this instance is arm64)
    22:42:42 Plugin mountpoint-s3: configure / start / running
    
  • A successful verify logs nothing; the install only gets past the fetch steps if the size and sha256 match. As an independent cross-check, I re-downloaded both arm64 artifacts on the instance:
    • .rpm: d3e814c2…ec283118, 13260240 bytes;
    • .deb: 6e4e9203…e4e8e524, 11956986 bytes.
      Both are byte-identical to the spec's sha256:/size: pins.
  • On the instance:
    • rpm -q mount-s3 → mount-s3-1.19.0-1.aarch64;
    • mount-s3 --version → mount-s3 1.19.0;
    • mountpoint-s3.service is active, /mnt/s3 is a mountpoint, and cat /mnt/s3/hello.txt returns the object;
    • the staging dir /opt/spore-plugins/mountpoint-s3 was removed as designed.

2. Tampered artifact

Test file: https://s3.amazonaws.com/mountpoint-s3-release/1.19.0/arm64/mount-s3-1.19.0-arm64.rpm.asc (490 bytes, real sha256 99e2e6fb…bdefddc0).

The spec has three remote steps:

  • install[0]: a run step that writes a STEP1_BEFORE_FETCH_RAN marker;
  • install[1]: the fetch, with sha256 …ddc1 (last nibble flipped);
  • install[2]: a run step that writes STEP3_AFTER_FETCH_RAN.

Plus a configure step that writes CONFIGURE_RAN. spawn plugin validate accepts it (well-formed pin). Then:

plugin live1557-tampered failed on i-0188e697c28d22c4e: install: step[1] type=fetch: fetch https://s3.amazonaws.com/mountpoint-s3-release/1.19.0/arm64/mount-s3-1.19.0-arm64.rpm.asc: sha256 mismatch (want 99e2e6fbbcef7c0f13dff250837e1033ce801d08c97c62cb3d08f397bdefddc1, got 99e2e6fbbcef7c0f13dff250837e1033ce801d08c97c62cb3d08f397bdefddc0)

State on the instance afterwards. Only the pre-fetch marker exists: no sig.asc (deleted), no STEP3_AFTER_FETCH_RAN, no CONFIGURE_RAN. spawn plugin list shows live1557-tampered failed.

/opt/live1557/live1557-tampered
-rw-r--r--. 1 root root 21 22:44:08 STEP1_BEFORE_FETCH_RAN
  • Size pin, same shape (correct sha256, size: 491): size mismatch (want 491 bytes, got 490). Same state: only STEP1_BEFORE_FETCH_RAN, and no file left behind.
  • Positive control (correct sha256, size: 490): installs, running. All four markers are present, and sig.asc is kept with sha256 99e2e6fb…bdefddc0. So the refusals above are the pin check, not the spec harness.

3. Unpinned fetch (the same spec with no sha256:, plus a local provision step that would write a marker on the controller)

  • spawn plugin validate, rc=1:
    ✗ specs/live1557-unpinned/plugin.yaml
        remote.install[1]: fetch of https://s3.amazonaws.com/mountpoint-s3-release/1.19.0/arm64/mount-s3-1.19.0-arm64.rpm.asc has no sha256 — every downloaded artifact must be pinned (sha256sum the exact file and add sha256: <digest>)
    
  • spawn plugin install ./…/plugin.yaml --instance …: rc=1, plugin live1557-unpinned failed validation: remote.install[1]: … has no sha256 ….
    • The controller marker LOCAL_STEP_RAN was never created, so no local step ran.
    • Nothing was created on the instance.
    • --dry-run prints the step as (REFUSED — no sha256) under "⚠ Validation problems".
  • spored push API, bypassing the CLI. Over SSM, curl POST of the spec to 127.0.0.1:7777/v1/plugins/install (and /preflight) with the push token:
    HTTP 400  bad request: spec failed validation        (install and preflight)
    22:44:45 install validate spec error for live1557-unpinned: remote.install[1]: fetch of … has no sha256 — every downloaded artifact must be pinned …
    
    No state was recorded and /opt/live1557/live1557-unpinned was never created.
  • Launch-time declaration path, which skips Validate and so exercises the new CheckArtifactPins in InstallWithProvenance. I wrote /etc/spawn/plugins.json = [{"ref":"/opt/live1557/push/plugin.yaml"}] and restarted spored:
    22:45:08 Plugin runtime: loading 1 declared plugin(s)
    22:45:08 Plugin live1557-unpinned: install failed: plugin live1557-unpinned: plugin downloads an artifact it does not pin by sha256: remote.install[1]: fetch of … has no sha256 — …
    
    spawn plugin status live1557-unpinned → Status: failed with the same error. /opt/live1557/live1557-unpinned was never created, so not even install[0] (the run step before the fetch) ran. The declaration file was removed afterwards.

4. --insecure

  • Unpinned + --insecure: the same refusal, failed validation: remote.install[1]: … has no sha256 …, rc=1, and no local step ran.
  • Tampered + --insecure (marker dir cleared first): the same sha256 mismatch (want …ddc1, got …ddc0), rc=1. Again only STEP1_BEFORE_FETCH_RAN (22:45:31), and no sig.asc.

5. Regression: spawn plugin install docker (official, no fetch steps)

Installing docker v1.0.0 on i-0188e697c28d22c4e...
  pinned to commit 3014c5b1e0e3f878f8f2c9064054591b38bb0b51 (sha256 0dd4aae00264)
  signature verified (official release)
...
Plugin docker installed on i-0188e697c28d22c4e.

docker.service is active, docker info reports 25.0.18 aarch64, and the login user is in the docker group. spawn plugin list shows docker v1.0.0 running.

Side observation (not this PR, pre-existing): filed as #1559

Each systemctl restart spored runs Cleanup → StopAll. That marks every push-installed plugin stopped and ends its health loop, and on start spored only re-processes /etc/spawn/plugins.json declarations. So after my restart, mountpoint-s3 showed stopped while mountpoint-s3.service was still active and /mnt/s3 still served reads. The same happens on any in-place spored upgrade (#234).

Teardown and leak check (us-east-1, us-west-2)

  • spawn terminate i-0188e697c28d22c4e --yes at 22:47:02Z → terminated. Scratch bucket deleted (HeadBucket 404).
  • No pending, running, stopping, stopped or shutting-down instances in either region.
  • No unattached volumes, no unassociated EIPs, and no open or active Spot requests.
  • Security groups and key pairs are unchanged from the pre-run baseline: default SGs only; us-east-1 keys spawn-key-scttfrdmn-rsa, spawn-key-scttfrdmn, plugin-e2e-test; us-west-2 key spawn-key-scttfrdmn.
  • The spawn-managed role spawn-instance-7c33c24a (created for --s3-read) remains. spawn cleanup --instance-roles or the reaper removes it after the 24 h guard.

Cost: one c7g.medium on-demand for 5 min 54 s (22:41:09–22:47:03Z), ≈ 0.10 instance-hours, ≈ $0.004.

…t by arch (#838)

The release signature covers plugin.yaml, but sha256: on a fetch step was
optional, so a signed spec could download an unverified artifact and spored
would run it as root. Every remote fetch must now pin its download:

- Validate and CheckArtifactPins refuse a fetch with no (or a malformed)
  sha256, a negative size or an unknown arch. spored checks the whole spec
  before any install step runs, on every path (push API and launch-time
  declarations), and fetch() itself refuses an unpinned step before a byte
  is requested.
- New optional size: (exact byte length, read at most one byte past it) and
  arch: (x86_64|arm64, aliases amd64|aarch64) on fetch steps, so a spec can
  pin a different artifact per architecture instead of curling in a run step.
- spawn plugin inspect shows arch, size and the sha256, and marks an
  unpinned fetch REFUSED.

Compatibility: refused, no warning period. No tagged spore-plugins release
has a fetch step, so no official install breaks.
@scttfrdmn
scttfrdmn force-pushed the fix/838-pin-plugin-artifacts branch from dba6fb6 to 5bb602b Compare November 8, 2026 22:50
@scttfrdmn
scttfrdmn merged commit 3fbea4d into main Nov 8, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/838-pin-plugin-artifacts branch November 8, 2026 23:14
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.

Plugin signatures cover plugin.yaml but not the artifacts it downloads and runs

1 participant