Skip to content

security: SpawnSweepCrossAccountRole: unconditioned ec2:CreateTags defeats the tag-gated ssm:SendCommand, giving the orchestrator root on any instance in every compute account #1586

Closed

Description

@scttfrdmn

From the pre-1.0 security audit (spore-host/spore-host#649, 2026-11-11), audit id iam-7. Verified: confirmed, severity medium (reviewer said medium).

Where: pkg/aws/sweep_role.go:115 (at origin/main on 2026-11-11)

Evidence

LaunchAndCancelMembers grants ec2:CreateTags, ec2:TerminateInstances and RunInstances on Resource "" with no condition (lines 105-118). EgressProxyProbeProxies (line 189) gates ssm:SendCommand (AWS-RunShellScript) only on ssm:resourceTag/spawn:managed=true and spawn:egress-proxy=vpc-, both of which the same role can write onto any instance. PassSpawnInstanceRoles also passes any spawn-instance-* role except nested ones (line 139), including roles carrying user-attached managed policies. The trusting principal is SpawnSweepOrchestratorRole in the shared infra account, whose script policy assumes arn:aws:iam::*:role/SpawnSweepCrossAccountRole (scripts/setup-sweep-orchestrator-lambda-role.sh). The target account comes from the aws_account_id field of the DynamoDB sweep record (lambda/sweep-orchestrator/main.go:304, 433).

Scenario

Anyone who can modify the spawn-sweep-orchestrator code, or its role in 966362334030 (including the GitHubActions-spawn-lambda-deploy CI role via UpdateFunctionCode), can for every compute account that ran a detached sweep: tag any instance spawn:managed=true and spawn:egress-proxy=vpc-x, then SendCommand a root shell to it and read its instance credentials. Terminate-on-* was already there; root command execution on non-spawn production instances is new reach. This is the #678 pattern in a role spawn now auto-creates in user accounts.

Verifier

pkg/aws/sweep_role.go:105-117 grants ec2:CreateTags and TerminateInstances on '*' unconditioned. EgressProxyProbeProxies (lines 188-200) gates ssm:SendCommand only on the ssm:resourceTag spawn:managed and spawn:egress-proxy tags, which this same role can write. EgressProxyProbeDocument (lines 202-206) allows AWS-RunShellScript. Whoever controls the orchestrator Lambda or its role can therefore retag a non-spawn instance and get a root shell on it. That needs code or role control in 966362334030 (an insider or CI-deploy compromise), so it is not externally exploitable. The tag gate on SendCommand is defeated by the unconditioned CreateTags. Related to input-3 (same role) but a different root cause: policy breadth versus who chooses the target account.

Suggested fix

Condition CreateTags with ec2:CreateAction=RunInstances (members are tagged at launch), plus ec2:ResourceTag/spawn:managed=true for later tag edits, plus an explicit Deny on aws:TagKeys spawn:managed and spawn:egress-proxy outside a create action. Condition TerminateInstances and CancelSpotInstanceRequests on spawn:managed (or spawn:sweep-id). Consider limiting PassRole to roles tagged by the CLI as sweep-passable. Bump sweepRolePolicySchema.

Deployed-state check

In 435415984226 (and any compute account), read SpawnSweepCrossAccountRole's inline policy names and confirm which schema is live, and check whether a legacy SweepCrossAccountEC2Policy from the old script with broader grants still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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