Skip to content

Refuse cross-account trust into forbidden or management accounts on every path (#1582, #1583) - #1608

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/trust-boundary-1582
Nov 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/trust-boundary-1582

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1582. Fixes #1583.

Summary

  • pkg/trustboundary now holds the forbidden-account list (942542972736) and the Organizations management-account rule. They moved out of pkg/aws/sweep_role.go. The package takes lookups rather than importing the Organizations client, so the Lambdas that import pkg/aws do not carry it.
  • Fails closed (security: Sweep-role management-account check fails open, and ignores the orchestrator account's own organization #1583). An Organizations error refuses the trust, and the message names organizations:DescribeOrganization. The only lookup result that passes is the proven one: AWSOrganizationsNotInUseException (the account is in no organization), which pkg/orgaccount already reports as such.
  • Both ends (security: Sweep-role management-account check fails open, and ignores the orchestrator account's own organization #1583). The sweep role now also checks the orchestrator account's own organization, using the infra credentials (aws.CheckSweepRoleTrust). CheckSweepRoleAccounts keeps its signature and now fails closed.
  • spawn onboard and spawn notify register (the SpawnBotCrossAccount role) run the check before any IAM call. A principal ARN with no account is refused. TestCrossAccountTrustWritersCheckTheBoundary gates that the check precedes the trust write in each command.
  • CloudFormation: ttl-reaper-cross-account-role.yaml and bot-cross-account-role.yaml carry a Rules assertion refusing AWS::AccountId = 942542972736. The reaper template also refuses that value for ReaperAccountId. TestCrossAccountTemplatesRefuseTheForbiddenAccount discovers every template in the repository whose IAM role trusts an AWS principal and fails CI on any without the rule. It also fails if it discovers none. A template cannot ask Organizations, so the management-account half applies only to the CLI paths.

The reaper does not create a cross-account role: spawn reaper deploy writes a role trusting lambda.amazonaws.com in the caller's own account. So no reaper CLI path needed the check.

Deploy checklist impact

  • Lambdas changed: none.
  • The two templates changed only by adding Rules, which CloudFormation evaluates at stack create and update. Updating existing stacks is optional and changes no resource.
  • New permission on the CLI side: organizations:DescribeOrganization for spawn onboard and spawn notify register, and on the infra credentials for detached sweeps and spawn sweep setup. Every member-account principal may call it if its IAM allows. docs/reference/cli-iam-actions.md is regenerated.

Tests

  • New tests: pkg/trustboundary unit tests, TestSweepRoleChecksTheOrchestratorsOrganization, the updated fail-closed cases in pkg/aws and cmd (TestSweepRoleRefusesAManagementAccount), TestOnboardRefusesForbiddenAndManagementAccounts, TestCrossAccountTrustWritersCheckTheBoundary, and the template gate with its self-test. Each was watched failing against a revert that compiles.
  • cfn-lint is clean on both templates. The hermetic suite passes, except the space-in-path known failures.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.85714% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/sweep_role.go 20.00% 4 Missing ⚠️
pkg/trustboundary/trustboundary.go 89.47% 4 Missing ⚠️
cmd/bot.go 0.00% 2 Missing ⚠️
cmd/onboard.go 88.88% 1 Missing ⚠️
pkg/aws/sweep_role.go 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…gement account everywhere spawn writes it (#1582, #1583)

Move the forbidden-account list and the management-account rule into
pkg/trustboundary, shared by the sweep role, spawn onboard and spawn notify
register. The check fails closed: an Organizations error refuses, naming
organizations:DescribeOrganization; only AWSOrganizationsNotInUse (proven: in
no organization) passes. The sweep role also checks the orchestrator
account's own organization with the infra credentials.

The cross-account CloudFormation templates carry a Rules assertion refusing
AWS::AccountId = 942542972736, and a CI test fails any cross-account template
without one.
@scttfrdmn
scttfrdmn force-pushed the fix/trust-boundary-1582 branch from f59cfe0 to 9f50a1c Compare November 12, 2026 19:03
@scttfrdmn
scttfrdmn marked this pull request as ready for review November 12, 2026 19:03
@scttfrdmn
scttfrdmn merged commit 3a165a4 into main Nov 12, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/trust-boundary-1582 branch November 12, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant