A non-UTF-8 request body skips all body detection, bypassing every category
Description
guard-core reads a request body, then decodes it as strict UTF-8 before scanning; if that decode fails, the entire body scan is silently skipped. As a result, any attack payload delivered in a request body that contains a single non-UTF-8 byte is never inspected by the detection engine, in any category, 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
In guard_core/utils.py, detect_penetration_attempt reads the request body bytes and does raw_body = body_bytes.decode() (strict UTF-8) inside a broad except that returns a detection miss on failure. A request body containing any byte sequence that is not valid UTF-8 (raw binary, a Latin-1 / Windows-1252 encoded body, or a single stray 0xFF byte appended to an otherwise-textual payload) raises UnicodeDecodeError, and the whole-body scan is abandoned before any detection pattern runs.
Consequently, an attacker delivers a body-borne payload of ANY category (SQL injection, XSS, command injection, NoSQL injection, deserialization, etc.) and appends or prepends a single invalid byte; the body is read but never scanned, so the payload bypasses detection end-to-end. The evasion is trivial to trigger (one non-UTF-8 byte) and applies to every category that relies on body scanning.
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 that processes the body. What fails is the detection and blocking a consumer would reasonably expect guard-core to provide for request bodies.
CWE-693: Protection Mechanism Failure.
Affected versions
All released versions of guard-core (< 3.13.0). The strict-decode-then-skip shape has been present in the body-scan path since body scanning was introduced. Framework adapters (fastapi-guard, flaskapi-guard, djapi-guard) inherit this behavior through their guard-core dependency and are remediated by upgrading guard-core. Filed against guard-core as the single affected package.
Patches
[PLACEHOLDER pending the fix] guard-core 3.13.0 decodes the request body with a lossy decoder (errors="replace") instead of strict UTF-8, so a body containing non-UTF-8 bytes is still scanned: the invalid bytes become replacement characters and the embedded text content is inspected by the detection engine. The over-cap and missing-body behavior is unchanged. Final code identifiers to be confirmed here once the fix lands.
Mitigations / workarounds
For affected versions (< 3.13.0) there is no configuration remedy; strict body decoding is not exposed as an option. Recommended actions:
- Upgrade to guard-core
3.13.0or later once available. - As defense in depth, reject or normalize non-UTF-8 request bodies at the application/edge layer, and keep downstream components patched.
References
guard_core/utils.py: the body-scan path indetect_penetration_attempt(strictbody_bytes.decode()that skips scanning on failure), plus the sync mirror inguard_core/sync/utils.py.
Severity
Moderate. CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N (5.3). Same conservative basis as the header-exclusion (GHSA-vg6x-82jh-rp4h) and parameter-name (GHSA-5cxc-h6c3-r39g) advisories: network-reachable, no privileges or interaction; guard-core's own confidentiality and availability are unaffected (C:N/A:N); the integrity impact is limited to the bypassed detection layer (I:L); scope unchanged (S:U) because actual harm is gated on an independently vulnerable downstream component. This advisory is co-published with the other two CWE-693 detection-bypass advisories, so it carries the same basis for consistency; the maintainer may weigh the trivially-triggered, all-category nature of this bypass higher.