---
title: "IamGuard drops Deny statements whose condition…"
description: "GHSA-rv7g-r6hp-xprf: IamGuard drops Deny statements whose condition cannot be evaluated… Affected and fixed versions of qwed-infra."
url: https://qwedai.tech/security/advisories/ghsa-rv7g-r6hp-xprf
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-rv7g-r6hp-xprf

# IamGuard drops Deny statements whose condition cannot be evaluated (unimplemented operator, absent key on a negated operator, unparsed date), reporting forbidden access as allowed and VERIFIED

high Fixed in 0.4.0 GHSA-rv7g-r6hp-xprf · Published 13 November 2026

## Summary

`IamGuard._evaluate_operator` implements five condition operators (`StringEquals`, `StringLike`, `IpAddress`, `NotIpAddress`, `DateLessThan`). For any other operator it returns `False`, with the comment "fail closed (deny access)". That is fail-closed for an **Allow** statement but fail-open for a **Deny**: a Deny whose condition evaluates to `False` does not apply. So a policy with a broad Allow and a conditional Deny using an unimplemented operator is reported as **allowed**, with `verified=True`, and the guard mints its proof-bearing allow result.

Common AWS Deny patterns are affected, for example `Bool` on `aws:SecureTransport`, `StringNotEquals` on `aws:PrincipalOrgID` or `aws:RequestedRegion`, `ArnEquals` / `ArnLike` on `aws:PrincipalArn`, `NumericGreaterThan`, and the `...IfExists` and `ForAnyValue:` / `ForAllValues:` forms.

This is related to GHSA-qjhf-xg26-439q (wildcard and condition-key matching that also drops Denies) but has a different root cause. The two may be merged before publishing.

## Affected components

| Component | Location |
| --- | --- |
| `IamGuard._evaluate_operator` | `qwed_infra/guards/iam_guard.py` L149-165 |
| `IamGuard.verify_access` and the Verification Context / attestation built from it | `qwed_infra/guards/iam_guard.py` |

## Root cause

A single "condition not satisfied" value (`False`) is used for two different meanings: "the request does not meet this condition" and "this operator is not understood". For an Allow both mean "do not grant". For a Deny the second should mean "cannot decide", but it becomes "the Deny does not apply".

## Proof of concept (local, synthetic)

```python
from qwed_infra.guards.iam_guard import IamGuard

g = IamGuard()
allow_all = {"Effect": "Allow", "Action": "s3:*", "Resource": "*"}
deny_insecure = {"Effect": "Deny", "Action": "s3:GetObject", "Resource": "*",
                 "Condition": {"Bool": {"aws:SecureTransport": "false"}}}
r = g.verify_access({"Statement": [allow_all, deny_insecure]},
                    "s3:GetObject", "arn:aws:s3:::b/k", {"aws:SecureTransport": "false"})
print(r.verified, r.allowed)   # True True   (AWS would deny this request)
```

Run against `qwed-infra` **0.3.0**: `StringEquals` (implemented) gives `allowed=False`; `ArnEquals`, `StringNotEquals` and `Bool` (not implemented) each give `verified=True, allowed=True`. `main` @ `b3098be` has the same code.

## Impact

Integrity of IAM policy verification. A pipeline that uses IamGuard to confirm that a sensitive action is denied before applying a policy will be told the action is allowed, or, in the reverse check, that a guard-rail Deny is not needed. When the caller is asking "is this request denied?", it receives a verified answer that is wrong. Attacker capability: authoring or influencing the policy document, for example IaC generated by a model. No credentials are needed.

## Affected versions

-   Confirmed at runtime: **0.3.0**. `main` @ `b3098be` is unchanged.
-   Code history: the `return False` for unknown operators was added in `42e5fe2` (first released in v0.2.0). v0.1.0 used a different inline operator chain and was not tested, so the range `<= 0.3.0` is to be confirmed for 0.1.0 before publishing.

## Remediation (what to fix)

1.  Return a third state for an unknown or unimplemented operator (and for unknown qualifiers such as `IfExists`, `ForAnyValue:` and `ForAllValues:`), and make `verify_access` return `UNVERIFIABLE` (`verified=False`) for the whole decision when any statement that could match the request has an unsupported condition. Never mint a proof-bearing allow in that case.
2.  Implement the operators that common Deny guard-rails use: `Bool`, `StringNotEquals`, `StringEqualsIgnoreCase`, `ArnEquals`/`ArnLike`/`ArnNotEquals`/`ArnNotLike`, the `Numeric*` and `Date*` families, `Null`, and the `IfExists` suffix.
3.  Fail closed for unknown condition keys the same way (see GHSA-qjhf-xg26-439q for key casing).

## Regression tests to add

-   Allow `s3:*` + Deny with each unimplemented operator: the result is `UNVERIFIABLE`, never `allowed=True` with `verified=True`.
-   The same with each newly implemented operator: correct deny or allow, matching AWS semantics.
-   Mirror cases (conditional Allow with an unknown operator) stay denied.

## Additional variants with the same root cause (added 2026-10-27)

The October 2026 correctness audit found two more paths where an operator that **is** implemented returns `False` for "cannot evaluate", and the Deny is dropped at `iam_guard.py:225` (`deny_logic = And(deny_logic, Not(stmt_cond))`). Both were confirmed at runtime on 0.3.0 (`main` @ `b3098be`).

### A. Negated operator with an absent context key

AWS docs ("IAM JSON policy elements: Condition operators"):

-   If a policy condition requires that the key is not matched, such as `StringNotLike` or `ArnNotLike`, and the key is not present, the condition is **true**.
-   This applies to every operator except `...IfExists` and `Null`.
-   `aws:SourceIp`, for example, is absent for requests that arrive through a VPC endpoint.

`_apply_not_ip_address` (`iam_guard.py:114-127`) instead returns `False` when `ctx_val is None` (line 119-120). It also returns `False` on a `ValueError` from a malformed IP (line 126). A Deny guarded by `NotIpAddress` is therefore dropped whenever the key is missing:

```python
from qwed_infra.guards.iam_guard import IamGuard

g = IamGuard()
allow = {"Effect": "Allow", "Action": "s3:*", "Resource": "*"}
deny = {"Effect": "Deny", "Action": "s3:*", "Resource": "*",
        "Condition": {"NotIpAddress": {"aws:SourceIp": "203.0.113.0/24"}}}
for ctx in [{}, {"aws:SourceIp": "198.51.100.7"}, {"aws:SourceIp": "203.0.113.5"}]:
    r = g.verify_access({"Statement": [allow, deny]}, "s3:GetObject", "arn:aws:s3:::b/k", ctx)
    print(ctx, r.verified, r.allowed)
# {}                               True True    <- AWS denies (key absent: NotIpAddress is true)
# {'aws:SourceIp': '198.51.100.7'} True False   (control, correct)
# {'aws:SourceIp': '203.0.113.5'}  True True    (control, correct)
```

Through `mint_diagnostic_attestation` and `to_verification_context`, the first case is issued an attestation and gets `VERIFIED · ADMIT`. The mirror case (an Allow with the same condition and the key absent) is wrongly denied.

`tests/test_iam_guard.py:160-161` (`test_not_ip_address_none_ctx`) asserts the current behaviour (`is False`) and must be inverted with the fix. The negated operators planned under remediation item 2 (`StringNotEquals`, `ArnNotEquals`, `ArnNotLike` and others) need the same absent-key rule, or the fix will reintroduce this.

### B. `DateLessThan` with a date-only or epoch value

AWS accepts W3C ISO 8601 date formats and epoch (UNIX) time as condition values for the date operators. `_apply_date_less_than` (`iam_guard.py:129-143`) handles neither:

-   **Date-only value:** `"2030-01-01"` parses to a naive `datetime`, so comparing it with the timezone-aware request time raises `TypeError`.
-   **Epoch value:** `"1893456000"` raises `ValueError`.

Both are caught at line 142 and returned as `False` ("fail closed"), which drops the Deny:

```python
for value in ["2030-01-01", "1893456000", "2030-01-01T00:00:00Z"]:
    deny = {"Effect": "Deny", "Action": "s3:*", "Resource": "*",
            "Condition": {"DateLessThan": {"aws:CurrentTime": value}}}
    r = g.verify_access({"Statement": [allow, deny]}, "s3:GetObject", "arn:aws:s3:::b/k",
                        {"aws:CurrentTime": "2026-10-27T12:00:00Z"})
    print(value, r.verified, r.allowed)
# 2030-01-01           True True    <- AWS denies (2026 is before 2030)
# 1893456000           True True    <- AWS denies
# 2030-01-01T00:00:00Z True False   (control, correct)
```

### Additions to the remediation

-   Give every condition evaluator three outcomes: satisfied, not satisfied, and cannot evaluate. "Cannot evaluate" covers an unknown operator, an exception while parsing a value, or an absent key where the operator's semantics are not modelled. It makes `verify_access` return `UNVERIFIABLE` whenever the statement could match the request, in both Allow and Deny statements.
-   Implement AWS's absent-key rule: a negated operator with an absent key is **true**; a non-negated operator is **false**; `...IfExists` is true; `Null` tests presence.
-   Parse date values in all W3C ISO 8601 forms (date-only as midnight UTC) and as epoch seconds, and compare as aware UTC datetimes.
-   Regression tests: both reproductions above; `NotIpAddress` with a malformed context IP gives `UNVERIFIABLE`; flip `tests/test_iam_guard.py:160-161`.
-   Related public issue: #78 (array-valued condition values raise and drop a Deny), which has the same exception-to-`False` shape in the IP handlers. Consider fixing it in the same release.

[All advisories](https://qwedai.tech/security/advisories)

Affected and fixed

qwed-infra

Affected <= 0.3.0 Fixed in 0.4.0

Weakness

CWE-636 Not Failing Securely CWE-863 Incorrect Authorization

[View on GitHub](https://github.com/QWED-AI/qwed-infra/security/advisories/GHSA-rv7g-r6hp-xprf)
