guard-core protection bypass
Description
guard-core's request-header scanner excludes a hardcoded set of headers from all detection scanning, so attack payloads delivered through those headers, most importantly User-Agent (the canonical Log4Shell delivery vector) and Referer (a classic XSS vector), are never inspected by the detection engine in any released version. This is a failure of guard-core's detection protection mechanism (CWE-693), not a compromise of guard-core itself or of the host application.
Impact
_scan_headers in guard_core/utils.py skips every header in the hardcoded _DEFAULT_EXCLUDED_HEADERS set (host, user-agent, accept, accept-encoding, connection, origin, referer, and the sec-fetch-* / sec-ch-ua-* client-hint headers) before running any detection pattern. The exclusion exists to avoid false positives on chaotic, client-supplied header values, but the excluded_detection_headers configuration is additive-only (_resolve_excluded_headers), so a consumer cannot remove the built-in exclusions.
As a result, a payload of any detection category (SQL injection, XSS, command injection, Log4Shell ${jndi:...}, etc.) delivered through an excluded header is not scanned end-to-end. The highest-impact concrete case is Log4Shell: the original and still-common delivery vector is a ${jndi:ldap://...} string placed in the User-Agent header, which guard-core never inspects.
This is a gap in guard-core's DETECTION LAYER. It does not, by itself, compromise guard-core or the protected application. Real-world impact requires an independently vulnerable downstream component (for example, an application that logs the User-Agent value through a vulnerable Log4j version). What fails is the detection and blocking that a consumer would reasonably expect guard-core to provide for those headers.
CWE-693: Protection Mechanism Failure.
Affected versions
All released versions of guard-core (< 3.13.0).
The code identifiers used above (_scan_headers, _DEFAULT_EXCLUDED_HEADERS) are the current (3.x) names. The same behavior, a request-header scan that skips a hardcoded excluded set including user-agent, has existed since the earliest release (0.1.0) via an inline excluded_headers set in guard_core/utils.py (verified at 0.1.0, 1.0.0, and 1.2.1, where the skip wraps the detection call itself). The 2.0.0 refactor into _scan_headers / _DEFAULT_EXCLUDED_HEADERS only renamed pre-existing behavior. The exclusion, and therefore the bypass, is present in every released version, hence the affected range < 3.13.0.
Framework adapters (fastapi-guard, flaskapi-guard, djapi-guard) inherit this behavior through their guard-core dependency and are remediated by upgrading guard-core. This advisory is filed against guard-core as the single affected package rather than duplicated per adapter.
Patches
guard-core 3.13.0 introduces an "always-scan" pattern set that is applied even to excluded headers, seeded with the Log4Shell ${jndi:} pattern. Because ${jndi: has no legitimate occurrence in user input, scanning excluded headers for it adds no false-positive surface, closing the Log4Shell-via-User-Agent vector secure-by-default. The general header exclusion is retained for all other patterns to avoid false positives on chaotic client headers, so header-borne payloads of other categories remain outside the detection layer's scope by design (see Mitigations).
Mitigations / workarounds
For affected versions (< 3.13.0) there is NO complete configuration remedy: because excluded_detection_headers is additive-only, the built-in exclusions cannot be removed through configuration. Recommended actions:
- Upgrade to guard-core 3.13.0 or later once available, which closes the Log4Shell /
User-Agentcase secure-by-default. - As defense in depth for all header-borne payload categories (including after upgrading, since the detection layer still does not inspect excluded headers for non-jndi patterns), apply application-level input hardening and keep downstream components patched (for example, Log4j >= 2.17.1).
References
guard_core/utils.py:_DEFAULT_EXCLUDED_HEADERS,_scan_headers,_resolve_excluded_headers.
Severity
Moderate. CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N (5.3). Network-reachable, no privileges or interaction; guard-core's own confidentiality and availability are unaffected (C:N/A:N); integrity impact is limited to the bypassed detection layer (I:L), and scope is unchanged (S:U) since actual harm is gated on an independently vulnerable downstream component.