Skip to content

fix(bootstrap): install the pinned AWS CLI from the regional spawn-binaries mirror first (#1494) - #1503

Merged
scttfrdmn merged 4 commits into
mainfrom
fix/1494-awscli-regional-mirror
Nov 2, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
fix/1494-awscli-regional-mirror

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1494

What

An Ubuntu instance in a private subnet (only VPC endpoints, the --no-public-ip case) cannot reach awscli.amazonaws.com, so since #1490 its bootstrap fails closed installing the pinned AWS CLI. This PR has the release mirror the two pinned zips into every spawn-binaries-<region> bucket, and has the bootstrap try that mirror first.

Design

  • Bootstrap (pkg/launcher/bootstrap.go). spawn_need_aws REGION tries https://spawn-binaries-$region.s3.$region.amazonaws.com/spawn/awscli/awscli-exe-linux-<arch>-<version>.zip first. That is the regional S3 name (bootstrap: fetch spored from the regional S3 name so an S3 interface endpoint serves a private-only instance #1436), which gateway and interface endpoints both serve. It then tries https://awscli.amazonaws.com/.... Each source's bytes must match the pinned sha256 before anything is unpacked. A mirror zip that fails the check is reported (AWS CLI zip from <url>: sha256 mismatch) and the origin is tried. The two callers pass the region they already have: "$REGION" in the body, and "$SPAWN_ST_REGION" (the launch-region staging bucket) in the staged-files fetch, which runs before the body reads $REGION.
  • Path: spawn/awscli/, not a new top-level awscli/. Instances already read spawn/... anonymously. The file name is AWS's own, so only the base URL differs between the two sources.
  • One source of truth: launcher.AWSCLIPins() (exported, so api/public-surface.txt is regenerated) and a hidden spawn awscli-pin print <arch> <version> <sha256> <mirror key>. The release mirrors exactly what the tagged build fetches.
  • Release (scripts/mirror-awscli.sh, two new steps in release.yaml, after the versioned-spored verify and before GoReleaser).
    • publish imports scripts/awsclipin/aws-cli-team.asc into a throwaway GNUPGHOME and requires exactly one primary key, FB5DB77FD5C118B80511ADA8A6310ACC4672475C.
    • For each pin, it downloads the zip and its .sig from awscli.amazonaws.com, requires gpg --verify to pass, requires a VALIDSIG whose primary fingerprint is the pinned one, and requires the pinned sha256. Only then does it upload, to all buckets in SPAWN_BINARY_BUCKETS.
    • The key file is byte-identical to the one feat(ci): weekly workflow moves the bootstrap's pinned AWS CLI by PR (#1495) #1501 adds at the same path, so whichever PR merges second sees a clean add/add. The verification logic mirrors feat(ci): weekly workflow moves the bootstrap's pinned AWS CLI by PR (#1495) #1501's bump-awscli-pin.sh.
    • verify fetches every copy over anonymous HTTPS at the regional name, the way an instance does, and requires the pinned sha256 and the bytes publish verified. So it also proves the bucket policy serves spawn/awscli/ publicly.
  • Deleter: publish keeps, per bucket, the pinned version and the two newest other versions under spawn/awscli/, and aws s3 rms older ones. Keys not of the mirror's own name form are never touched.
  • --no-public-ip pre-flight (pkg/aws/private_network.go): it already requires an S3 endpoint and refuses regions with no bucket, so no new check is needed. Only the S3 reason text now mentions the AWS CLI.

Before tagging v0.156.0: IAM on the hand-managed release role (not verifiable here)

GitHubActions-spore-host-release (inline SpawnBinariesS3Upload) allowed only specific keys at v0.143.0. The mirror step needs:

  • s3:PutObject and s3:DeleteObject on arn:aws:s3:::spawn-binaries-*/spawn/awscli/*
  • s3:ListBucket on arn:aws:s3:::spawn-binaries-* with s3:prefix spawn/awscli/*

Without them the release stops at the mirror step, before GoReleaser, so nothing broken is published. The bucket policy must also allow anonymous GetObject under spawn/awscli/; the verify step fails if it does not.

Bootstrap body

  • Body sha256 changes from 63421a2d…3d23 (v0.155.0) to 73d1876b92ed94d9ae07904ff70dd7b3d736ef635321d01609dc79e72b04c049, so deploy the sweep orchestrator from the release.
  • Published body: 23501 → 23665 bytes raw.
  • Inline bare bootstrap: 7954 → 7991 gzipped. The budget is 9088, so 1097 bytes of headroom remain, above the 1024 margin.
  • Stub: 1841 → 1842 gzipped, against a budget of 3072.

Gates and revert evidence

Every revert below kept go vet clean, and the named gate failed against it:

Gate Revert Failure
TestAWSCLIMirrorTriedFirstAndShaChecked (boot sandbox, 7 cases) origin listed before mirror mirror … fetched 0 times, want 1, awscli.amazonaws.com was fetched 1 times, want 0
same mirror bytes exempt from the sha check installed "evil\n", want "good\n", a zip that is not the pinned one was unpacked and installed, bad-mirror cases exit 0
TestEverySpawnNeedAWSCallNamesItsRegion (discovers calls in all rendered bootstraps) staged-files call without "$SPAWN_ST_REGION" spawn_need_aws called with 0 args in 4 staged variants
TestReleaseMirrorRefusesAnUnverifiedAWSCLI (runs the real step, real gpg, throwaway key) gpg verify replaced by a fake VALIDSIG signed by another key: the mirror step succeeded
same one-primary-key check disabled key file holds a second key: succeeded
same sha256 check disabled validly signed but not the pinned sha256: succeeded
TestReleaseMirrorRequiresThePinnedSigner (rule 2: disables the key-count check in the sandbox copy, signs with a second imported key) VALIDSIG fingerprint test dropped (&& $NF == fpr removed) a zip signed by a key other than the pinned one was mirrored
TestReleaseMirrorsExactlyThePinnedAWSCLI (buckets from sporedinstall.PublishedRegions(); a newer 2.99.0 zip at the origin must not be mirrored) upload to awscli/ instead every bucket holds []
same also upload the .sig holds [… .sig …], want exactly the pinned
same skip the first bucket spawn-binaries-us-east-1 holds []
TestReleaseMirrorDeletesOldVersions KEEP=100 wrong kept set
same foreign keys treated as prunable wrong kept set
TestReleaseMirrorVerifyCatchesABadCopy verify content check removed altered: verify passed
same a missing copy not counted missing: verify passed
TestReleaseMirrorsTheAWSCLIBeforeTheCLI both steps moved after GoReleaser mirror 13, verify 14, GoReleaser 10
TestMirrorScriptPinsTheAWSCLITeamKey one fingerprint hex digit changed pins FB5DB77E…, want … FB5DB77F…
TestAWSCLIPinCommandPrintsThePins prints only the first pin printed 1 lines for 2 pins

gpg tests use a GNUPGHOME under /tmp and gpgconf --kill all on cleanup; the script's own trap does the same. They skip without gpg or on Windows.

Checks

These pass:

  • make check, from /private/tmp.
  • make lint: 0 issues in all 10 modules.
  • semgrep scan --config=auto --error .: rc 0.
  • actionlint: release.yaml is clean. The only finding repo-wide is the existing SC2001 at ci.yml:98, which is also on main.
  • shellcheck scripts/mirror-awscli.sh
  • make check-docs: the new command is hidden, so there is no docs drift.

Not verified here

There were no AWS calls. Still unverified: the release role's permissions, anonymous read of spawn/awscli/, and a real Ubuntu --no-public-ip launch.

@scttfrdmn scttfrdmn added this to the v0.156.0 milestone Nov 2, 2026
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/awscli_pin.go 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Release-role IAM applied (2026-11-02, owner-approved). GitHubActions-spore-host-release (infra 966362334030) gained a separate inline policy, AWSCLIMirror:

  • s3:PutObject and s3:DeleteObject on arn:aws:s3:::spawn-binaries-*/spawn/awscli/*
  • s3:ListBucket on spawn-binaries-*, conditioned on s3:prefix spawn/awscli/* or spawn/awscli/

The real PutRolePolicy succeeded. The existing SpawnBinariesS3Upload and spored-signing-kms-sign are byte-unchanged.

Simulated (custom policy and the live role):

  • allowed: put and delete under spawn/awscli/, and list with that prefix;
  • implicitDeny: delete of released spored, put of spored via this policy, other buckets, list of spawn/ or mpi-keys/, PutBucketPolicy.

Bucket policy: all 11 spawn-binaries-* buckets already allow anonymous s3:GetObject on spawn/*, so the mirror path needs no bucket change.

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live-verified on EC2 (2026-11-02) with a CLI built from c903c956, in account 942542972736, us-east-1.

Mirror: published to spawn-binaries-us-east-1 with scripts/mirror-awscli.sh publish. Both zips were signature-verified against FB5D…475C and sha-matched to the pins; verify re-read them anonymously, and both URLs return 200.

Test: a throwaway VPC (10.198.0.0/16) with no IGW and no NAT. The route table held only the local route plus the S3 prefix list via a gateway endpoint, with ec2/ssm/ssmmessages/ec2messages interface endpoints. Ubuntu 24.04 arm64 t4g.small, with --no-public-ip. The pre-flight passed on all 5 endpoints.

Result: PASS.

  • awscli.amazonaws.com timed out (no internet path), yet spawn: no aws CLI; installing AWS CLI 2.39.3 succeeded: aws-cli/2.39.3 … exe/aarch64.ubuntu.24 at /usr/local/bin/aws. That is only possible from the regional mirror, which returned 200 through the gateway endpoint.
  • Hostname mirror1494; the MOTD shows the instance ID, TTL 1h and On Complete: terminate.
  • SPAWN_COMPLETE completed/0/command. /tmp/spawn-awscli was removed.
  • Terminated via on-complete.

Teardown: the VPC, endpoints, SG, route table and subnet were deleted. The leak check is clean (only the owner's and a concurrent EFA test's instances remain); cost under $0.05.

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.

bootstrap: Ubuntu in a private subnet cannot install the AWS CLI (awscli.amazonaws.com unreachable), so it now fails closed

1 participant