AWS cross-account role trust policy review
Brief
A role trust policy is a resource policy that says who may become the role, and a loose one hands the role to another account, to every repository in a CI organization or to anyone in the account with sts:AssumeRole. The review reads every trust policy by name, classifies each principal and condition, and confirms one chain with a read that prints a session ARN and nothing else.
On this page
- Situation
- A read-only review role in each account in scope with
SecurityAudit, or the CI deploy identity the client gave us for the test, plus the account ids of the client's organization, vendors and identity provider. Every command here reads roles, providers and simulation results. The one assume-role step runs only against a role the client named for the test, in an account the scope letter names, and prints the session ARN and expiry, never the credentials. Where the escalation page tests one principal, this page reviews every role. - Goal
- A trust map: every role, the principals and conditions that may assume it, and each chain from an identity we hold to a role with more, with the statement that allows it.
- Outputs
- Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.
Check first
- The account ids of the client's organization, vendors and identity provider: any other id in a trust policy is a leak.
- The identity we hold and its policies, from the first hour.
- The role the client named for the dry read, in writing.
- The organization id, which
aws:PrincipalOrgIDconditions are checked against. - Where CloudTrail is delivered, to match the dry read to its event.
Steps
AWS
Which roles exist, and what does each one trust?
aws iam get-account-authorization-details --filter Role \
--query 'RoleDetailList[].[RoleName,CreateDate,RoleLastUsed.LastUsedDate]' --output text
aws iam get-account-authorization-details --filter Role \
--query 'RoleDetailList[].[RoleName,AssumeRolePolicyDocument.Statement[].Principal]' > roles-trust.json
aws iam get-role --role-name vendor-monitoring --query 'Role.AssumeRolePolicyDocument'
Expected output
$ aws iam get-account-authorization-details --filter Role --query ... --output text
app-deploy-role 2024-11-05T09:40:13+00:00 2026-10-28T06:12:40+00:00
gh-deploy 2025-03-02T08:15:27+00:00 2026-10-28T07:51:02+00:00
legacy-sync 2022-06-30T16:44:09+00:00 None
ops-audit 2023-02-14T11:02:51+00:00 None # <- never assumed, still trusts whatever it trusted in 2023
vendor-monitoring 2025-07-19T14:02:08+00:00 2026-10-27T23:00:04+00:00
$ aws iam get-role --role-name vendor-monitoring --query 'Role.AssumeRolePolicyDocument'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::444455556666:root" # <- another account; the condition block decides how safe this is
},
"Action": "sts:AssumeRole"
}
]
}
The dates come from the authorization details dump, since ListRoles does not return RoleLastUsed; the dump also holds every trust policy decoded. A principal is AWS (an account, user or role ARN, or *), Service, or Federated (an OIDC or SAML provider). A role never used and a trust policy never reviewed usually arrive together.
Negative result. Every role was used this quarter or has a documented owner, and every principal is one the client can name.
Fix. Delete roles with no use and no owner after confirming with their creators; Access Analyzer UnusedIAMRole findings list the same roles.
Which trusts are open: wildcards, roots, missing external ids, deleted principals?
jq -c '.[] | {role: .[0], principals: .[1]}' roles-trust.json
aws iam get-role --role-name ops-audit \
--query 'Role.AssumeRolePolicyDocument.Statement[].[Principal.AWS,Action,Condition]'
Expected output
$ jq -c ... roles-trust.json
{"role":"app-deploy-role","principals":[{"Service":"lambda.amazonaws.com"}]}
{"role":"gh-deploy","principals":[{"Federated":"arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"}]}
{"role":"legacy-sync","principals":[{"AWS":"AROADBQP57FF2AEXAMPLE"}]} # <- a deleted role's unique id: nothing can match it now
{"role":"ops-audit","principals":[{"AWS":"*"}]} # <- every AWS account, unless a condition narrows it
{"role":"vendor-monitoring","principals":[{"AWS":"arn:aws:iam::444455556666:root"}]}
$ aws iam get-role --role-name ops-audit --query ...
[
[
"*",
"sts:AssumeRole",
{
"StringEquals": {
"aws:PrincipalOrgID": "o-a1b2c3d4e5" # <- narrowed to the organization; confirm the id is the client's
}
}
]
]
An unconditioned * is open to every AWS account; with aws:PrincipalOrgID it is open to that whole organization, fine only if the id is the client's. An account root defers to identity policies in that account: anyone there allowed sts:AssumeRole on the role gets it, and for a vendor's account only sts:ExternalId stops a second customer pointing the vendor's role at this one. A named ARN is the narrow form and in the same account needs no identity policy permission. A unique id beginning AROA or AIDA is a deleted principal: IAM rewrites the ARN on deletion so a namesake does not inherit the trust, and the statement grants nothing today.
Negative result. No unconditioned *, every outside account root paired with sts:ExternalId or aws:PrincipalArn, and no unique ids in any policy.
Fix. Trust named role ARNs rather than account roots, require sts:ExternalId on every vendor trust and aws:PrincipalOrgID on internal ones, delete statements that hold unique ids, alert on UpdateAssumeRolePolicy as the persistence audit shows, and read Access Analyzer ExternalAccess findings for anything assumable from outside the zone of trust.
What do the federated and service trusts let in?
aws iam list-open-id-connect-providers --query 'OpenIDConnectProviderList[].Arn' --output text
aws iam get-open-id-connect-provider \
--open-id-connect-provider-arn arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com \
--query '[Url,ClientIDList]'
aws iam get-role --role-name gh-deploy --query 'Role.AssumeRolePolicyDocument.Statement[].[Action,Condition]'
aws iam list-saml-providers --query 'SAMLProviderList[].Arn' --output text
aws iam get-role --role-name app-deploy-role \
--query 'Role.AssumeRolePolicyDocument.Statement[].[Principal.Service,Condition]'
Expected output
$ aws iam get-role --role-name gh-deploy --query ...
[
[
"sts:AssumeRoleWithWebIdentity",
{
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:example-org/*" # <- any repository in the organization, any branch, any pull request workflow
}
}
]
]
$ aws iam list-saml-providers --query ... --output text
arn:aws:iam::111122223333:saml-provider/corp-idp
$ aws iam get-role --role-name app-deploy-role --query ...
[
[
"lambda.amazonaws.com",
null # <- no aws:SourceArn or aws:SourceAccount: any function in this account whose creator can pass this role
]
]
A federated trust is only as narrow as its conditions. For OIDC, a sub of repo:example-org/* lets every repository the organization owns mint credentials for the role, and a missing aud lets in a token issued for another audience. A SAML trust without SAML:aud leaves who gets the role to the identity provider's attribute mapping. lambda.amazonaws.com is every Lambda function; only aws:SourceArn or aws:SourceAccount ties the trust to the functions meant to use it, and who can pass the role is the escalation page's second question.
Negative result. Every OIDC trust pins sub to a repository, environment or branch and the right aud; every SAML trust carries SAML:aud; every service trust carries a source condition where the service supports one.
Fix. Pin sub to repo:example-org/payments:environment:prod or repo:example-org/payments:ref:refs/heads/main, one role per repository and environment. Add SAML:aud to SAML trusts, source conditions to service trusts, and sts:RoleSessionName and sts:SourceIdentity conditions so a federated session names the person or job behind it.
Can the CI identity chain into a second role?
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:user/ci-deploy \
--action-names sts:AssumeRole \
--resource-arns arn:aws:iam::111122223333:role/ops-audit arn:aws:iam::111122223333:role/vendor-monitoring \
--query 'EvaluationResults[].ResourceSpecificResults[].[EvalResourceName,EvalResourceDecision]' --output text
aws sts assume-role --role-arn arn:aws:iam::111122223333:role/ops-audit \
--role-session-name atarus-trust-review \
--query '{session:AssumedRoleUser.Arn,expires:Credentials.Expiration}'
Expected output
$ aws iam simulate-principal-policy ... --output text
arn:aws:iam::111122223333:role/ops-audit allowed # <- the trust says the organization; the identity policy says ops-*; the chain exists
arn:aws:iam::111122223333:role/vendor-monitoring implicitDeny # <- outside the ops-* pattern, refused before the vendor's trust is asked
$ aws sts assume-role ... --query '{session:AssumedRoleUser.Arn,expires:Credentials.Expiration}'
{
"session": "arn:aws:sts::111122223333:assumed-role/ops-audit/atarus-trust-review", # <- assumed; credentials not printed
"expires": "2026-10-29T16:04:11+00:00"
}
A chain has two halves: the target's trust policy must allow the caller, and unless it names the caller's ARN, the caller's identity policy must allow sts:AssumeRole on that role. The simulator answers the second half for every candidate role in one call; the first we read from the trust map. With several roles named, the call returns one result per action. Its top-level EvalDecision is the most restrictive of the roles, and its EvalResourceName is a template rather than either ARN, so the query reads each role's own answer from ResourceSpecificResults. ci-deploy reaches ops-audit because the trust is open to the organization and the deploy policy allows sts:AssumeRole on arn:aws:iam::111122223333:role/ops-*. The dry read is one assume-role as on the escalation page, with --source-identity where the trust allows it: session ARN and expiry printed, credentials dropped by the query and never written anywhere.
Negative result. implicitDeny on every role the identity is not meant to hold, and no trust so wide that the identity policy alone decides.
Fix. Trust the deploy identity by ARN on the one role it needs, grant it sts:AssumeRole on that ARN rather than a pattern, and require sts:SourceIdentity on roles people and pipelines assume so the chain is readable in CloudTrail.
What goes in the evidence table?
role: ops-audit (arn:aws:iam::111122223333:role/ops-audit)
trust statement: Principal AWS "*", Condition StringEquals aws:PrincipalOrgID o-a1b2c3d4e5
reached from: user/ci-deploy, via identity policy ci-deploy-policy statement 2 (sts:AssumeRole on role/ops-*)
simulation: sts:AssumeRole allowed, 2026-10-29T15:02Z
dry read: AssumeRole event 5b2e9c41-7d3a-4f60-9e18-c2a4d6f0b937, session atarus-trust-review, expires 16:04Z
what the role holds: SecurityAudit plus s3:GetObject on the exports bucket
One row per chain and one per open trust with no chain yet: the role ARN, the trust statement, the policy statement on our side, the simulator's decision and time, the dry read's event id, and what the role can do once held, which decides the severity. Statements go in the appendix as returned.
Negative result. Rows for every role, and no row with a chain.
Fix. The client's fix list is the reached from line of each row: every identity policy and trust statement named, to be changed and shown to the retest.
The defender sees
Every call is in CloudTrail under our identity. The IAM reads, GetAccountAuthorizationDetails, GetRole, ListOpenIDConnectProviders, GetOpenIDConnectProvider, ListSAMLProviders and SimulatePrincipalPolicy, land in us-east-1 whatever the CLI region; AssumeRole lands in the region of the STS endpoint the CLI used, which for CLI v2 is the configured region unless sts_regional_endpoints is legacy. A CI key calling GetAccountAuthorizationDetails or the simulator is itself worth an alert: pipelines do not ask what roles exist.
The dry read is one AssumeRole event with eventSource sts.amazonaws.com: roleArn, roleSessionName, externalId and sourceIdentity in its request parameters where sent, the CI user as userIdentity, and the session's temporary key id in the response, carried by every later call of that session with sessionContext.sessionIssuer naming the role. Where a trust crosses accounts, the event is written in both. GuardDuty raises nothing for an AssumeRole the trust allows; Discovery:IAMUser/AnomalousBehavior may follow the enumeration if the identity has never listed roles. A session with no source identity leaves the defender a role name, an account id and no person, which is a finding beside the trust.
Done when
Every role's trust policy is read and classified, each cross-account, wildcard, federated and service trust is marked with its conditions or their absence, each chain from the CI identity is simulated, one is confirmed with a dry read, and the evidence row for each is written.
Not covered
Identity policy escalation paths (see IAM privilege escalation checks), the pipeline side of OIDC trust (see CI pipeline secrets and OIDC trust review), IAM Identity Center permission sets and Cognito identity pools; the outputs shown are representative examples on placeholder accounts, not captured runs.