Repository navigation
Sweep role: tag only at create, terminate only spawn:managed (#1586) - #1612
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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
SpawnSweepCrossAccountRole granted ec2:CreateTags and TerminateInstances on any resource. Writing spawn:managed and spawn:egress-proxy onto an instance that was not spawn's passed the tag gate on its egress-proxy ssm:SendCommand, so the orchestrator's principal could get a root shell on any instance in a compute account. CreateTags is now allowed only with ec2:CreateAction RunInstances or CreateSecurityGroup (the only creates the orchestrator tags at, held to the code by an iamcoverage discovery gate), and TerminateInstances only on spawn:managed=true. Explicit Denies (StringNotLike ec2:CreateAction, the form proven live on the nested role; StringNotEquals spawn:managed) retire the unconditioned grants of older copies. Sweep role schema 2.
scttfrdmn
force-pushed
the
fix/1586-sweep-role-tags
branch
from
November 13, 2026 21:59
83fa346 to
80fbde6
Compare
scttfrdmn
marked this pull request as ready for review
November 13, 2026 21:59
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 #1586
What
SpawnSweepCrossAccountRole(schema 1) allowedec2:CreateTagsandec2:TerminateInstanceson*with no condition. The role could therefore writespawn:managed=trueandspawn:egress-proxy=vpc-*onto any instance, and those two tags are the whole gate on itsssm:SendCommand(AWS-RunShellScript) grant.Schema 2 (
SweepCrossAccountEC2Policy-v2) makes these changes:TagOnlyAtCreate:ec2:CreateTagsis allowed only withStringEquals ec2:CreateAction∈ {RunInstances,CreateSecurityGroup}. These are the only creates the orchestrator tags at: members and egress proxies at RunInstances, and the proxy's groups at CreateSecurityGroup. The orchestrator never calls CreateTags directly.DenyTagExistingResources: Denyec2:CreateTags/DeleteTagswithStringNotLike ec2:CreateActionover the same list. This is the form spawn#1606 proved live;Nullwas not enough there. It retires the unconditioned grant in any older copy (v1, or the script's unversioned policy).TerminateManagedInstancesplusDenyTerminateUnmanaged: terminate is allowed only whereec2:ResourceTag/spawn:managed=true. Every member (tags.go) and every egress proxy carries that tag from RunInstances.CancelSpotInstanceRequestsstays unconditioned because the members' requests are untagged, and cancelling a request terminates nothing. PassRole is unchanged.Gates
internal/iamcoverageTestSweepRoleTagsOnlyAtTheCreatesTheOrchestratorMakesdiscovers every create the orchestrator tags at and requires the CreateAction list to equal that set. I watched it fail against a compiling revert that droppedCreateSecurityGroup.pkg/awsTestSweepPolicyCannotRetagOrTerminateForeignInstanceschecks that no CreateTags Allow lacks a CreateAction, that no Terminate Allow lacks spawn:managed, that both Denies exist, and that the tag Deny does not useNull.sporedPolicySchemais unchanged because no spored document changed.Live checks needed before merge (owner)
No AWS calls were made writing this. Run these in 435415984226 (
spore-host-dev), with an explicit--regionon every call:go test ./pkg/aws -run TestSweepPolicyGolden -v(or renderSweepCrossAccountPolicyDocument("435415984226")), then on a throwaway role runaws iam put-role-policy --role-name <tmp> --policy-name SweepCrossAccountEC2Policy-v2 --policy-document file://doc.json. It must succeed. Delete the role afterwards.ec2:CreateTagsonarn:aws:ec2:us-east-1:435415984226:instance/i-xwithec2:CreateAction=RunInstancesec2:CreateTagson…:security-group/sg-xwithec2:CreateAction=CreateSecurityGroupec2:CreateTagson…:instance/i-xwith noec2:CreateActionec2:CreateTagswithec2:CreateAction=CreateTagsec2:DeleteTagson…:instance/i-xec2:TerminateInstanceswithec2:ResourceTag/spawn:managed=trueec2:TerminateInstanceswithec2:ResourceTag/spawn:managedabsent, and with it set tofalsessm:SendCommandon…:instance/i-xwithssm:resourceTag/spawn:managed=true,ssm:resourceTag/spawn:egress-proxy=vpc-1spawn launch --param-file <2 rows> --detach --ttl 15min us-east-1.SweepCrossAccountEC2Policy-v2.spawn:sweep-*tags.spawn sweep cancel <id>should terminate both.SpawnSweepCrossAccountRole(from the orchestrator role), then runaws ec2 create-tags --dry-run --resources <a non-spawn instance> --tags Key=spawn:managed,Value=true. ExpectUnauthorizedOperation. Then runterminate-instances --dry-runon the same instance. ExpectUnauthorizedOperation.--no-public-ip --bootstrap-egress proxyto exercise CreateSecurityGroup tag-on-create.spawn:sweep-id=<id>, and no proxy left increating.