Skip to content

LearnCloud

AWS IAM policy evaluation logic

Brief

AWS decides every request the same way: an explicit deny anywhere ends it, and otherwise each policy type that applies has to allow it, with a resource policy able to grant on its own inside one account. The simulator shows each rule on documents passed on the command line and attached to nothing, so the logic behind a finding is checked before the finding relies on it.

Track
Cloud
Stage
Escalation
Reviewed
On this page
  1. Check first
  2. AWS
  3. The defender sees
  4. Done when
  5. Not covered
  6. Tools
  7. Related research
  8. Where this page fits
  9. Reviewed

All commands

AWS book Chapter 3 of AWS Identity and Secrets, "IAM policy evaluation", goes further than this page.

Situation
Any identity the scope letter names that holds iam:SimulateCustomPolicy and iam:SimulatePrincipalPolicy, usually the read-only review role, plus the policy documents a finding depends on. simulate-custom-policy evaluates documents passed on the command line without attaching them, and simulate-principal-policy reads a principal's real policies; neither changes anything. The calls that are not simulations, two assume-role calls with a session policy and two S3 requests made with the narrowed session, create sessions that expire on their own after 15 minutes, print no credentials and are made only where the letter permits them. Every account read is one the scope letter names.
Goal
For each permission a finding rests on, the decision AWS reaches and the policy type that decides it, shown by a simulation or a session rather than asserted.
Outputs
Captured on 8 Nov 2026 (UTC) in the Atarus lab AWS Organization from the Atarus Bench edition 2026.11-cloud-0.3, AWS CLI 2.39.3, with account ids and other identifiers replaced by stable placeholders. Every step on this page is captured, run with the lab's ci-deploy key, the key the escalation pages follow, whose own policy may assume ops-break-glass. boundary-demo and ops-break-glass are the lab's seeded user and role, and the guardrail SCP is the lab Organization's own, whose DenyEmailSending statement denies ses:*.

Check first

  • Whether the account is in an organization, and whether the review identity can read the SCPs and resource control policies (the organization's caps on what can be done to its resources) above it, from the SCP review.
  • The principal's identity policies, groups and permissions boundary, from the cloud first hour.
  • The resource policy, if the finding involves a bucket, key, queue, topic, secret or role trust, and which account owns the resource.
  • A scratch directory for the fixture documents, outside any repository, removed at the end.

Steps

AWS

What decides a request that no policy mentions?

cat > allow-s3-read.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:ListBucket"],"Resource":"*"}]}
EOF
aws iam simulate-custom-policy --policy-input-list "$(cat allow-s3-read.json)" \
  --action-names s3:GetObject s3:PutObject --resource-arns arn:aws:s3:::example-exports/report.csv \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output text

Expected output

s3:GetObject	allowed
s3:PutObject	implicitDeny   # <- nothing allows it, so the default deny holds

Every request starts denied. An allow in a policy that applies flips it to allowed, and a request no statement mentions stays denied without any deny being written. implicitDeny is the simulator's name for that default; explicitDeny means a statement said Deny. The difference matters in a finding: an implicit deny is removed by any new allow, an explicit one is not.

A simulation tests each action against the resources named in --resource-arns, and against * when none is named. A grant written for named resources never matches *, so a simulation that names no resource prints implicitDeny for it, and that answer says only that nothing grants the action on every resource. Before a finding is dropped, its actions are simulated against the resources it names, as every simulation on this page is except the two on boundary-demo, whose grant is on *.

The list parameters take each document as a string, "$(cat allow-s3-read.json)"; handed file://allow-s3-read.json instead, AWS CLI v2 refuses the list item as invalid, which reads like a broken policy when the document is fine. The single-document parameters, --resource-policy and --policy further down, take file:// as usual.

Negative result. Not a negative in the usual sense: an action the finding needs that comes back implicitDeny from the principal's real policies, simulated against the resources the finding names, means the path is not there, and the finding is dropped.

Fix. Grant actions by name on named resources, so the default deny covers everything else without anyone writing a deny.

Does an explicit deny beat an allow?

cat > deny-exports.json <<EOF
{"Version":"2012-10-17","Statement":[{"Effect":"Deny","Action":"s3:*","Resource":"arn:aws:s3:::example-exports/*"}]}
EOF
aws iam simulate-custom-policy --policy-input-list "$(cat allow-s3-read.json)" "$(cat deny-exports.json)" \
  --action-names s3:GetObject --resource-arns arn:aws:s3:::example-exports/report.csv \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision,MatchedStatements[].SourcePolicyId]' --output text

Expected output

s3:GetObject	explicitDeny
PolicyInputList.2   # <- the second document's Deny wins, whatever order they come in

A Deny statement that matches the request ends the evaluation, whichever policy type holds it: an identity policy, a resource policy, a boundary, a session policy, an SCP or a resource control policy. Order on the command line and order in the account mean nothing. SourcePolicyId names the document by its place in the input list, which is how the finding points at the statement at fault. MatchedStatements is a list, so text output prints it on its own line under the decision, one id for each statement that determined the result. The first document's allow matches the request too and is not listed, because the Deny alone decided.

