Skip to content

fix(mpi): --efa installs a pinned, sha256-checked EFA installer, signature-verified at pin time and release; refuses AL2 (#1505, #1504) - #1508

Merged
scttfrdmn merged 5 commits into
mainfrom
fix/1505-efa-installer-pin
Nov 2, 2026
Merged

scttfrdmn merged 5 commits into
mainfrom
fix/1505-efa-installer-pin

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1505
Fixes #1504

Stacked on #1506. This branch carries #1506's two commits, rebased onto main (4cf785e6, a976d823). Both PRs change the same EFA block in pkg/userdata/mpi.go, and #1506's behaviour is kept: with --efa the job uses the installer's /opt/amazon/openmpi, and the run fails closed if that is missing. Merge #1506 first, then rebase this branch, which drops those two commits. Do not merge #1506 with --delete-branch while this PR targets main. It doesn't need to: it targets main.

What

--efa used to download aws-efa-installer-latest.tar.gz and run efa_installer.sh as root with no integrity check, and it left the tarball in /tmp. Now:

  • Pin (pkg/userdata/efa.go, the one Go source of truth). efaInstallerVersion = "1.51.0" (current latest; latest has the same ETag) and efaInstallerSHA256 = "83993044…2465c".

  • User data (the EFA block in mpi.go).

    1. On AL2 (/etc/os-release ID=amzn, VERSION_ID=2), refuse before downloading anything (--efa on an Amazon Linux 2 --ami fails: the EFA installer dropped AL2 in 1.50.0 and spawn fetches aws-efa-installer-latest #1504).
    2. In /tmp/spawn-efa, try https://spawn-binaries-<region>.s3.<region>.amazonaws.com/spawn/efa/aws-efa-installer-1.51.0.tar.gz first (only in sporedinstall.PublishedRegions()), then https://efa-installer.amazonaws.com/aws-efa-installer-1.51.0.tar.gz. Each source's bytes must have the pinned sha256 before anything is unpacked.
    3. Unpack, delete the tarball, and run ./efa_installer.sh -y -g.
    4. rm -rf /tmp/spawn-efa, whether the installer succeeds or fails.
    5. Exit with the installer's status if it failed.

    Every failure goes through the --mpi on an AL2 --ami dies at the jq hostfile step (jq not installed); no SPAWN_COMPLETE, so the cohort bills until TTL #1483 trap: an mpi-bootstrap record plus a reason in /var/log/spawn-command.log. No sha256 match at all gives spawn: no EFA installer 1.51.0 with the pinned sha256.

  • Signature, at pin time and at release, never on the instance (as bootstrap: nothing moves the pinned AWS CLI version/sha256 the Linux bootstrap installs #1495/fix(bootstrap): install the pinned AWS CLI from the regional spawn-binaries mirror first (#1494) #1503 do for the AWS CLI). scripts/efa-pin.sh imports scripts/efapin/aws-efa-installer.key into a throwaway GNUPGHOME. It requires exactly one primary key, 4E9091BCBB97A96B26B15E59A05480B1DD2D3CCC, and fails if that key ever gets an expiry within 60 days. It downloads the tarball and its .sig, requires a gpg VALIDSIG whose primary fingerprint is the pinned one, and only then hashes the tarball.

    • verify: a new release step, "Verify the pinned EFA installer". It runs right after the release version guard, before any AWS credentials or GoReleaser, needs no credentials, and requires the pinned sha256.
    • bump [--version V]: the newest 1.N.N in AWS's EFA release-notes table. It skips a version whose tarball is not published yet. Otherwise it rewrites the two constants via go/parser and adds a CHANGELOG entry.
  • Bump automation. .github/workflows/efa-pin.yml is a weekly sibling of awscli-pin.yml: GITHUB_TOKEN only, contents/pull-requests/issues: write on its one job. It opens a PR, or, only on GitHub's "not permitted to create or approve pull requests", it opens or updates an issue "EFA installer pin bump available: → " with the compare link.

  • Shared code. scripts/internal/pinkit holds the go/parser const rewrite, the CHANGELOG Unreleased/Changed insertion, the PR-refusal match, and the PGP v4 fingerprint (pgp.go moved from scripts/awsclipin, unchanged). scripts/awsclipin now calls it; its behaviour and its tests are unchanged and pass.

Key

AL2 decision (#1504)

I chose to refuse, not pin 1.49.0 for AL2. One pin, one key, one bump. The installer itself already exits 1 on AL2, but only after a 591 MiB download, and its message lands only in cloud-init's log. The check runs at the instance because spawn does not know the OS of an arbitrary --ami at launch. I checked the condition against the real /etc/os-release in amazonlinux:2 (refused) and ubuntu:24.04 and 22.04 (allowed). AL2023's VERSION_ID is 2023.

Mirror: instance side here, release publishing is follow-up #1507 (needs IAM)

The user data already tries spawn/efa/ first and sha-checks it. Nothing publishes it yet, so today that fetch fails fast (an anonymous GET of a missing key returns 403, and curl does not retry 4xx), and the origin serves the tarball. --no-public-ip with --efa therefore still needs NAT, and noPublicIPInternetNeeds is unchanged. Publishing needs a prefix the release role does not have, so I stopped there. The exact policy is in #1507:

  • s3:PutObject, s3:DeleteObject on arn:aws:s3:::spawn-binaries-*/spawn/efa/*
  • s3:ListBucket on arn:aws:s3:::spawn-binaries-* with StringLike s3:prefix spawn/efa/*
  • anonymous s3:GetObject under spawn/efa/ in each bucket policy (not checked)

It also builds on #1503 (still open). Cost: 591 MiB × 11 regions ≈ 6.5 GiB per version.

IAM in this PR: none. The verify step has no credentials, and the weekly workflow uses GITHUB_TOKEN only.

Sizes

  • MPI user data, rank 0 with --mpi-command, --efa: 9381 → 10200 bytes raw, 4074 → 4381 gzipped (+307).
  • Without --efa: unchanged, 9210 / 3989.
  • The combined user data is gzipped (encodeUserData), so it stays well under 16 KiB.
  • pkg/launcher is untouched, so the published bootstrap body does not change and no orchestrator redeploy is needed for this.
  • The release now downloads the 591 MiB tarball once. It took about 6 s locally.

Gates (every revert below kept go vet clean, and the named gate ran and failed)

Gate Revert Failure
TestEFAInstallerNotThePinnedOneIsNeverUnpackedOrRun (4 cases: tampered at both sources, tampered at origin with no mirror, truncated, served nowhere) sha comparison made tautological an EFA installer ran from a tarball that is not the pinned one: "TAMPERED"
TestEFAMirrorIsTriedFirstAndStillSHAChecked (mirror has it / lacks it / altered / unpublished region) origin before mirror fetched [origin], want [mirror …]
same, plus the first gate mirror bytes exempt from the sha check TAMPERED ran; rank 0 exited 1
TestEFAInstallerLeavesNothingInTmp (success, and an installer exiting 3) rm -rf /tmp/spawn-efa dropped left under /tmp …: ["/tmp/spawn-efa" "/tmp/spawn-efa/aws-efa-installer"]
TestEFARefusedOnAmazonLinux2 if false && (…) rank 0 exited 0, want 1, fetched both URLs, the installer ran
TestEFAPinIsTheGoSourceOfTruth template sha not from efa.go comparisons … = 0000…, want … 8399…
same origin URL back to -latest sources mismatch, still names … aws-efa-installer-latest
TestVerifyRefusesAnythingButThePinnedSignedTarball (efa-pin.sh, real gpg, throwaway keys, file:// origin) gpg verify bypassed verify exited 0, want success=false
same release sha compare dropped verify exited 0
same one-primary-key check dropped verify exited 0 (key file holds a second key)
TestVerifyRequiresThePinnedSigner (rule 2: the key-count check is disabled in the sandbox copy) && $NF == fpr dropped a tarball signed by a key other than the pinned one verified
TestBumpPinsOnlyASignedNewerTarball gpg verify bypassed bump succeeded, efapin set ran for a tarball that is not validly signed
TestPinScriptPinsTheSameFingerprint one hex digit in EFA_KEY_FPR pins …3CCD, want … 3CCC
TestCommittedKeyIsAWSsEFAInstallerKey (fingerprint computed from the key file, against the value written out from AWS's page) KeyFingerprint digit changed KeyFingerprint = …3CCD
TestPinConstantsExistInEFAGo / TestBumpCoversEveryEFAPin (discovers pins in pkg/userdata) const renamed no const efaInstallerSHA256 / looks like an EFA installer pin the bump does not move
TestReleaseVerifiesThePinnedEFAInstallerFirst step neutralised (echo …) 0 steps run scripts/efa-pin.sh verify
same continue-on-error: true must always run and fail the release
same moved after GoReleaser EFA verify is step 11, GoReleaser 10, and after the AWS credentials step 5
TestEFAPinWorkflowRunsTheBumpWithOnlyPRPermissions fallback without pr-refused opens an issue without first checking efapin pr-refused
same extra actions: write permissions = …, want exactly …

The sandbox tests run the whole rendered member scripts, rank 0 plus 2 peers, with real tar and sha256sum on real gzipped tarballs. Only curl's bytes are stand-ins, and the pinned sha is swapped for the stand-in's through efaPinnedSHA256, which TestEFAPinIsTheGoSourceOfTruth holds to the constant. #1506's three gates pass unchanged in intent; their stubs now serve a real tarball instead of faking tar.

Checks

These pass:

  • make check, from /private/tmp.
  • make lint: 0 issues in all modules.
  • semgrep scan --config=auto --error .: 0 findings.
  • actionlint: only the existing ci.yml:98 SC2001, which is also on main.
  • shellcheck scripts/efa-pin.sh
  • gitleaks: no leaks.
  • go build .

No help text changed. There were no AWS calls.

Live check (2-node EFA pair, branch-built CLI)

  1. Build: GOTOOLCHAIN=go1.27.3 go build -o ~/.xtmp/spawn-1505 . from this branch. A dev build inlines the bootstrap, so no published body is involved.
  2. Launch a 2-member --mpi --efa cohort on an EFA-capable type (e.g. c5n.18xlarge/hpc7g), default AL2023 AMI, with a TTL and --on-complete terminate. Use --mpi-command 'fi_info -p efa && mpirun … hostname' or an osu osu_latency if available.
  3. On each member, check:
    • /var/log/spawn-command.log and cloud-init output show Installing EFA installer 1.51.0....
    • In us-east-1, the mirror fetch failed (403) and the origin served it. Expect no sha256 mismatch line for the origin.
    • ls /tmp/spawn-efa /tmp/aws-efa-installer* 2>&1: absent.
    • /opt/amazon/openmpi/bin/mpirun exists and is the one on PATH (fix(mpi): --efa runs the EFA installer's Open MPI under /opt/amazon/openmpi (#1491) #1506).
    • fi_info -p efa lists the device.
    • The completion record is completed from mpi.
  4. Optional negative check, single member, so it costs one short instance: an Ubuntu 24.04 --ami with --efa should install normally. An AL2 --ami with --efa should fail fast with spawn: --efa needs AL2023 or Ubuntu… and an mpi-bootstrap record, with no download in the log.
  5. Reap, then independently verify that no instances or volumes are left.

@scttfrdmn scttfrdmn added this to the v0.156.0 milestone Nov 2, 2026
@scttfrdmn scttfrdmn added area:mpi MPI / EFA / placement groups / HPC type:security Security-relevant change or dependency labels Nov 2, 2026
@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Supply-chain pins independently verified (2026-11-02).

  • https://efa-installer.amazonaws.com/aws-efa-installer.key has fingerprint 4E9091BCBB97A96B26B15E59A05480B1DD2D3CCC (uid Amazon EC2 EFA <[email protected]>), matching AWS's EFA guide. It is byte-identical to the committed scripts/efapin/aws-efa-installer.key.
  • aws-efa-installer-1.51.0.tar.gz.sig gives a VALIDSIG by that fingerprint.
  • The sha256 of a fresh download is 83993044…2465c, equal to efaInstallerSHA256.

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live re-test at ef1ab657 (this PR stacked on #1506): Ubuntu 24.04 PASS, AL2023 PASS

Setup: c7gn.16xlarge Spot, us-east-1a, 2-node --mpi --efa --mpi-command hostname, CLI built from this head.

Both distros:

  • The regional mirror returned 403 (nothing is published there yet, Publish the pinned EFA installer to the spawn-binaries mirror at release (needs spawn/efa/* on the release role) #1507), and the origin served 1.51.0. No sha mismatch was reported, and the installer only runs on a matching sha.
  • EFA installation complete., with Open MPI 4 at /opt/amazon/openmpi.
  • /tmp/spawn-efa and /tmp/aws-efa-installer* were gone afterwards on both nodes.
  • No distro Open MPI was installed (no openmpi/openmpi-bin package, no /usr/bin/mpirun).
  • A cross-node mpirun ran /opt/amazon/openmpi/bin/mpirun, Open MPI 4.1.8, on both ranks.
  • fi_info -p efa showed efa-direct.
  • SPAWN_COMPLETE was completed/mpi with exit 0 on both nodes.
  • The installer's loopback fi_pingpong printed SUCCESS on the first attempt.

Ubuntu (ami-09a93d801db0bafae):

AL2023 (ami-0951c836c26e34fc8):

  • No apt step ran, as designed.
  • Inter-node fi_pingpong measured 12.76 µs/xfer over 10k transfers (8.22 µs in the earlier run; run-to-run variance). tx_pkts and rx_pkts rose from 85 to 10086.

AL2 refusal: not exercised live. The only shape that reaches it is a 2-node c7gn cohort, and #1509 tears that down before the logs can be read. It is covered by the sandbox gate.

Teardown: all 4 instances terminated, both placement groups and both SGs deleted, and the 2 lingering Spot requests cancelled. I checked the leak diff independently. Cost for this round was about $0.55.

@scttfrdmn
scttfrdmn force-pushed the fix/1505-efa-installer-pin branch from ef1ab65 to 37fbb13 Compare November 2, 2026 21:22
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…er scripts/efapin, allowlist the EFA key fingerprint
GNU tar execs gzip for -z; the sandbox's restricted PATH had none, so the
EFA sandbox tests failed on CI's Ubuntu runner while passing on macOS,
whose bsdtar decompresses in-process.
@scttfrdmn
scttfrdmn force-pushed the fix/1505-efa-installer-pin branch from af991ef to 01cdf44 Compare November 2, 2026 21:47
@scttfrdmn
scttfrdmn merged commit 830429c into main Nov 2, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1505-efa-installer-pin branch November 2, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:mpi MPI / EFA / placement groups / HPC type:security Security-relevant change or dependency

Projects

None yet

1 participant