In the default "enhanced" detection mode, ContentPreprocessor.preprocess() collapses all whitespace (re.sub(r"\s+", " ", content), guard_core/detection_engine/preprocessor.py:137 on master 08780f1; :384 in the 3.12.0 sdist) before pattern matching. This erases every \r and \n from the scanned value, rendering two built-in detectors structurally unmatchable regardless of input:
guard_core/handlers/suspatterns_handler.py:540: r"[\r\n]\s*(?:HTTP\/[0-9.]+|Location:|Set-Cookie:)" requires a literal \r or \n, which no longer exists after preprocessing;r"\n\s*(?:bash|sh|...)\s+-c\b" — same structural death.The downstream application receives the raw value with CRLF intact (Starlette percent-decodes %0d%0a in query parameters before the adapter passes request.query_params.items() to guard_core/utils.py:843-865), so a response-splitting-shaped payload passes detection unflagged.
Verified end-to-end against a real uvicorn server running the fastapi-guard adapter over guard-core 3.12.0, default config:
| request (?q=) | status |
|---|---|
| value%0d%0aHTTP%2F1.1+200+OK%0d%0aSet-Cookie%3A+pwned%3D1 (decoded to literal CRLF by the framework) | 200 — missed |
| ' OR 1=1-- | 400 — blocked (detection otherwise working) |
| 1 UNION SELECT password FROM users-- | 400 — blocked |
| ; cat /etc/passwd | 400 — blocked |
The legacy mode (no SecurityConfig detection attributes) skips preprocessing and catches the same decoded CRLF payload — the gap is specific to the enhanced-mode preprocessing pipeline, which every stock SecurityConfig activates. Contrast: every other preprocessing step (URL/HTML/hex/base64 decode) transforms toward what the attacker means; whitespace collapse is the one step that removes signal the detectors were written to require.
import asyncio
import httpx
import uvicorn
from fastapi import FastAPI
from guard.adapters import...
3.13.0Exploitability
AV:NAC:HPR:NUI:NScope
S:UImpact
C:NI:LA:N3.7/CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:NOther