Why this works

AWS reads every policy that applies, looks for a matching Deny first, then for the allows each policy type has to give. The simulator follows the same order, which is why it can name the one statement that decided.

Negative result. The deny the client relies on comes back allowed: it does not match the action or resource as written, often a bucket ARN where the object ARN was meant.

Fix. Write guardrail denies against the exact ARN form the action uses, and test them with the simulator in the pipeline that deploys them.

How does a permissions boundary cap an identity policy?

cat > allow-all-s3.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"*"}]}
EOF
cat > boundary-read-only.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:Get*","s3:List*"],"Resource":"*"}]}
EOF
aws iam simulate-custom-policy --policy-input-list "$(cat allow-all-s3.json)" \
  --permissions-boundary-policy-input-list "$(cat boundary-read-only.json)" \
  --action-names s3:GetObject s3:PutObject s3:DeleteBucket --resource-arns arn:aws:s3:::example-exports/report.csv \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision,PermissionsBoundaryDecisionDetail.AllowedByPermissionsBoundary]' --output text

Expected output

s3:GetObject	allowed	True
s3:PutObject	implicitDeny	False   # <- s3:* in the identity policy, but the boundary never allowed a write
s3:DeleteBucket	implicitDeny	False

The same rule on a real principal: boundary-demo has AdministratorAccess attached and the read-only boundary set, and simulate-principal-policy reads both from the account.

aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:user/boundary-demo \
  --action-names s3:GetObject s3:PutObject iam:CreateUser \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision,PermissionsBoundaryDecisionDetail.AllowedByPermissionsBoundary]' --output text

Expected output

s3:GetObject	allowed	True
s3:PutObject	implicitDeny	False
iam:CreateUser	implicitDeny	False   # <- AdministratorAccess attached, and the boundary still caps it

A boundary grants nothing. The principal gets only what both its identity policies and its boundary allow, which is why a user with AdministratorAccess and a read-only boundary can read and nothing more. The last column says the boundary is the reason. One exception matters in findings: inside one account, a resource policy that names an IAM user's ARN directly is not limited by an implicit deny in that user's boundary, while one that names a role's ARN is. A boundary is a cap on identity policies, not a wall around the principal.

Negative result. True in the last column for an action the boundary was meant to exclude: the boundary is wider than its name says.

Fix. Require a boundary on every principal that creates principals, through the iam:PermissionsBoundary condition key, so delegated administrators cannot create anything stronger than themselves.

When does a resource policy grant access on its own?

cat > caller-sts-only.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"sts:GetCallerIdentity","Resource":"*"}]}
EOF
cat > bucket-policy.json <<EOF
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::111122223333:user/ci-deploy"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::example-exports/*"}]}
EOF
aws iam simulate-custom-policy --policy-input-list "$(cat caller-sts-only.json)" \
  --resource-policy file://bucket-policy.json --resource-owner arn:aws:iam::111122223333:root \
  --caller-arn arn:aws:iam::111122223333:user/ci-deploy \
  --action-names s3:GetObject --resource-arns arn:aws:s3:::example-exports/report.csv \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output text

Expected output

s3:GetObject	allowed   # <- no identity policy grants it; the bucket policy alone does

Inside one account, either side can allow: a resource policy that names the principal is enough without any identity grant. Across accounts both sides have to allow, so the same bucket policy naming a principal in another account does nothing until that account's identity policy grants the action too. Two resource types break the same-account rule. A KMS key policy must allow use of the key, directly or by delegating to IAM through the account root, and a role's trust policy must allow sts:AssumeRole. The simulator takes one resource policy at a time with a --caller-arn, and it does not simulate resource policies for IAM roles or assumed-role sessions, so role-based paths are checked with simulate-principal-policy and the trust policy read beside it, as on the trust policy review.

Negative result. implicitDeny here, with the bucket policy naming the caller: --resource-arns or --resource-owner does not match the bucket the policy is written for, and the policy grants nothing.

Fix. Treat resource policies as grants in their own right and review them with the identity policies; the resource policy review lists where they live.

Where do service control policies come in?

aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:user/boundary-demo \
  --action-names ses:SendEmail ec2:RunInstances \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision,OrganizationsDecisionDetail.AllowedByOrganizations]' --output text

Expected output

ses:SendEmail	explicitDeny	False   # <- an explicit deny in the SCP decides it, whatever the identity policies allow
ec2:RunInstances	implicitDeny	True

