Skip to content

security: The sweep orchestrator acts in whatever aws_account_id a writable DynamoDB record names: a confused deputy with unconditioned RunInstances, CreateTags and Terminate #1584

Closed

Description

@scttfrdmn

From the pre-1.0 security audit (spore-host/spore-host#649, 2026-11-11), audit id input-3. Verified: plausible, severity medium (reviewer said high).

Where: lambda/sweep-orchestrator/main.go:429 (at origin/main on 2026-11-11)

Evidence

func createCrossAccountEC2Client(ctx, region, accountID string) does roleARN := fmt.Sprintf(crossAccountRole, accountID) and AssumeRole with no ExternalId. accountID is state.AWSAccountID, read from the spawn-sweep-orchestration item, which pkg/sweep/detached.go:233 CreateSweepRecord writes directly with the CLI's infra credentials (any writer can PutItem any aws_account_id and user_id). Nothing in the orchestrator ties the writer to the target account, and there is no 942542972736 or management-account check on this side. SpawnSweepCrossAccountRole's policy (pkg/aws/sweep_role.go ~111-119) grants ec2:RunInstances, ec2:CreateTags, ec2:TerminateInstances and ec2:CancelSpotInstanceRequests on Resource "" with no condition, plus iam:PassRole of spored-instance-role and spawn-instance-.

Scenario

Any principal that can write a sweep item and params object and invoke spawn-sweep-orchestrator controls the target account. Every user running a detached sweep needs those grants, because the CLI does it with infraCfg. Such a principal can set aws_account_id to another onboarded account. The orchestrator then launches instances in the victim account with attacker-chosen user data and the spored role, terminates any instance (not just spawn ones), or rewrites any instance's spawn:pre-stop/spawn:local-username tags (no reaperControlTagDeny on this role). The TTL reaper then runs the hook as root via SSM AWS-RunShellScript. ExternalId was dropped by owner decision. That is defensible only if the record writer is bound to the target account, and today it is not.

Verifier

The confused-deputy shape is real. lambda/sweep-orchestrator/main.go:304, 1100 and cancel.go:91 build the role ARN from state.AWSAccountID, read from the DynamoDB record, and AssumeRole with no ExternalId and no check that ties the record's writer to that account. The forbidden-account and management-account checks (pkg/aws/sweep_role.go CheckSweepRoleAccounts) run only in the CLI when the role is provisioned, never in the orchestrator. Every SpawnSweepCrossAccountRole trusts the same SpawnSweepOrchestratorRole (sweep_role.go:245-262), and its policy grants RunInstances, CreateTags, TerminateInstances and CancelSpotInstanceRequests on '*' (lines 105-117). Exploitability depends entirely on who holds PutItem on spawn-sweep-orchestration, PutObject on the params bucket and InvokeFunction in 966362334030. The CLI reaches these with spore-host-infra credentials (cmd/launch_sweep.go:1402), which suggests operators only. If only operators who also own every compute account hold those grants, nothing crosses a trust boundary. I rated it medium, not high, for that reason.

Suggested fix

Bind writer to target: have the orchestrator (or a SigV4-authenticated front door like dns-updater) derive the target account from the verified caller identity, and refuse records whose aws_account_id differs. Or store records under a key the writer cannot forge, such as a per-account table or condition dynamodb:LeadingKeys on the caller's account. Add the forbidden/management-account refusal before every AssumeRole in main.go and cancel.go. Condition TerminateInstances/CreateTags on aws:ResourceTag/spawn:sweep-id, and add the reaperControlTagDeny statement to SpawnSweepCrossAccountRole.

Deployed-state check

Find who holds dynamodb:PutItem/UpdateItem on spawn-sweep-orchestration, s3:PutObject on the params bucket, and lambda:InvokeFunction on spawn-sweep-orchestrator in 966362334030. If any non-operator or tenant principal holds them, this is exploitable today. Also list the accounts holding SpawnSweepCrossAccountRole.

Also raised as: tenant-7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions