6 IAM Policy Conditions That Contain a Leaked AWS Key

A leaked AWS access key can perform any action its IAM user is permitted by the policies attached to that user, so containment starts with the conditions already written into those policies. That is the AWS Identity team’s own description of what an exposed key can do, and it explains why the fix is policy design rather than key hygiene alone. Six IAM policy conditions shrink what a copied key can reach: aws:RequestedRegion and aws:SourceIp pin where it can call from, aws:MultiFactorAuthPresent gates destructive actions, aws:TokenIssueTime kills sessions the key already minted, aws:PrincipalOrgID keeps your resources closed to outsiders, and aws:VpcSourceIp with aws:SourceVpce confines workloads that enter through a VPC endpoint. None of them grants anything; each is a Deny that stays in force after the key leaks. This guide maps every condition to its policy type, the caveat that breaks it and the order to apply when a key is already exposed. It was reviewed on 2 December 2026 against the AWS and Google Cloud pages listed at the end.
The Six Conditions at a Glance
| Condition | Where it lives | What it blocks | Main caveat |
|---|---|---|---|
| aws:RequestedRegion | Identity policy Deny | Calls to Regions you never use | Global services need a NotAction exemption |
| aws:SourceIp | Identity policy Deny | Calls from outside your public address ranges | Breaks automation that has no fixed egress |
| aws:VpcSourceIp and aws:SourceVpce | Identity or resource policy | Calls that do not enter through your VPC endpoint | Only fits workloads routed through the endpoint |
| aws:MultiFactorAuthPresent | Identity policy Deny | Destructive actions made without MFA | A long-term key never passes; automation must use roles |
| aws:TokenIssueTime | Identity policy Deny | Temporary sessions issued before a cut-off | Also cuts legitimate sessions issued earlier |
| aws:PrincipalOrgID | Resource policy Deny | Principals outside your Organization | Requires AWS Organizations; excludes partners |
Read the table as a map of where each Deny belongs. Identity policies travel with the IAM user, so they follow the key wherever it is copied. Resource policies stay with the bucket, key or queue, so they protect the target even when the caller is someone else’s leaked credential.
Pin Region and Network Origin
AWS publishes identity-based policy examples that deny every action outside the Regions listed in aws:RequestedRegion and every request that comes from outside specified IP ranges. Both belong in the identity policy of a user that still holds a long-term key, because that policy is evaluated on every request the key makes.
The region example exempts global services through a NotAction list, and the exemption is not optional: IAM, CloudFront, Route 53 and Support run from a single endpoint physically located in us-east-1, so a region deny without that list would cut them off. List only the Regions your workloads use and the leaked key loses every other geography before anyone touches the key itself.
For a team with fixed egress, the IP example turns the key into something that only works from your network: a NAT gateway with static addresses, a corporate CIDR block or both. The same page notes that requests AWS services make on a principal’s behalf through forward access sessions keep the original requester’s IP address, so the evaluation still reflects your caller rather than an internal AWS address. It also warns you to check when aws:SourceIp may not work in your policy, which is the step most teams skip.
Address pinning splits once traffic enters through interface endpoints. aws:SourceIp only fits public address ranges, so a workload that reaches AWS over a private endpoint needs aws:VpcSourceIp and aws:SourceVpce instead: a Deny with StringNotEquals on the endpoint ID rejects any call that does not arrive through the endpoint you own. The trade-off is operational, because every workload that authenticates as this user must then route through that endpoint or fail closed.
Gate Destructive Actions on MFA
The aws:MultiFactorAuthPresent key is only present when the user authenticates with short-term credentials, and long-term credentials such as access keys do not include the key. That gap is the control: a Deny with a Bool condition on aws:MultiFactorAuthPresent set to false blocks every request that did not arrive through an MFA-authenticated session, so a stolen long-term key cannot pass it regardless of the Allow statements it inherits. Put the Deny on the actions that change trust: creating access keys, writing inline or managed policies, editing a trust policy, deleting a permissions boundary, terminating instances, deleting objects and scheduling KMS key deletion.
Two limits shape the design. Sessions from AssumeRole do not carry MFA information in the request context, so cross-account access has to enforce MFA in the role’s trust policy rather than in each downstream action. And because automation never authenticates with MFA, every workload that legitimately calls these actions must move to a role assumed through OIDC federation or a service-linked role before the Deny goes live; otherwise the gate becomes an outage.
Cut Sessions and Close Side Doors
Rotating the exposed key does not invalidate temporary credentials that were already obtained with it. The AWS guidance is to attach a Deny with a DateLessThan condition on aws:TokenIssueTime set to the moment you learned of the exposure, which cuts every session minted before that time while leaving later sessions alone. Temporary credentials can last up to 36 hours depending on how they were obtained, so keep the Deny in place at least that long and expect legitimate sessions issued before the cut-off to fail as well.
Resource policies need their own guard because a leaked key is usually someone else’s problem until a confused-deputy path lets it reach your bucket. A Deny with StringNotEquals on aws:PrincipalOrgID keeps any principal outside your AWS Organization from using the resource, even when a third-party role would otherwise vouch for the request. It only works once the organization exists and it excludes partners by design, so treat partner access as an explicit exception rather than a gap to patch later.
Find and Revoke Before Hardening
Conditions limit the next leak; they do not clean up the current one. Work the response in this order:
- Deactivate the key instead of deleting it. Disabled credentials can be restored if an unknown workload breaks, which is why AWS recommends this as the first step.
- Attach the
aws:TokenIssueTimeDeny so sessions minted before the exposure stop working. - Pull CloudTrail events for the key’s access key ID and score the IAM write calls it made; the escalation paths and the fields to inspect are covered in 6 CloudTrail Signals of AWS IAM Privilege Escalation.
- IAM Access Analyzer unused access findings include IAM user access keys and passwords that have not been used to access the account within the specified usage window, which shows which other keys on this user are stale enough to remove now. Expect charges for unused access findings, billed per role and user analyzed per analyzer per month.
- Replace the user with a role assumed through federation or OIDC, then delete the key.
- Check what the identity could reach while it existed; the inventory steps in 6 Inventory Checks That Surface Forgotten Storage Buckets cover the storage side.
Trade-offs and Limits
Three constraints decide whether this hardening holds. First, Deny statements only restrict: every condition above needs a least-privilege Allow beneath it, and a user that still holds iam:PutUserPolicy or iam:DetachUserPolicy on itself can remove the Deny, so pair the conditions with a permissions boundary or a service control policy that caps the maximum permissions for the account. Second, conditions are evaluated per request and never undo what already happened, which is why the response order matters more than the policy text. Third, root credentials sit outside all of this: they carry full access to every resource in the account and no IAM policy limits them.
Other clouds follow the same shape with different syntax. Google Cloud IAM Conditions define and enforce conditional, attribute-based access control for Google Cloud resources, written as Common Expression Language expressions evaluated against attributes such as request time, resource name and resource tags, so the per-request gate described here becomes a condition on a role binding rather than a JSON policy block. The practical rule survives the translation: put the gate where the credential is evaluated, test it with a deliberately out-of-policy request and keep an exception path that a human, not a key, can use.
Sources
- AWS Security Blog: What to Do If You Inadvertently Expose an AWS Access Key
- AWS IAM User Guide: Denies access to AWS based on the requested Region
- AWS IAM User Guide: Denies access to AWS based on the source IP
- AWS IAM User Guide: Secure API access with MFA
- AWS IAM User Guide: IAM Access Analyzer findings
- Google Cloud IAM documentation: Overview of IAM Conditions
Reviewed 2 December 2026. The six-condition mapping, the comparison table and the response order are our own synthesis; the condition definitions and quoted behaviors come from the pages above.