PIVTR-D
RAWS playbook · Identity and access

Backdoor roles, keys and trust policies

The attacker adds access that survives rotation of the first stolen credential, such as a new IAM user or a second access key. Other runs add an account the attacker controls to a role trust policy, or register a SAML or OpenID Connect (OIDC) identity provider that a role trusts. Save an IAM snapshot first, then deny each backdoor principal before you delete anything.

Look here

LogSearch for
CloudTrail, IAM users and keysNew users, keys and sign-in methods: CreateUser, CreateAccessKey, CreateLoginProfile, UpdateLoginProfile, CreateServiceSpecificCredential, UploadSSHPublicKey, EnableMFADevice, AddUserToGroup. IAM events land in us-east-1
CloudTrail, roles and trustNew roles and changes to trust and permissions: CreateRole, UpdateAssumeRolePolicy, UpdateRole, AttachRolePolicy, PutRolePolicy, DeleteRolePermissionsBoundary, CreatePolicyVersion, SetDefaultPolicyVersion, AddRoleToInstanceProfile. Read account IDs in requestParameters.policyDocument
CloudTrail, federationNew or changed identity providers: CreateSAMLProvider, UpdateSAMLProvider, CreateOpenIDConnectProvider, AddClientIDToOpenIDConnectProvider, UpdateOpenIDConnectProviderThumbprint. IAM Roles Anywhere: CreateTrustAnchor, UpdateTrustAnchor, CreateProfile
CloudTrail, sso.amazonaws.comPermission sets and assignments added in IAM Identity Center: CreatePermissionSet, PutInlinePolicyToPermissionSet, AttachManagedPolicyToPermissionSet, CreateAccountAssignment, ProvisionPermissionSet, CreateTrustedTokenIssuer. User and group changes come from sso-directory.amazonaws.com and identitystore.amazonaws.com
CloudTrail, resource policiesGrants to principals in other accounts: AddPermission20150331v2 (Lambda AddPermission), PutBucketPolicy, PutKeyPolicy, CreateGrant, Secrets Manager PutResourcePolicy
IAM Access AnalyzerRoles trusted from outside the zone of trust: aws accessanalyzer list-findings-v2 --analyzer-arn <arn> --filter '{"status":{"eq":["ACTIVE"]},"resourceType":{"eq":["AWS::IAM::Role"]}}'
IAM snapshotEvery principal and policy, to compare with your infrastructure-as-code (IaC) state: aws iam get-account-authorization-details > <case>-iam.json
IAM credential reportPassword, key and MFA state of every user. Run aws iam generate-credential-report first, then read it: aws iam get-credential-report --query Content --output text | base64 --decode
GuardDutyFindings for new persistence and privilege changes: Persistence:IAMUser/AnomalousBehavior, PrivilegeEscalation:IAMUser/AnomalousBehavior, AttackSequence:IAM/CompromisedCredentials

Contain

#Item
1Save the IAM snapshot and credential report above before changing any principal. See Evidence
2Deny each backdoor role with an inline deny-all policy, which also applies to live sessions. For a user, run put-user-policy with the same file: aws iam put-role-policy --role-name <role> --policy-name ir-deny-all --policy-document file://deny-all.json
3Deactivate every access key the attacker created: aws iam update-access-key --user-name <user> --access-key-id <access-key-id> --status Inactive
4Restore each changed trust policy: aws iam update-assume-role-policy --role-name <role> --policy-document file://known-good-trust.json
5Revoke sessions issued before now on each role whose trust changed: aws iam put-role-policy --role-name <role> --policy-name AWSRevokeOlderSessions --policy-document file://revoke.json
6Disable a rogue Roles Anywhere trust anchor: aws rolesanywhere disable-trust-anchor --trust-anchor-id <id>
7Deny every role whose trust policy names a rogue SAML or OIDC provider. IAM has no way to disable a provider
8Remove Identity Center assignments the attacker added destructive: aws sso-admin delete-account-assignment --instance-arn <arn> --target-id <account> --target-type AWS_ACCOUNT --permission-set-arn <arn> --principal-type USER --principal-id <id>
9Delete a rogue OIDC provider once the evidence is saved destructive: aws iam delete-open-id-connect-provider --open-id-connect-provider-arn <arn>
10Delete a rogue SAML provider once the evidence is saved destructive: aws iam delete-saml-provider --saml-provider-arn <arn>
11Delete each backdoor role destructive. Detach its policies and remove it from instance profiles first, or the call fails: aws iam delete-role --role-name <role>

Eradicate and recover

#Item
1Diff IAM against the baseline and remove every user, key, inline policy, group membership and trust statement added in the window
2After you set the known-good default on a changed managed policy, delete the attacker's version: aws iam delete-policy-version --policy-arn <arn> --version-id <version>
3Remove Lambda permissions granted to unknown accounts: aws lambda remove-permission --function-name <function> --statement-id <sid>
4Revoke KMS grants made to unknown accounts: aws kms revoke-grant --key-id <key> --grant-id <grant>
5Resolve every active Access Analyzer finding. Archive only access you approved by name
6Rotate the credential that started the incident. See Leaked IAM user access keys
7Add an SCP (service control policy) that denies iam:CreateUser, iam:CreateAccessKey, iam:CreateOpenIDConnectProvider, iam:CreateSAMLProvider and iam:UpdateAssumeRolePolicy to every principal except your admin role
Watch out
  • A managed policy keeps up to five versions. Setting a good default leaves the attacker's version in place for anyone who can call SetDefaultPolicyVersion, so delete it.
  • CloudTrail does not log denied cross-account AssumeRole calls in the target account. After you close a trust, your trail shows no failed attempts from the attacker's account.
  • An external access analyzer treats accounts inside its zone of trust as trusted. A trust added for another compromised member account produces no finding.

AWS documentation: IAM API actions, session revocation, policy versioning and credential reports; IAM Access Analyzer findings, resource types and filter keys; IAM Identity Center and Roles Anywhere API actions; Lambda CloudTrail logging; IAM CloudTrail integration; GuardDuty IAM finding types. Checked September 2026.

Adapts material from Dynamic Incident Response: A Framework for Security Teams by Joshua Wright, © 2026 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute, licensed under CC BY 4.0. Figures reproduced under that license. Changes were made. Not published by, endorsed by, or affiliated with the SANS Institute.