Security¶
- Validate policies (JSON Schema 2020-12) before applying.
- Avoid logging sensitive data; apply masking obligations to payloads. When using
DecisionLogger, preferuse_default_redactions=True(if you don't pass explicitredactions) and considermax_env_bytesto bound payload size. - Reload policies atomically (HotReloader already re-computes etag).
- Consider step-up auth challenges (e.g., MFA) for high-risk actions.
Note (condition depth limit, v1.9.4+):
eval_conditionlimitsand/or/notnesting toMAX_CONDITION_DEPTH(default 50) to prevent a maliciously crafted policy from exhausting the Python call stack. A rule whose condition exceeds this limit is treated as a non-match (fail-closed) withreason = "condition_depth_exceeded". Legitimate policies rarely exceed 5–10 levels of nesting; the default limit is intentionally generous.Note (compiled fast-path, v1.9.3+): the compiled decision path is always semantically equivalent to the interpreter for all combining algorithms. In particular, a
denyrule at any resource-specificity level (wildcard, type-only, attrs-constrained, or id-specific) correctly overrides apermitrule at any other level underdeny-overrides, and the same holds for the other algorithms. If you are upgrading from ≤ 1.9.2, re-evaluate any policy that mixes deny and permit rules at different resource-specificity levels to confirm the new (correct) behaviour matches your intent.Note (caching): when using shared/external caches, avoid putting sensitive data into keys/metadata and choose a backend that fits your security requirements. The default in-memory cache is per-process/per-Guard.
Note (HTTPPolicySource, v1.9.5+):
HTTPPolicySourcevalidates the URL scheme against anallowed_schemeswhitelist and optionally blocks numeric private/loopback IP literals (block_private_ips=True). TLS verification, timeout, and redirect behaviour are configurable viaverify_ssl,timeout, andallow_redirects. Seedocs/policy_stores.mdfor details.