Skip to content

Sweep orchestrator: refuse an impossible target account before every AssumeRole (#1584) - #1634

Merged
scttfrdmn merged 1 commit into
mainfrom
hardening/1584-sweep-target-check
Nov 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
hardening/1584-sweep-target-check

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

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: every AssumeRole the orchestrator makes now goes through assumeSweepRole. That covers all three sites: single-region createCrossAccountEC2Client, multi-region initializeRegionalOrchestrator, and cancel's assumeMemberClients. Before STS is called, it refuses a record whose aws_account_id:

  • is not a 12-digit account ID (*, an ARN fragment, empty), so it never reaches the role-ARN template;
  • is forbidden by pkg/trustboundary (942542972736), which is hardcoded and so cannot be switched off by configuration;
  • is the orchestrator's own account, read from the invoked function ARN. That is spore.host's control plane, which launches no members, and the CLI already refuses a sweep role there (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 TerminateInstances on spawn:managed=true, and CreateTags/DeleteTags are denied except at RunInstances/CreateSecurityGroup. That closes the "rewrite any instance's spawn:pre-stop" path the finding describes. A reaperControlTagDeny on this role would also deny the create-time tags every member needs, so it is not added. The residual unconditioned ec2:CancelSpotInstanceRequests on * 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 exactly arn:aws:iam::435415984226:role/SpawnSweepCrossAccountRole. A source gate requires exactly one .AssumeRole(ctx in the package's non-test code, in target_account.go. The iamcoverage gate passes (the call is discovered through the interface). make check is 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

  1. Deployed state, from the finding. In 966362334030, find who holds dynamodb:PutItem/UpdateItem on spawn-sweep-orchestration, s3:PutObject on the sweep params bucket, and lambda:InvokeFunction on spawn-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-orchestration for 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.
  2. After deploy: run one detached sweep (spawn launch --params ... --detach, 2 members, short --ttl) into the dev account. It launches, and its log shows Assuming the sweep role in account 435415984226. Cancel it from the dashboard and confirm the members terminate. Reap and verify nothing is left.
  3. Negative, optional: write a copy of a finished sweep's record with aws_account_id=942542972736 under a new sweep_id and invoke the orchestrator on it. It fails with refusing to act in account 942542972736, and CloudTrail in 966362334030 shows no AssumeRole for that ARN. Delete the test record afterwards.

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn force-pushed the hardening/1584-sweep-target-check branch from ba2fdcf to e77f50b Compare November 14, 2026 20:17
…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
scttfrdmn marked this pull request as ready for review November 14, 2026 22:50
@scttfrdmn
scttfrdmn force-pushed the hardening/1584-sweep-target-check branch from e77f50b to caf8cca Compare November 14, 2026 22:50
@scttfrdmn
scttfrdmn merged commit 5d46ba6 into main Nov 14, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the hardening/1584-sweep-target-check branch November 14, 2026 23:14
@scttfrdmn scttfrdmn mentioned this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant