A request body larger than detection_max_body_inspect_bytes was skipped by body detection entirely instead of being scanned up to the cap
Description
When a request declared a Content-Length above detection_max_body_inspect_bytes (default 262144), guard_core/_utils/body_reader.py returned no body to the scanner at all, so body detection ran on nothing. A payload placed at the start of a body padded past 256 KB was never scanned, while the same payload in a 255 KB body was detected. Found by the maintainers while profiling the fix for GHSA-3hfx-8m47-5f9h.
Impact
Body-borne detection (every category that scans the request body: SQL injection, command injection, deserialization, and the rest) is bypassed by padding the body past the inspection cap. The cap exists to bound memory; it was implemented as a skip instead of a truncation. Unauthenticated, default configuration, any adapter.
Affected
guard-core versions with detection_max_body_inspect_bytes (the cap was introduced with the chunked-body fix in 3.12.0; earlier versions had other body-size behaviour) up to and including 3.14.0.
Fixed in 3.15.0
Fixed in guard-core 3.15.0 (PyPI), merged in #83 (75d13343). An oversized body is read up to the cap through the adapter's bounded reader (read_body_prefix, present in fastapi-guard since 7.6.0 and the other adapters since their 3.12.0 lockstep), the straddle overlap the no-Content-Length path already used is applied, and the prefix is scanned; one warning per request names the cap and the client. An adapter without a bounded reader still skips, now with a warning that names the missing reader. The detection-gate corpus pins the attack-in-the-first-kilobyte and the benign 300 KB cases.
Credit
Found by the maintainers.