Skip to content

security: remove an sts:AssumeRole grant into an account we do not own, and gate the class - #814

Merged
scttfrdmn merged 1 commit into
mainfrom
security/remove-forbidden-cross-account-grant
Oct 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
security/remove-forbidden-cross-account-grant

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Two committed scripts granted sts:AssumeRole on a role ARN in account
942542972736, and the statement had reached the live
SpawnDashboardLambdaPolicy, attached to the execution role of four production
Lambda functions.

The live policy was remediated before this PR was opened, so nothing here is
an open exposure.

Verified by simulation, not asserted

action before after
sts:AssumeRole on the forbidden ARN allowed implicitDeny
ec2:DescribeInstances allowed allowed
dynamodb:PutItem spawn-user-accounts allowed allowed
dynamodb:GetItem spawn-teams allowed allowed
sts:GetCallerIdentity allowed allowed
ec2:TerminateInstances implicitDeny implicitDeny (tag-conditioned)

Exactly one statement removed, none added. v8 retained as rollback.

Two things the snapshot caught before I broke something

  • The scripts build 3- and 5-statement policies; the live policy had 13. So
    remediating by re-running the script — the obvious move — would have shrunk
    the live policy and probably broken the dashboard. The live fix is a surgical
    edit of v8, not a regeneration.
  • All five policy version slots were in use, so v9 required pruning v4 first.

It was inert, which is exactly what made it dangerous

The role name is one nothing in this repo creates, and the live code assumes a
role in a different account with a different name. Nothing depended on the
grant — so nothing would have noticed it being re-applied, and
setup-user-accounts-table.sh re-applied the whole policy on every run with its
failure discarded.

Prevention, not just repair

TestNoARNNamesAnAccountWeDoNotOwn rejects any ARN naming an account outside
an allowlist of accounts this project owns. Allowlist, not denylist — a
denylist only catches the account someone already thought of. Verified against
two compiling reverts: the exact grant that shipped, and a one-digit typo in
an owned account, which a denylist would have missed entirely.

The deploy-script discovery now includes aws iam (create|put|attach|update)-.
#799 widened that discovery over files but listed only the lambda and
cloudformation verbs — the verbs I happened to be fixing — so the script class
that creates cross-account trust was the one class outside the account
assertion. Six scripts now fall under it.

Three of those six create roles in a member account, where there is no
correct default to assert. They now require SPAWN_MEMBER_ACCOUNT explicitly
(:?, so unset is fatal) and refuse to run inside the infra account, where a
cross-account role would trust itself.

Also fixed, surfaced by the same widening

  • setup-user-accounts-table.sh ran create-policy-version --set-as-default
    under &>/dev/null || true, so a failed update left permissions unchanged
    while the script printed success. Now fails loudly.
  • Four attach-role-policy calls dropped their || true: AttachRolePolicy is
    idempotent, so it tolerated no real case while hiding AccessDenied. The
    version-prune loop keeps its || true with a swallow-ok marker — a version
    already gone must not abort the update.

SECURITY.md

The suite had no vulnerability-reporting channel anywhere — the umbrella's
SECURITY.md is a CISO-facing overview with no reporting section. Added one, and
enabled GitHub private vulnerability reporting first, so the documented link
resolves rather than pointing at a disabled button. Link verified 200; both doc
paths it names verified present.

Verification

make check (all 10 nested modules), the deploy census, check-docs, the
changelog gate, and semgrep (0 findings) all clean.

…n, and gate the class

Two committed scripts granted sts:AssumeRole on
arn:aws:iam::942542972736:role/SpawnDashboardCrossAccountRole, and the
statement had reached the LIVE SpawnDashboardLambdaPolicy — attached to
the execution role of four production Lambda functions.

Proven by simulation rather than asserted:

  before   sts:AssumeRole on that ARN -> allowed
  after    sts:AssumeRole on that ARN -> implicitDeny

and every other action on the role unchanged (DescribeInstances,
PutItem, GetItem, GetCallerIdentity all still allowed;
TerminateInstances implicitDeny both sides, being tag-conditioned).
Exactly one statement removed, none added. v8 retained as rollback.

## Two things the snapshot caught before I broke something

The scripts build 3- and 5-statement policies; the live policy had 13. So
remediating by re-running the script — the obvious move — would have
SHRUNK the live policy and probably broken the dashboard. The live fix is
a surgical edit of v8, not a regeneration.

All five policy version slots were in use, so v9 required pruning v4
first. The script's own prune loop exists for this reason.

## It was inert, which is what made it dangerous

The role name is one nothing in this repo creates, and the live code
assumes arn:aws:iam::435415984226:role/SpawnDashboardCrossAccountReadRole
— a different account AND a different role name. Nothing depended on the
grant, so nothing would have noticed it being re-applied.

Noticed while simulating: the LEGITIMATE assume is implicitDeny, so the
dashboard's cross-account reads have never worked. Filed separately.

## Prevention, not just repair

TestNoARNNamesAnAccountWeDoNotOwn rejects any ARN naming an account
outside an ALLOWLIST of accounts this project owns. Allowlist, not
denylist: a denylist only catches the account someone already thought of.
Verified against two compiling reverts — the exact grant that shipped,
and a one-digit typo in an owned account, which a denylist would miss.

The deploy-script discovery regex now includes
`aws iam (create|put|attach|update)-`. #799 widened that discovery over
FILES but listed only the lambda and cloudformation verbs — the verbs I
happened to be fixing — so the script class that creates cross-account
trust was the one class outside the account assertion. Six scripts now
fall under it.

Three of those six create roles in a MEMBER account, where there is no
correct default to assert. They now require SPAWN_MEMBER_ACCOUNT
explicitly (`:?`, so unset is fatal) and refuse to run inside the infra
account, where a cross-account role would trust itself.

## Also fixed, surfaced by the same widening

setup-user-accounts-table.sh ran create-policy-version --set-as-default
under `&>/dev/null || true`, so a failed policy update left permissions
unchanged while the script printed success. It now fails loudly — and it
is the line that was re-applying the forbidden grant.

Four attach-role-policy calls dropped their `|| true`: AttachRolePolicy
is idempotent, so it tolerated no real case while hiding AccessDenied,
which would leave a role with no permissions silently. The version-prune
loop keeps its `|| true` with a swallow-ok marker — a version already
gone must not abort the update.

## SECURITY.md

The suite had NO vulnerability-reporting channel anywhere; the umbrella's
SECURITY.md is a CISO-facing overview with no reporting section. Added
one, and enabled GitHub private vulnerability reporting first so the
documented link resolves — shipping a policy that points at a disabled
button is the defect class this whole audit is about. Link verified 200;
both doc paths it names verified present.

make check green (all 10 nested modules), census, check-docs, changelog,
semgrep 0 findings.
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit be68316 into main Oct 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the security/remove-forbidden-cross-account-grant branch October 11, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant