How a trust policy change makes a privileged AWS role reachable
Assuming an AWS role needs two things, a permission on the caller and a matching trust policy on the target. A one-line trust change can complete a path that was already half built.
Most reviews of AWS access start with permission policies: what can this role do? That is the right question for a role you are looking at, but it misses a second one. Which other identities are allowed to become this role? A role’s permissions can stay exactly the same while the set of identities that can use them changes. The usual cause is a change to the trust policy.
This guide explains how role assumption is authorized, shows how a small trust change can open an indirect path to a sensitive table, and lists the checks you can run by hand.
Two halves of sts:AssumeRole
When a principal calls sts:AssumeRole on a role, AWS looks at two documents.
- The caller’s side. An identity-based policy on the calling role or user allows
sts:AssumeRoleon the target role’s ARN. - The target’s side. The target role’s trust policy (its
AssumeRolePolicyDocument) names the caller as a trusted principal.
How the two combine depends on where the caller lives.
| Case | What is required |
|---|---|
| Caller in a different account | Both: the caller’s policy allows it, and the target’s trust policy trusts the caller |
| Caller in the same account, trust policy names the caller’s ARN | The trust policy is enough on its own |
| Caller in the same account, trust policy names the account root | The caller’s identity policy must also allow it |
Two further controls can only narrow the result: permission boundaries and service control policies (SCPs) can deny an assumption that both documents allow, and explicit denies override allows.
The consequence for review is that the two halves are often written by different people, in different files, at different times. One half can sit in the repository for months as an unused permission. The other half is what turns it into a working path.
Example: a half-built path
In the sample account halvorne-prod, the deploy.yml workflow federates into ci-deploy-role and uses it to publish artifacts to the deploy-artifacts bucket. The role also carries a permission that lets it call sts:AssumeRole on data-maintenance-role:
data "aws_iam_policy_document" "ci_deploy_assume" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
resources = [aws_iam_role.data_maintenance.arn]
}
}
This is the caller’s half. It does nothing today, because data-maintenance-role only trusts ops-maintenance-role. data-maintenance-role can write to the CustomerRecords DynamoDB table with dynamodb:PutItem.
Pull request #187 changes infra/iam/data-access.tf, with the title “Update data maintenance role”:
resource "aws_iam_role" "data_maintenance" {
name = "data-maintenance-role"
assume_role_policy = jsonencode({
Statement = [{
Effect = "Allow"
Action = "sts:AssumeRole"
Principal = { AWS = [
+ aws_iam_role.ci_deploy.arn,
aws_iam_role.ops_maintenance.arn,
] }
}]
})
}
One line is added. The permission policy of data-maintenance-role is untouched, and ci-deploy-role gets no new permission. Yet the pipeline can now reach the table:
deploy.yml
-> ci-deploy-role (OIDC federation)
-> data-maintenance-role (sts:AssumeRole, both halves now present)
-> CustomerRecords (dynamodb:PutItem)
The workflow has no direct permission on the table. The access exists only as a chain, and a reviewer reading the diff sees a trust list getting one entry longer. The plan output is just as quiet: one resource is updated in place.
Why chains hide
Three properties make this kind of path easy to miss.
- The change is on the wrong resource. The risk lands on the role being trusted, but the identity that gains access is somewhere else. Nothing in the diff mentions the pipeline’s purpose.
- The other half is old. The caller’s permission was reviewed when it was added, when it did nothing. Nobody re-reads it when the trust policy changes.
- Chains compose. A federated workflow assumes a role, which assumes a second role, which has the data permission. Each hop looks reasonable alone.
Checking by hand
Start from the target role and work outward.
-
Read the trust policy. List every principal that can assume it, and any conditions.
aws iam get-role --role-name data-maintenance-role \ --query 'Role.AssumeRolePolicyDocument' -
Find who can already call it. Search the other roles’ policies for
sts:AssumeRoleon the target ARN or on a wildcard that covers it. List the inline and attached policies of each candidate, then read them.aws iam list-role-policies --role-name ci-deploy-role aws iam list-attached-role-policies --role-name ci-deploy-role aws iam get-role-policy --role-name ci-deploy-role \ --policy-name ci-deploy-assume -
Find every role that trusts a given identity. This answers the reverse question for the role you are reviewing.
aws iam list-roles \ --query "Roles[?contains(to_string(AssumeRolePolicyDocument), 'ci-deploy-role')].RoleName" -
Walk the chain. Repeat from each role you found until you reach identities you do not need to follow, such as people. Record the result as a chain, not a list of roles.
-
Check the narrowing controls. Look for conditions in the trust policy, a permission boundary on the roles, and SCPs on the account. They can make a path unreachable that the two policies alone would allow.
When a pull request changes a trust policy, ask three questions of every principal added:
- Does it already hold
sts:AssumeRoleon this role, directly or through a wildcard? - What does the target role do, and to which resources?
- Does the principal’s job need that?
Fixing it
If the pipeline has no reason to assume the data role, remove the principal from the trust policy. The change is the reverse of #187: leave aws_iam_role.ci_deploy.arn out of the list. Also consider deleting the unused sts:AssumeRole permission from ci-deploy-role, so that a future trust change cannot complete the path by accident.
If the pipeline does need the role, say so in the pull request and scope the trust. A condition on aws:PrincipalArn, or on the session name, narrows who can use the role even when a broad principal is listed. Do not rely on the permission side alone to keep a role private.
How AccessRoot surfaces it
AccessRoot reads trust relationships and permission policies together, so it can report the chain above on the pull request instead of leaving it for a reviewer to rebuild. For #187, Access Diff reports the path as a critical finding before merge, and Access Graph shows the same path from CustomerRecords backwards. The AWS connection lists what is read to build it. The finding describes what the policies allow, not that the pipeline used the path.