Repository navigation
Description
Split from #1344 (items 3 and 4). These need an owner decision, because each fix grants a terminate path to an identity that does not have one today.
Dashboard terminate in a member account has no working role
handleTerminateInstance (lambda/dashboard-api/instances.go) checks ownership with DescribeInstances, then calls ec2:TerminateInstances and ec2:CancelSpotInstanceRequests (terminateCancellingSpot), all on the client from getEC2ClientForRegion. That client is SpawnDashboardCrossAccountReadRole, assumed with the caller's credentials (#815). The role grants reads only, so the terminate is denied.
Why I did not add a tag-scoped terminate to that role: the Lambda is not in the path to it. The browser assumes the same role directly with the user's Cognito credentials (spore-host/web/js/main.js:296-306, crossAccountRoleArn then sts.assumeRole), and the trust names Cognito_SpawnDashboard_Auth_Role, which every signed-in dashboard user holds. The ownership check (spawn:iam-user == cliIamArn) runs only in the Lambda. A grant on the role conditioned on ec2:ResourceTag/spawn:managed=true would therefore let any dashboard user terminate any spore in the member account, theirs or not. No condition binds the owner: the session is the caller's to name and tag.
Dashboard sweep cancel assumes a role whose trust does not name it
terminateSweepInstancesCrossAccount (lambda/dashboard-api/sweeps.go:~407) assumes arn:aws:iam::<account>:role/SpawnSweepCrossAccountRole with the Lambda's own credentials (SpawnDashboardLambdaRole). That role's trust (scripts/setup-sweep-cross-account-role.sh) names only SpawnSweepOrchestratorRole, so the AssumeRole is denied whatever the Lambda role grants. The cancel still marks the sweep CANCELLED in DynamoDB, but its instances keep running until their TTL.
Options
- Give the dashboard Lambda a terminate path of its own: a member-account role trusted only by
SpawnDashboardLambdaRoleand scoped tospawn:managed=true, with the Lambda's ownership check as the gate. This is the standing cross-tenant Lambda privilege that Dashboard cross-account EC2 reads have never worked: the role it assumes is not granted #815 deliberately rejected for reads. - Add
SpawnDashboardLambdaRoletoSpawnSweepCrossAccountRole's trust. This is option 1 using an existing role that can also RunInstances, so it grants more. - Do not terminate from the dashboard in a member account. Point the user to
spawn terminate/spawn sweep cancel, which run as the user. The coverage gate's ledger keeps these as permanent, explained entries.
The coverage gate (internal/iamcoverage/gaps_test.go) records dashboard-api | SpawnDashboardCrossAccountReadRole | ec2:TerminateInstances, ec2:CancelSpotInstanceRequests and dashboard-api | SpawnDashboardLambdaRole | sts:AssumeRole against this issue.
Activity
fix(iam): batch-queue results role, dashboard role scripts match the …
fix(iam): batch-queue results role, dashboard role scripts match the …
scttfrdmn commentedon Oct 27, 2026
Decision (owner, 2026-10-26):
spawn terminate <id>(shipped in fix(iam): batch-queue results role; dashboard role scripts match the code (#1344) #1352) is the permanent behaviour, and the coverage-gate ledger keepsec2:TerminateInstances/ec2:CancelSpotInstanceRequestsonSpawnDashboardCrossAccountReadRoleas explained, permanent entries.SpawnSweepCrossAccountRoleand is trusted by it, terminates the cancelled sweep's instances. No new trust and no new role. The Lambda'ssts:AssumeRoleledger entry goes away along with the dead code path.fix(sweep): dashboard cancel marks CANCELLED and starts the orchestra…
dashboard-api: retire SpawnDashboardCrossAccountReadRole; read EC2 as…
dashboard-api: retire SpawnDashboardCrossAccountReadRole; read EC2 as…
dashboard-api: retire SpawnDashboardCrossAccountReadRole; read EC2 as…