Expand description
Body-size inspection bypass.
Cloud WAFs only inspect the leading N bytes of a request body: Cloudflare Pro 8 KB, Cloudflare Enterprise 128 KB, AWS WAF 8/16/64 KB depending on tier, Akamai 8 KB by default. If we prepend ≥ N bytes of inert junk in front of the real payload, the WAF rule engine never sees the malicious bytes — they’re past its inspection window — and the origin still parses the body correctly.
This module produces structurally-valid padded bodies for the four content-types we routinely inject into:
application/json— wrap original in an object with a leading junk field:{"_w":"<N bytes>","payload":<original>}.application/x-www-form-urlencoded— prepend_w=<N bytes>&to the original body.multipart/form-data— prepend a junk part with the same boundary, before the real parts.- any other content-type (raw text, XML, etc.) — fall back to a
_wquery-style prefix only if the body is empty; otherwise refuse and return the original. Padding inside an opaque body would corrupt it; honesty over false-victory.
The junk is alphabetic ASCII (A-Z cycled). It carries no SQL,
XSS, or shell metacharacters, so the WAF won’t flag the padding
itself even if it does inspect a partial slice.
Enums§
- PadOutcome
- Result of a padding attempt.
Constants§
- MAX_
USEFUL_ PAD - Hard cap on padding size to prevent OOM from accidental
requested_bytes = usize::MAX(deliberate abuse or arithmetic underflow upstream). 8 MiB is well above any documented cloud-WAF inspection window (Cloudflare Enterprise tops out at 128 KiB). - MIN_
USEFUL_ PAD - Smallest padding worth applying. Anything below this won’t reliably push a real payload past a WAF’s inspection window.
- PAD_KEY
- Marker prefix for the padding field/key. Stable across calls so a post-hoc test can verify the padding was applied.
Functions§
- known_
threshold_ values - Set of all numeric thresholds used by
known_thresholds, forclapvalue-validation in the proxy. - known_
thresholds - List of well-known WAF inspection thresholds (bytes). Useful for
callers picking a sane
requested_bytesdefault. - looks_
padded - Reverse-check: does
bodylook like it carries a wafrift-padded prefix? Used in tests + diagnostic logging. - pad
- Pad
bodywith at leastrequested_bytesof inert filler, choosing a structure-preserving strategy based oncontent_type.