Skip to content

Dashboard cross-account EC2 reads have never worked: the role it assumes is not granted #815

Closed

Description

@scttfrdmn

Found while simulating the before/after state for #814. Not a security exposure —
the opposite: a permission that should exist and does not.

Measured

$ aws iam simulate-principal-policy \
    --policy-source-arn arn:aws:iam::966362334030:role/SpawnDashboardLambdaRole \
    --action-names sts:AssumeRole \
    --resource-arns arn:aws:iam::435415984226:role/SpawnDashboardCrossAccountReadRole
implicitDeny

lambda/dashboard-api/cross_account.go:21 assumes exactly that ARN:

return "arn:aws:iam::435415984226:role/SpawnDashboardCrossAccountReadRole"

and getEC2ClientForRegion builds every cross-account EC2 client through it. The
role's policy grants sts:AssumeRole on no resource now that #814 removed
the one statement it had — and that statement named a different account and a
different role name (…CrossAccountRole, not …CrossAccountReadRole).

So the dashboard's cross-account instance listing has never worked. The two
findings explain each other: the grant was written for an account/role pair that
later changed, the code moved to the dev account, and the grant was never
updated — leaving a useless grant pointing somewhere forbidden and no grant
pointing anywhere useful.

Before fixing, decide whether the feature is wanted

This is the #783 question again. Two facts worth weighing:

  1. lambda/dashboard-api/scripts/setup-cross-account-role.sh does create
    SpawnDashboardCrossAccountReadRole in the dev account and trusts
    966362334030, so the resource half was built. Only the identity half is
    missing.
  2. That script's trust is arn:aws:iam::966362334030:root with no ExternalId
    and no ArnLike
    on aws:PrincipalArn, so any principal in the infra
    account can assume it, and it carries AmazonEC2ReadOnlyAccess +
    AmazonDynamoDBReadOnlyAccess. Compare the reaper's trust, which was
    deliberately narrowed to :root plus an ArnLike for exactly this reason
    (ttl-reaper: cross-account trust names a CFN-generated role ARN suffix — recreating the stack breaks EVERY account at once (#457 trap 1) #476). If the feature is kept, that trust should be narrowed the same way
    before the grant is added — otherwise adding the grant widens real access.

If kept

Add a statement to SpawnDashboardLambdaPolicy granting sts:AssumeRole on that
one role ARN — scoped to the ARN, not arn:aws:iam::*:role/..., which is the
wildcard-account shape flagged elsewhere in the review. Then narrow the member-side
trust per (2), and verify with simulate-principal-policy plus an actual
dashboard request, not just the simulation.

If not kept

Remove cross_account.go's assume path and
scripts/setup-cross-account-role.sh, and say in the dashboard that instance
listing is infra-account only. Leaving a code path that silently fails on every
call is the shape this audit exists to remove.

Activity

  1. added
    bug
    on Oct 11, 2026
  2. scttfrdmn commented on Oct 11, 2026

    @scttfrdmn
    ContributorAuthor

    I went to do this and the live state does not match what I wrote on this issue. Correcting
    before anyone acts on it.

    The deployed trust is not :root. SpawnDashboardCrossAccountReadRole in
    435415984226 currently trusts:

    "Principal": { "AWS": [
      "AROA6B75PANHFXGFLBRS7",
      "arn:aws:iam::966362334030:role/Cognito_SpawnDashboard_Auth_Role"
    ]}

    Three things follow:

    1. Item (2) of this issue is moot for the live role. I said the trust was
      966362334030:root with no ExternalId, so any principal in the infra account could
      assume it, and that it should be narrowed before adding the grant. The script does
      write :root (setup-cross-account-role.sh:36), but the live role does not match the
      script — so either it was never created by it or it was hand-edited afterwards. The
      live trust is already narrow.
    2. AROA6B75PANHFXGFLBRS7 is a deleted role. It matches no live role in 966362334030
      (list-roles --query 'Roles[?RoleId==...]' → []). A bare AROA… principal ID in a
      trust policy is what AWS leaves behind when a trusted role ARN is deleted. Harmless —
      role unique IDs are never reused, so it cannot be re-granted by recreating a role of
      the same name — but it is dead weight that obscures who is actually trusted.
    3. The remaining trusted principal is a Cognito role, not the Lambda.
      Cognito_SpawnDashboard_Auth_Role exists in infra (created 2026-01-15). That reframes
      the architecture question: cross-account reads look like they were designed for
      browser-side Cognito-authenticated callers, and cross_account.go assuming the role
      from the dashboard Lambda may be a later addition that was never wired up at either
      end. SpawnDashboardLambdaRole is not in the trust at all, which is a second reason
      the assume fails beyond the missing identity-side grant.

    So the decision this issue asks for is sharper than I framed it. It is not "keep the
    feature and narrow the trust" — it is which caller is supposed to do cross-account
    reads
    : the Lambda (add it to the trust, add the identity grant) or the browser via
    Cognito (delete cross_account.go's assume path). I am not guessing at that one.

    One decision-free defect regardless: setup-cross-account-role.sh writes
    Principal: {"AWS": "arn:aws:iam::<infra>:root"} with no ExternalId and no ArnLike on
    aws:PrincipalArn. Re-running it would replace today's narrow trust with a wide one,
    and it carries AmazonEC2ReadOnlyAccess + AmazonDynamoDBReadOnlyAccess. Compare the
    reaper's trust, deliberately narrowed to :root plus an ArnLike for exactly this
    reason (#476). Worth fixing whichever way the architecture decision goes — unless the
    answer is "delete the script", which is why I have not pre-emptively fixed it.

    Org check done before touching any of this, per the project constraint: both 966362334030
    and 435415984226 are in o-v33p2ygcff (management 752123829273). Neither is 942542972736
    and neither is in o-pygqyjjoym. No live IAM change made.

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

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions