Repository navigation
security: remove an sts:AssumeRole grant into an account we do not own, and gate the class - #814
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two committed scripts granted
sts:AssumeRoleon a role ARN in account942542972736, and the statement had reached the liveSpawnDashboardLambdaPolicy, attached to the execution role of four productionLambda functions.
The live policy was remediated before this PR was opened, so nothing here is
an open exposure.
Verified by simulation, not asserted
sts:AssumeRoleon the forbidden ARNec2:DescribeInstancesdynamodb:PutItemspawn-user-accountsdynamodb:GetItemspawn-teamssts:GetCallerIdentityec2:TerminateInstancesExactly one statement removed, none added. v8 retained as rollback.
Two things the snapshot caught before I broke something
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.
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.shre-applied the whole policy on every run with itsfailure discarded.
Prevention, not just repair
TestNoARNNamesAnAccountWeDoNotOwnrejects any ARN naming an account outsidean 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_ACCOUNTexplicitly(
:?, so unset is fatal) and refuse to run inside the infra account, where across-account role would trust itself.
Also fixed, surfaced by the same widening
setup-user-accounts-table.shrancreate-policy-version --set-as-defaultunder
&>/dev/null || true, so a failed update left permissions unchangedwhile the script printed success. Now fails loudly.
attach-role-policycalls dropped their|| true:AttachRolePolicyisidempotent, so it tolerated no real case while hiding
AccessDenied. Theversion-prune loop keeps its
|| truewith aswallow-okmarker — a versionalready gone must not abort the update.
SECURITY.md
The suite had no vulnerability-reporting channel anywhere — the umbrella's
SECURITY.mdis a CISO-facing overview with no reporting section. Added one, andenabled 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, thechangelog gate, and
semgrep(0 findings) all clean.