How it works
Every IAM role has two kinds of policy. Permissions policies define what a session of the role may do. The trust policy, also called the assume role policy, is a resource-based policy attached to the role that defines who may obtain such a session through AssumeRole and the other STS operations.
UpdateAssumeRolePolicy replaces the trust policy document of a role. It changes who may enter the role, not what the role may do. A principal that is allowed to call it on a privileged role can add a statement that trusts:
- its own user or role in the same account, which is a direct privilege escalation;
- an external AWS account the attacker owns, which turns the role into a backdoor that works without any credential in the victim account (see cross-account access);
- a service principal, so that a workload the attacker can configure receives the role;
- a federated identity provider, which is covered on the identity provider backdoor page.
AWS evaluates a cross-account request in two places. The role's trust policy must allow the calling principal, and the caller's own account must allow it to call sts:AssumeRole on that role. In the external variant the attacker administers the second account, so the only decision that matters is the trust policy it has just rewritten.
Two details of trust evaluation shape the attack. A trust statement that names an account as principal delegates the choice to that account's administrator: it does not limit the trust to the root user. And IAM stores a role or user ARN in a trust policy as that principal's unique id, so the trust stops working if the named principal is deleted and recreated. Attackers who want durability therefore trust an account, not a single identity.
The call replaces the whole document. A careful operator reads the current trust policy and appends a statement, because dropping the existing principals breaks the workloads that use the role.
Prerequisites
- Valid credentials in the target account.
iam:UpdateAssumeRolePolicyallowed on a role that has more permissions than the caller.iam:*andiam:Update*onResource: "*"include it.- For the same-account variant: the attacker's identity must be allowed to call
sts:AssumeRoleon the role. - For the external variant: an AWS account the attacker controls. No permission in the victim account is needed after the change.
- No service control policy or explicit deny on the trust change, and none that blocks the role's use from outside the organization.
- Useful:
iam:ListRoles,iam:GetRoleandiam:ListAttachedRolePoliciesto choose a role and read its current trust policy. The trust policy document is limited to 2,048 characters by default, which restricts how much can be appended.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Choose a role and read its trust policy
aws iam list-attached-role-policies --role-name org-admin
aws iam get-role --role-name org-admin
get-role returns the current trust policy in AssumeRolePolicyDocument. Roles with AdministratorAccess, IAM write access or access to sensitive data are the targets.
2. Write the new trust policy
Keep the existing statements and add one. This example adds an external account:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "ec2.amazonaws.com" },
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::444455556666:root" },
"Action": "sts:AssumeRole"
}
]
}
For the same-account variant the added principal is the attacker's own identity, for example arn:aws:iam::111122223333:user/alice.
3. Replace the trust policy
aws iam update-assume-role-policy --role-name org-admin \
--policy-document file://trust.json
Pacu's iam__backdoor_assume_role module automates steps 2 and 3 and creates trust relationships between chosen users and roles:
Pacu > run iam__backdoor_assume_role
4. Assume the role
From the trusted identity, in the victim account or in the attacker's own:
aws sts assume-role \
--role-arn arn:aws:iam::111122223333:role/org-admin \
--role-session-name maintenance
The response contains an access key id, a secret access key and a session token. Export them and confirm the session:
export AWS_ACCESS_KEY_ID=<access-key-id>
export AWS_SECRET_ACCESS_KEY=<secret-access-key>
export AWS_SESSION_TOKEN=<session-token>
aws sts get-caller-identity
The attacker repeats step 4 whenever the session expires. Nothing in the victim account has to be touched again.
Impact
The attacker can act as the target role whenever it wants. For a role with administrative permissions that is control of the account. For a role used by a workload, it is that workload's access to data and services.
As a backdoor the change is durable and hard to remove by accident. It does not depend on a user, an access key or a password in the victim account, so credential rotation, user deletion and session revocation leave it in place. Revoking the role's active sessions only forces the attacker to call AssumeRole again. Access ends when the trust policy is restored.
OPSEC and artifacts
- Append, do not replace. Keeping the existing principals means no workload breaks and nobody investigates an outage. The UpdateAssumeRolePolicy event still records the caller, the role in
requestParameters.roleNameand the complete new document inrequestParameters.policyDocument. - A plausible principal. Operators choose an account id that could pass as a vendor or a sibling account, or add a condition such as an external id to make the statement look like a managed integration. A principal outside the organization is still what IAM Access Analyzer reports as external access.
- A quiet role. A role that is rarely assumed, such as a break-glass or legacy migration role, is preferred because nobody watches its sessions. A role that is never used and suddenly issues sessions is its own signal.
- Creating a role instead. An attacker with
iam:CreateRolecan skip the edit and create a new role whose trust policy already names its principal. That is a CreateRole event with the document inrequestParameters.assumeRolePolicyDocument, followed by a policy attachment. - Plain session names. The role session name is chosen by the caller and appears in the ARN of every later event, so it is set to something that resembles automation. It proves nothing about who the caller is.
- What always remains: the IAM management event for the trust change, in the US East (N. Virginia) Region; an
AssumeRoleevent fromsts.amazonaws.comfor every session, with the calling account inuserIdentity.accountIdand the role in the request; and every action of the session logged with the role asuserIdentity.sessionContext.sessionIssuer.arn. For a cross-account assumption, both accounts record the event and share asharedEventID. - What does not appear: a trust statement that has not been used yet produces no session events. Until the first
AssumeRole, the trust change is the only trace.
Detection
- Every trust policy change on a privileged role. Alert on
UpdateAssumeRolePolicyand parserequestParameters.policyDocument. Compare the principals, actions and conditions with the previous document; a formatting change can produce a large text difference with no change in meaning. The role trust policy detection rules cover the event and roles created with a wildcard principal. - New principal outside the organization. Extract account ids from the
AWSprincipals and compare them with the organization's account list and the approved vendor list. A wildcard principal ("AWS": "*") without a restricting condition is always a finding. - First assumption by a new principal. After a trust change, watch for
AssumeRoleon that role from an account or identity that never assumed it before. A session issued before the change cannot have used it. - Self-benefit. The principal added to the trust policy is the identity that made the change, or one created by it shortly before.
- Continuous review. An IAM Access Analyzer external access analyzer reports roles that principals outside its zone of trust can assume. A new active finding for a role is the same signal from the state side, and it also catches backdoors older than the log retention.
-- Athena, CloudTrail table: trust policy changes and the role assumptions that follow
SELECT eventtime, eventsource, eventname,
useridentity.arn AS caller, useridentity.accountid AS caller_account,
coalesce(json_extract_scalar(requestparameters, '$.roleName'),
json_extract_scalar(requestparameters, '$.roleArn')) AS role,
json_extract_scalar(requestparameters, '$.policyDocument') AS new_trust_policy,
sourceipaddress, errorcode, sharedeventid
FROM cloudtrail_logs
WHERE recipientaccountid = '111122223333'
AND eventtime >= '2026-11-28T00:00:00Z'
AND ((eventsource = 'iam.amazonaws.com' AND eventname = 'UpdateAssumeRolePolicy')
OR (eventsource = 'sts.amazonaws.com' AND eventname = 'AssumeRole'
AND useridentity.accountid <> '111122223333'))
ORDER BY eventtime
AWS services and trusted vendors also assume roles from other accounts, so build the allow list of caller accounts from your own baseline before alerting on the second branch.
Mitigation
- Restrict
iam:UpdateAssumeRolePolicyto the identity administration role. Scope it by resource to the role paths a team owns, and keep privileged roles outside those paths. No workload role needs it. - Protect privileged roles with a service control policy that denies
iam:UpdateAssumeRolePolicy,iam:AttachRolePolicyandiam:PutRolePolicyon them for every principal except a named administration role. - Block the backdoor at use time. A service control policy or a resource control policy that denies
sts:AssumeRolewhen the caller is outside the organization (theaws:PrincipalOrgIDcondition key), with exceptions for approved vendors, makes an external principal in a trust policy ineffective. - Run an IAM Access Analyzer external access analyzer with the organization as the zone of trust, and treat a new external access finding on a role as an incident until explained.
- Keep trust policies specific. Name the exact role or service that needs the role, add conditions such as
sts:ExternalIdfor third parties, and avoid account-wide principals where one role would do. See what an AWS principal is and the confused deputy page. - Reduce what there is to take. A trust backdoor is worth as much as the role behind it. Review each over-permissioned IAM role and keep a record of approved trust documents so that a change can be compared with a baseline.
- In incident response, restore the trust policy first, then revoke the role's active sessions. Doing only the second leaves the door open.
Detection rules for this attack
Log events to collect
FAQ
What does a trust policy control, compared with a permissions policy?
The trust policy is the resource-based policy on a role that says who may assume it. The permissions policies say what a session of the role may do. UpdateAssumeRolePolicy changes only the first: the role's power is untouched, but a new principal is let in. That is why reviews of attached policies do not show the change.
Why is this a persistence technique as well as an escalation?
The new trust statement is a standing entitlement. Once an external account the attacker owns is trusted, the attacker can request fresh temporary credentials for the role at any time, with no user, key or password in the victim account. Rotating every credential in the account does not remove it. Only restoring the trust policy does.
Does trusting an account root principal mean only the root user can assume the role?
No. A principal of the form arn:aws:iam::444455556666:root stands for the whole account. Any user or role in that account that its own administrator allows to call sts:AssumeRole on the target can assume it. In an account the attacker owns, that is every identity the attacker chooses.
How do you find a trust policy backdoor that is already in place?
List every role's trust policy and check each principal against the accounts, identity providers and services you expect. IAM Access Analyzer does this continuously: an external access analyzer reports roles that a principal outside its zone of trust can assume. In CloudTrail, look back for UpdateAssumeRolePolicy and for AssumeRole calls from unknown account ids.
References
- UpdateAssumeRolePolicy (AWS IAM API Reference)
- Policy evaluation logic (AWS IAM User Guide)
- assume-role (AWS CLI Command Reference)
- What is IAM Access Analyzer? (AWS IAM User Guide)
- Account Manipulation: Additional Cloud Roles, T1098.003 (MITRE ATT&CK)
- AWS IAM Privilege Escalation: Methods and Mitigation (Rhino Security Labs)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.