Most AWS IAM policy mistakes that survive review are condition mistakes: a key that is absent for the request you care about, a set operator on the wrong kind of key, or a network condition that silently stops matching when traffic moves to a VPC endpoint. This reference explains the AWS global condition context keys (the aws: prefixed keys available across services) grouped the way AWS groups them: principal, role session, network, resource and request properties. For each group it shows what the key carries, when it is present, and the safe pattern for using it in identity policies, resource policies, service control policies (SCPs) and resource control policies (RCPs). It is written for AWS IAM and platform engineers who already write policies; for policy types and evaluation basics see the AWS IAM Policies and Roles Guide.
This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.
Key takeaways
- Presence is the first question. Many global keys only exist for some requests (for example
aws:SourceVpceonly through a VPC endpoint,aws:MultiFactorAuthPresentonly with temporary credentials), and a missing key changes how every operator behaves. - Network keys depend on the path.
aws:SourceIpis not available when a request arrives through a VPC endpoint, so pair private traffic controls onaws:SourceVpce,aws:SourceVpcoraws:VpcSourceIpinstead. - Service principals need confused deputy keys. Any resource policy that trusts a service principal should be scoped with
aws:SourceArn,aws:SourceAccount,aws:SourceOrgIDoraws:SourceOrgPaths. - Set operators are only for multivalued keys. Use
ForAnyValueandForAllValueswith keys such asaws:TagKeysandaws:PrincipalOrgPaths, add aNullcheck withForAllValues, and never use them on single-valued keys. - The list keeps growing. AWS adds keys regularly (recent additions include
aws:ViaAWSMCPServiceandaws:CalledViaAWSMCPfor AWS MCP servers), so re-check the reference before you design a new guardrail.
How condition keys work
A Condition block compares values in the request context against values in your policy using a condition operator. Global keys are populated by AWS for the request; service-specific keys (such as s3:prefix or ec2:InstanceType) are populated by the service. Four evaluation rules decide almost every outcome.
| Rule | Behaviour | Practical consequence |
|---|---|---|
| Several operators or several keys in one block | AND: all must be true | Each extra key narrows the statement |
| Several values for one key | OR: any value may match | List approved VPC endpoints or accounts in one array |
Several values under a negated operator (StringNotEquals, ArnNotLike) | NOR: true only if none match | The usual pattern for "deny unless from one of these" |
| Key absent from the request | Most operators evaluate to false; negated operators evaluate to true | An absent key can make a Deny with a negated operator fire, or an Allow never match |
Two modifiers handle absence explicitly. IfExists (for example StringNotEqualsIfExists) evaluates the key normally when present and treats the condition as true when absent. Null tests presence itself: "Null": {"aws:TokenIssueTime": "false"} requires the key to exist (in this case, temporary credentials). Use string operators for strings and ARN operators (ArnEquals, ArnLike) for ARN keys; StringEquals and StringLike are case sensitive, and only StringLike, StringNotLike and the ARN operators accept the * and ? wildcards.
Single-valued and multivalued keys
Whether a key is multivalued depends on the request, not on how many values your policy lists. aws:TagKeys is multivalued because one request can carry several tag keys; aws:ResourceTag/tag-key is single-valued because each tag key holds one value. Multivalued keys need a set operator:
- ForAnyValue: true if at least one request value matches a policy value; false if the key is absent.
- ForAllValues: true if every request value matches a policy value, and also true when the key is absent or empty. AWS warns that this can be overly permissive with Allow, and advises always adding
"Null": {"key": "false"}. - Single-valued keys: AWS states plainly not to use
ForAllValuesorForAnyValuewith them, because it can produce overly permissive policies.
Principal keys
Principal keys describe who signed the request. They are the backbone of identity perimeters, attribute-based access control (ABAC) and trust policy hardening.
| Key | Type | Present when | Typical use |
|---|---|---|---|
aws:PrincipalArn | ARN, single | All signed requests | Exempt a break-glass or pipeline role from a Deny; use ArnLike |
aws:PrincipalAccount | String, single | All requests (value anonymous for unsigned) | Restrict a resource policy to named accounts |
aws:PrincipalOrgID | String, single | Principal's account is in an organization | Identity perimeter: only principals from your organization |
aws:PrincipalOrgPaths | String, multivalued | Principal's account is in an organization | Scope to an OU path with ForAnyValue:StringLike |
aws:PrincipalTag/tag-key | String, single | Principal or session has that tag | ABAC, for example match ${aws:PrincipalTag/team} to a resource tag |
aws:PrincipalIsAWSService | Bool, single | All signed requests | Exclude direct service principal calls from network and perimeter Deny statements |
aws:PrincipalServiceName / aws:PrincipalServiceNamesList | String single / multivalued | Direct service principal calls only | Allow or deny a specific service principal |
aws:PrincipalType, aws:userid, aws:username | String, single | aws:username only for IAM users | Per-user resource paths; prefer roles and tags for workloads |
Role session keys sit alongside these and exist only for temporary or federated credentials: aws:MultiFactorAuthPresent, aws:MultiFactorAuthAge, aws:TokenIssueTime, aws:SourceIdentity (set once at AssumeRole and carried through role chaining), aws:FederatedProvider, and aws:Ec2InstanceSourceVpc with aws:Ec2InstanceSourcePrivateIPv4 for instance role credentials. These last two are a useful machine identity control: they let you deny use of an EC2 role's credentials from outside the VPC the instance runs in. For the wider role model see the AWS STS and AssumeRole Guide.
MFA caveat: aws:MultiFactorAuthPresent is not present for requests signed with long-term access keys or for federated identities. AWS's recommended Deny uses "BoolIfExists": {"aws:MultiFactorAuthPresent": "false"}, which blocks non-MFA sessions and access key calls; a plain Bool false check is not reliable.
Network keys
Network keys describe where the request came from. The single most important fact: aws:SourceIp is not available when the request comes through a VPC endpoint, and it only applies to public IP ranges. A policy that allows only your office or NAT egress range by aws:SourceIp stops matching the moment a workload switches to a gateway or interface endpoint.
| Key | Present when | Use it for | Watch for |
|---|---|---|---|
aws:SourceIp | Requests over the public endpoint | Restricting console or API use to known public egress ranges | Absent via VPC endpoints; a calling service (for example CloudFormation) presents its own IP |
aws:SourceVpce | Requests through a VPC endpoint | Pinning a bucket or key to named endpoints (vpce-...) | Sensitive key: AWS states wildcards have no valid use case |
aws:SourceVpc / aws:SourceVpcArn | Requests through a VPC endpoint | Allowing any endpoint in a given VPC | AWS recommends aws:SourceVpcArn where the service supports it |
aws:VpcSourceIp | Requests through a VPC endpoint | Private IP ranges (IPv4 and IPv6) | Always pair with a VPC or endpoint key, because private CIDRs overlap across VPCs |
aws:VpceAccount, aws:VpceOrgID, aws:VpceOrgPaths | Through an endpoint owned by your account or organization, for listed services | "Any endpoint we own" without listing endpoint IDs | Limited service support; aws:VpceOrgPaths is multivalued |
aws:SourceVpce or aws:SourceIp
- Private workloads in a VPC: use
aws:SourceVpce(strictest),aws:SourceVpcArn/aws:SourceVpc, oraws:VpceOrgIDwhen you run many endpoints. - People and on-premises systems on the internet path: use
aws:SourceIpwith your public egress ranges. - Both paths in use: write the Deny so the request must satisfy one or the other, using
IfExistsvariants, and test both paths. - Calls AWS makes for you: forward access sessions (FAS), where a service such as CloudFormation or Athena calls another service with your credentials, do not preserve the original VPC or IP. AWS's pattern adds
"Bool": {"aws:ViaAWSService": "false"}so those calls are exempt, and"BoolIfExists": {"aws:PrincipalIsAWSService": "false"}so direct service principal calls are not blocked by redacted network context.
Network keys are the network leg of a data perimeter; see the AWS Resource Control Policies and Data Perimeter Guide and VPC Endpoints vs NAT Gateways.
Resource keys
| Key | Type | Use | Notes |
|---|---|---|---|
aws:ResourceAccount | String, single | Deny access to resources outside named accounts | Use in Deny statements; not supported for some actions (all Amazon EBS actions and selected EC2, Route 53, EventBridge and other actions) |
aws:ResourceOrgID | String, single | Resource perimeter in SCPs and VPC endpoint policies: only resources in your organization | Can be compared with ${aws:PrincipalOrgID}; same unsupported action list |
aws:ResourceOrgPaths | String, multivalued | Resources in specific OUs | ForAnyValue:StringLike for OU wildcards |
aws:ResourceTag/tag-key | String, single | ABAC on existing resources | Only for services with tag-based authorisation; tag keys are case-insensitive, values case-sensitive |
Resource perimeters stop data being copied to an attacker-owned bucket by a valid principal, a pattern that identity controls alone miss. Because several actions do not populate aws:ResourceAccount and aws:ResourceOrgID, AWS uses aws:CalledVia and aws:ViaAWSService for controlled exceptions; test the SCP against your real workloads before attaching it to production OUs. See the AWS Organizations and SCPs Guide.
Request keys
| Key | Type | Use | Notes |
|---|---|---|---|
aws:SecureTransport | Bool | Deny requests not using TLS (common on S3 bucket policies) | Always present |
aws:RequestedRegion | String | Region guardrails in SCPs | Global services such as IAM call us-east-1, so exempt them with NotAction; the key controls the endpoint, not cross-Region effects such as S3 replication |
aws:RequestTag/tag-key | String, single | Require tags on create | One key per tag pair |
aws:TagKeys | String, multivalued | Allow only approved tag keys | ForAllValues plus a Null false check |
aws:CalledVia, aws:CalledViaFirst, aws:CalledViaLast | Multivalued / single | Allow an action only when a named service makes it with the principal's credentials | Absent for service roles and direct calls; order cannot be enforced with aws:CalledVia |
aws:ViaAWSService | Bool | Exempt FAS calls from network rules | Always present |
aws:CurrentTime, aws:EpochTime | Date | Time-boxed access, expiry of temporary grants | ISO 8601 or epoch values |
aws:ViaAWSMCPService, aws:CalledViaAWSMCP | Bool / String | Restrict what AWS MCP servers do on a principal's behalf, for example deny s3:DeleteBucket via MCP | Newer keys: confirm service support |
aws:referer, aws:UserAgent | String | Content hot-link protection, client hints | Client-supplied and spoofable: AWS warns not to use them as security controls |
Confused deputy keys
When a resource policy trusts a service principal (for example cloudtrail.amazonaws.com on a log bucket) with no condition, the service is authorised for any configuration, including one set up in another customer's account. AWS's guidance is to add one of these keys wherever a service principal is granted access:
- aws:SourceArn: the specific resource the service acts for (a trail, a topic, a fleet). Use ARN operators.
- aws:SourceAccount: the account the service acts for, when the resource ARN is not known in advance.
- aws:SourceOrgID / aws:SourceOrgPaths: any resource in your organization or OU;
aws:SourceOrgPathsis multivalued.
These keys are only present for service principal calls, so central RCPs pair them with "Null": {"aws:SourceAccount": "false"} and aws:PrincipalIsAWSService so ordinary calls are unaffected. The cross-account form of the problem, a third party assuming a role for many customers, is solved with sts:ExternalId in the role trust policy rather than a global key; see How to review AWS cross-account trust policies for confused deputy and the Confused Deputy in AI Agents Guide.
Choosing where to put the condition
| Goal | Keys | Policy type |
|---|---|---|
| Only my organization's principals reach my resources | aws:PrincipalOrgID (with aws:PrincipalIsAWSService exception) | RCP, VPC endpoint policy, resource policy |
| My principals only reach my organization's resources | aws:ResourceOrgID | SCP, VPC endpoint policy |
| Access only from expected networks | aws:SourceIp, aws:SourceVpc, aws:SourceVpce | SCP, with RCP as defence in depth |
| Services act only for my accounts | aws:SourceAccount, aws:SourceOrgID | RCP or resource policy |
| Team-scoped access without per-team policies | aws:PrincipalTag, aws:ResourceTag, aws:RequestTag, aws:TagKeys | Identity policy, permissions boundary |
Small estates with one or two accounts can put conditions directly in bucket and key policies. Larger organizations should express perimeters once in SCPs and RCPs, keep resource policies for resource-specific grants, and treat exceptions (break-glass roles, deployment pipelines) as a short list of aws:PrincipalArn values that is reviewed.
Testing and monitoring
- Model first: write the condition, then run representative requests through the IAM policy simulator, including requests via a VPC endpoint, via a service using FAS, and with long-term keys.
- Validate: use IAM Access Analyzer policy validation and its external access findings to catch overly broad resource policies; see the IAM Access Analyzer Guide.
- Pilot: attach new SCPs or RCPs to a test OU first and watch CloudTrail for
AccessDeniederrors on expected workloads for at least one business cycle. - Roll back: keep the previous policy version; detaching or reverting an SCP is the fastest recovery when a network condition blocks production.
Useful measures: the share of resource policies trusting a service principal that carry a confused deputy key (target 100 percent); the count of ForAllValues statements without a Null check (target zero); the number of approved Deny exceptions by aws:PrincipalArn; and AccessDenied events attributed to perimeter policies after each change.
Common mistakes
- IP allow-lists that break or leak through endpoints: relying on
aws:SourceIpfor workloads that use VPC endpoints, where the key is absent. - ForAllValues without Null: an Allow on
ForAllValues:StringEqualsforaws:TagKeysmatches a request that sends no tags at all. - Set operators on single-valued keys:
ForAnyValue:StringEqualsonaws:SourceVpceoraws:PrincipalTagproduces unintended matches. - Unscoped service principals: bucket, topic or queue policies trusting a service principal without
aws:SourceArnoraws:SourceAccount. - MFA checks that skip access keys: using
Boolinstead ofBoolIfExistsonaws:MultiFactorAuthPresent. - Trusting spoofable headers:
aws:refereroraws:UserAgentused as an access control. For the wider list see Top 10 AWS IAM Mistakes.
Framework mapping
| Framework | Reference | How condition keys support it |
|---|---|---|
| NIST SP 800-53 Rev. 5 | AC-3 Access Enforcement; AC-6 Least Privilege | Conditions narrow when an allowed action can actually be used |
| NIST SP 800-53 Rev. 5 | AC-4 Information Flow Enforcement; AC-16 Security and Privacy Attributes | Network and resource perimeters; tag-based ABAC |
| NIST CSF 2.0 | PR.AA-05 | Access permissions defined in policy and enforced with least privilege |
| MITRE ATT&CK | T1078.004 Cloud Accounts | Network and organization conditions limit where stolen cloud credentials work |
Practitioner checklist
- Inventory every resource policy that trusts a service principal and add
aws:SourceArnoraws:SourceAccount. - Replace
aws:SourceIprules for VPC workloads withaws:SourceVpce,aws:SourceVpcArnoraws:VpceOrgID. - Add
aws:ViaAWSServiceandaws:PrincipalIsAWSServiceexceptions to network Deny statements, and test FAS paths. - Search policies for
ForAllValueswithout aNullfalse check and for set operators on single-valued keys. - Enforce MFA with
BoolIfExistsonaws:MultiFactorAuthPresent. - Deploy identity and resource perimeters with
aws:PrincipalOrgIDandaws:ResourceOrgIDin RCPs and SCPs, piloted on a test OU. - Bind EC2 role credentials to their VPC with
aws:Ec2InstanceSourceVpcwhere workloads allow. - Review the global condition keys reference each quarter for new keys, including the MCP-related keys.
Standards and references
- AWS: AWS global condition context keys
- AWS: IAM JSON policy elements, condition operators
- AWS: Single-valued vs multivalued context keys
- AWS: Condition logic for multiple context keys or values
- AWS: The confused deputy problem
- AWS: Building a data perimeter on AWS, perimeter implementation
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
Related NHI Mgmt Group resources: AWS IAM Policies and Roles Guide · AWS Resource Control Policies and Data Perimeter Guide · AWS IAM Permissions Boundaries Guide · Top 10 AWS IAM Mistakes