Skip to content

Dashboard: terminate and sweep cancel in a member account have no role that may do them (owner decision) #1349

Closed

Description

@scttfrdmn

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

  1. Give the dashboard Lambda a terminate path of its own: a member-account role trusted only by SpawnDashboardLambdaRole and scoped to spawn: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.
  2. Add SpawnDashboardLambdaRole to SpawnSweepCrossAccountRole's trust. This is option 1 using an existing role that can also RunInstances, so it grants more.
  3. 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

  1. added this to the v0.147.0 milestone on Oct 26, 2026
  2. scttfrdmn commented on Oct 27, 2026

    @scttfrdmn
    ContributorAuthor

    Decision (owner, 2026-10-26):

    • Instance terminate from the dashboard, member account: option 3. It is not done from the dashboard. The 403 that names 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 keeps ec2:TerminateInstances / ec2:CancelSpotInstanceRequests on SpawnDashboardCrossAccountReadRole as explained, permanent entries.
    • Sweep cancel: the dashboard stops trying to terminate. It only marks the sweep CANCELLED, which it can already do. The sweep orchestrator, which already assumes SpawnSweepCrossAccountRole and is trusted by it, terminates the cancelled sweep's instances. No new trust and no new role. The Lambda's sts:AssumeRole ledger entry goes away along with the dead code path.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions