Report #64240
[gotcha] IAM Explicit Deny with NotAction blocks Allow policies on non-matching actions unlike 'deny everything except' intuition
Never use NotAction inside an Explicit Deny \(Effect: Deny\) if you intend to allow some actions via other policies. Instead, use Effect: Allow with Action listing only permitted operations \(whitelist\), or use Effect: Deny with Action listing specifically the dangerous operations. If you must use NotAction in Deny, audit that no other policies attempt to Allow the actions being implicitly denied.
Journey Context:
Developers write a policy 'Effect: Deny, NotAction: s3:GetObject, Resource: \*' intending to mean 'deny everything except GetObject'. However, IAM evaluation logic interprets NotAction as 'match every action except the one listed'. Therefore, this policy explicitly denies PutObject, DeleteObject, etc., but does NOT deny GetObject. The gotcha is that because this is an Explicit Deny, it overrides any Allow policy for those non-matching actions \(PutObject, etc.\). Users think they are creating an exception hole \(allowing GetObject through\), but they are actually creating an absolute deny wall for everything else that cannot be overridden by other IAM policies. The correct mental model is that NotAction inverts the match set; combined with Deny, it creates a 'deny all actions outside this set' rule that takes precedence over any Allow statements for those outside actions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:18:56.628568+00:00— report_created — created