Repository navigation
Sweep orchestrator: refuse an impossible target account before every AssumeRole (#1584) - #1634
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
hardening/1584-sweep-target-check
branch
from
November 14, 2026 20:17
ba2fdcf to
e77f50b
Compare
…AssumeRole (#1584) Every AssumeRole the orchestrator makes (single-region, multi-region, cancel) now goes through assumeSweepRole, which refuses, before STS is called, a record whose aws_account_id is not a 12-digit account ID, is a pkg/trustboundary forbidden account, or is the orchestrator's own control-plane account. A source gate allows exactly one AssumeRole call site in the package. Binding the record's writer to the account it names is #1631.
scttfrdmn
marked this pull request as ready for review
November 14, 2026 22:50
scttfrdmn
force-pushed
the
hardening/1584-sweep-target-check
branch
from
November 14, 2026 22:50
e77f50b to
caf8cca
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.
Refs #1584. This PR does the orchestrator-side half. The core of the finding, binding the record's writer to the account it names, needs an infra front door and is tracked in #1631, so this PR does not close #1584.
What changes
lambda/sweep-orchestrator/target_account.go: everyAssumeRolethe orchestrator makes now goes throughassumeSweepRole. That covers all three sites: single-regioncreateCrossAccountEC2Client, multi-regioninitializeRegionalOrchestrator, and cancel'sassumeMemberClients. Before STS is called, it refuses a record whoseaws_account_id:*, an ARN fragment, empty), so it never reaches the role-ARN template;pkg/trustboundary(942542972736), which is hardcoded and so cannot be switched off by configuration;CheckSweepRoleTrust).The management-account rule stays the CLI's: Organizations is checked when the role is created, so a role cannot exist in a management account for an AssumeRole to reach.
Policy side: #1586 already conditions
TerminateInstancesonspawn:managed=true, andCreateTags/DeleteTagsare denied except atRunInstances/CreateSecurityGroup. That closes the "rewrite any instance'sspawn:pre-stop" path the finding describes. AreaperControlTagDenyon this role would also deny the create-time tags every member needs, so it is not added. The residual unconditionedec2:CancelSpotInstanceRequestson*is noted on #1631.Tests
target_account_test.go: for a fake STS and a Lambda context in 966362334030, the forbidden account, the own account and six malformed IDs are each refused with no STS call, and a member account assumes exactlyarn:aws:iam::435415984226:role/SpawnSweepCrossAccountRole. A source gate requires exactly one.AssumeRole(ctxin the package's non-test code, intarget_account.go. The iamcoverage gate passes (the call is discovered through the interface).make checkis clean apart from the known space-in-path failures. Semgrep is clean.Deploy
spawn-sweep-orchestrator: code-only. No IAM change.Live checks for the owner
dynamodb:PutItem/UpdateItemonspawn-sweep-orchestration,s3:PutObjecton the sweep params bucket, andlambda:InvokeFunctiononspawn-sweep-orchestrator. For example,aws iam simulate-principal-policy --policy-source-arn <each role/user ARN> --action-names dynamodb:PutItem --resource-arns arn:aws:dynamodb:us-east-1:966362334030:table/spawn-sweep-orchestrationfor each principal. If any non-operator holds them, Sweep orchestrator: bind the record's writer to its target account (rest of #1584) #1631 is exploitable today and is the priority.spawn launch --params ... --detach, 2 members, short--ttl) into the dev account. It launches, and its log showsAssuming the sweep role in account 435415984226. Cancel it from the dashboard and confirm the members terminate. Reap and verify nothing is left.aws_account_id=942542972736under a newsweep_idand invoke the orchestrator on it. It fails withrefusing to act in account 942542972736, and CloudTrail in 966362334030 shows noAssumeRolefor that ARN. Delete the test record afterwards.