Repository navigation
Require IMDSv2 on every launch path (#1588) - #1613
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Live check (spore-host-dev, 2026-11-13). The build integrated #1612, #1613, #1614 and #1616 on main.
Not run live: Windows (#1617), the egress proxy (#1618), the release manifest (#1619), retiring a reused DCV/MPI group, and interactive |
This was referenced Nov 13, 2026
MetadataOptions (HttpTokens=required, endpoint enabled, hop limit 1) was set only in compliance mode. It is now set unconditionally in applyLaunchSettings (Client.Launch, and every detached member's LaunchSettings.Apply), in the sweep orchestrator for legacy params, in the pipeline orchestrator, and through one helper in the egress proxy. That covers spawn launch, sweeps, nested spawn, spawn app, spawn task and pkg/launcher (lagotto). Hop limit 2 only where a bridged container is the workload and uses the instance role: spawn task run with a container, and pkg/launcher with a ContainerScript. Web apps stay at 1. spawn launch gains --imds-hop-limit. The CLI always sends imdsv2_enforced=true so an orchestrator deployed before this change also enforces it. A root AST gate discovers every RunInstancesInput literal and fails one whose function does not set MetadataOptions.
scttfrdmn
marked this pull request as ready for review
November 13, 2026 22:25
scttfrdmn
force-pushed
the
hardening/instance-side
branch
from
November 13, 2026 22:25
12eaaf6 to
00215bb
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1588
What
Every RunInstances call spawn makes now requires IMDSv2:
HttpTokens=required,HttpEndpoint=enabled, andHttpPutResponseHopLimit1. The settings come from one helper,pkg/aws.IMDSMetadataOptions(imds.go).spawn launch, nested spawn (the head runsspawn launch),spawn app(DCV/web/desktop),spawn image, burst, batch queue, job arrays, foreground sweepsapplyLaunchSettingsinClient.Launchnow sets it unconditionallyLaunchSettings.Apply, the same function. It ignoresimdsv2_enforced=falsefrom older CLIsbuildRunInstancesInputsets it before the settings are appliedbuildStageRunInstancesInputpkg/launcher.Provision(lagotto, spore-host-mcp)Client.Launch. lagotto picks it up on its next spawn bumpHop limit 2, path by path
spawn task runwithcontainer: the task runs indocker runon the default bridge network, one hop further from IMDS than the host. Adapters whose own tooling does the S3 I/O inside the container (resources.s3_read_write, e.g. Snakemake's S3 plugin) need the task role.pkg/launcherwithOptions.ContainerScript(pkg/userdatacontainer launches):docker runbridged, and the container is the workload. Its only credential is the instance profile. A caller's explicitIMDSv2HopLimitwins.--network host.spawn launch --imds-hop-limit N(1-64) covers user workloads that need more. Compliance mode still forces 1.Compatibility. The CLI now always writes
imdsv2_enforced: trueinto the launch settings, so a sweep orchestrator deployed before this PR also enforces IMDSv2 for members launched by a new CLI.Gates
TestEveryRunInstancesRequiresIMDSv2(repo root) discovers everyec2.RunInstancesInputliteral in non-test code. It fails any whose function neither setsMetadataOptionsnor callsapplyLaunchSettings; DryRun literals are exempt. I watched it fail when I removed the pipeline line.TestApplyLaunchSettingsAlwaysRequiresIMDSv2andTestLaunchSettingsAlwaysCarryIMDSv2Enforced(pkg/aws),TestEveryMemberRequiresIMDSv2(sweep Lambda),TestStageRequiresIMDSv2,TestTaskLaunchConfig_IMDSHopLimit,TestProvisionHopLimit.IMDSMetadataOptionsand three constants. These are additions only.No IAM changes. There is no spored policy change, so no
sporedPolicySchemabump.Not covered here: spawn-ts (
src/aws/ec2.tsRunInstancesCommand) lives in its own repo and needs the same change.Live checks needed before merge (owner)
These are RunInstances-side changes, and the Lambdas need redeploying: sweep-orchestrator, and pipeline-orchestrator (root module). Run in 435415984226, with
--ttl 15mon every launch.spawn launch --ttl 15m --ami <an Ubuntu 22.04 AMI>(an AMI with ImdsSupport unset).aws ec2 describe-instances --query 'Reservations[].Instances[].MetadataOptions'should showHttpTokens=required,HttpPutResponseHopLimit=1.spawn connectshould work and spored should heartbeat, which proves spored works under IMDSv2.--imds-hop-limit 2and expect hop 2. With--imds-hop-limit 0, the default applies. With--imds-hop-limit 65, expect a refusal before any AWS call.spawn task runwith acontainer:spec that runsaws sts get-caller-identityinside the container. Expect hop 2, and the call succeeds from the container.spawn app launchof a web kind (e.g. code-server). Expect hop 1. From inside the container,curl -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'gets no token. The app itself still loads.--detach --ttl 15m). Both members should showHttpTokens=required, hop 1. Optionally, replay an old schedule (legacy params) and expect the same.HttpTokens=required, hop 1.pkg/launcherlaunch built against this branch should show required, hop 1.