SCPs set the most any principal in a member account can have, including the account's administrators; they grant nothing either. simulate-principal-policy includes the SCPs that apply to the principal's account and reports them in OrganizationsDecisionDetail, so False there means no identity change in this account can open the action. The lab guardrail's DenyEmailSending statement denies ses:*, so SES is refused to every principal in the account, administrators included. ec2:RunInstances is the other case: True says the organization allows it, so the SCP is not the reason for the implicitDeny; the read-only boundary from the step above is, since it allows S3 reads and nothing else. simulate-custom-policy, run as on this page with only the documents passed to it, applies no SCP. Resource control policies cap what can be done to resources in member accounts, from inside or outside the organization; we read them separately from the management account with aws organizations list-policies --filter RESOURCE_CONTROL_POLICY rather than rely on the simulator for them.

Negative result. True for every action, in an organization that says it has a region or service guardrail: the guardrail is not attached where the client thinks.

Fix. Attach guardrail SCPs to the organizational units that hold workloads, and test each one with the simulator against a principal in every unit it should cover.

How does a session policy narrow a role session?

cat > session-s3-list.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:ListBucket","Resource":"*"}]}
EOF
aws sts assume-role --role-arn arn:aws:iam::111122223333:role/ops-break-glass --role-session-name atarus-session-policy \
  --policy file://session-s3-list.json --duration-seconds 900 --query '{session:AssumedRoleUser.Arn,packedPolicyPercent:PackedPolicySize}'

Expected output

{
    "session": "arn:aws:sts::111122223333:assumed-role/ops-break-glass/atarus-session-policy",
    "packedPolicyPercent": 19   # <- the session policy was accepted; this session can list objects and nothing more
}

A session policy passed at assume-role narrows that one session to what both the role's policies and the session policy allow; it can never widen it. That is how identity brokers, CI systems and IAM Identity Center hand out less than a role holds, and why a principal can simulate as allowed while its live session is denied. The simulator does not model session policies, so the evidence is the session's own refusal or the policy field in the AssumeRole event. The query prints the session ARN and the packed size, never the credentials, and --duration-seconds 900 keeps the session to the 15-minute minimum. PackedPolicySize is the share of the session's size limit the session policy and tags take up: 19 percent for this one statement, and a request over 100 fails.

The refusal is the proof. A second session under the same policy makes two requests to the exports bucket, and the last line removes the fixture documents:

set -- $(aws sts assume-role --role-arn arn:aws:iam::111122223333:role/ops-break-glass --role-session-name atarus-narrowing-proof \
  --policy file://session-s3-list.json --duration-seconds 900 \
  --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --output text)
if [ "$#" -eq 3 ]; then
  AWS_ACCESS_KEY_ID=$1 AWS_SECRET_ACCESS_KEY=$2 AWS_SESSION_TOKEN=$3 \
    aws s3api list-objects-v2 --bucket example-exports --query 'length(Contents[])' --output text
  AWS_ACCESS_KEY_ID=$1 AWS_SECRET_ACCESS_KEY=$2 AWS_SESSION_TOKEN=$3 \
    aws s3api head-object --bucket example-exports --key export-2026-01.csv --query 'ContentLength'
else
  echo "no session: the assume-role above was refused" >&2
fi
rm -f allow-s3-read.json deny-exports.json allow-all-s3.json boundary-read-only.json caller-sts-only.json bucket-policy.json session-s3-list.json && echo removed

Expected output

7   # <- the narrowed session lists the bucket: seven objects, counted, not named

aws: [ERROR]: An error occurred (403) when calling the HeadObject operation: Forbidden   # <- and is refused a read the role itself holds
removed

set -- puts the session's three credential values into the shell's positional parameters, so they are never printed or written to a file, and each request uses them for one command. The listing works because s3:ListBucket is in both the role's policies and the session policy, and the query prints only the object count. The head is refused: the role's ReadOnlyAccess allows s3:GetObject and the session policy does not. The if stops both requests when no session came back, since with the variables empty the CLI would fall back to the profile's own key and test the wrong identity. The last line removes every fixture document this page wrote; nothing was ever attached to a principal.

Negative result. No session policy where the client's design says one is used: the broker hands out the whole role.

Fix. Pass a session policy or session tags from every broker that issues role sessions, and alert on AssumeRole calls to break-glass roles outside an incident.

The defender sees

SimulateCustomPolicy and SimulatePrincipalPolicy are IAM management events, recorded in us-east-1 whatever region the CLI is set to, with the action names and the principal in the request parameters; the documents passed to the custom simulator are not attached anywhere and leave no other trace. A run of simulations from a CI key or an application role is worth an alert, since workloads do not ask what they may do. Each AssumeRole call lands in CloudTrail with the role session name and the session policy in its request parameters, which is how a defender tells our narrowed sessions from an ordinary use of the break-glass role. The two S3 requests are data events, recorded only where the trail logs them. Nothing else on this page reaches the account. The full view of a test's events is on the CloudTrail and GuardDuty evidence review.

Done when

The finding's key actions are simulated with the real principal, the deciding policy type (identity, deny, boundary, SCP, resource or session) is named for each, and every local fixture document is removed.

Not covered

Finding the escalation paths themselves (see AWS IAM privilege escalation checks), condition keys in depth, and the policy languages of Azure and Google Cloud.