George Muscat
Senior Security Engineering Consultant @ Asontu
Email: g.muscat@unsw.edu.au
# Accept an incoming connection
client_connection, _ = listen_socket.accept()
# Manually buffer the request data
request_data = b""
while True:
# Receive bytes in chunks
data = client_connection.recv(1024)
request_data += data
# Check if the end of the HTTP headers is reached
if b'\r\n\r\n' in request_data:
# If this is a POST request, we would need to do more stuff here...
break
# parse request_data further
Key specs to know:
For smuggling, RFC 9112 framing rules are the core.
RFC 9112 defines strict message delimitation behavior.
Transfer-Encoding (if present and valid) governs decoding/framingContent-Length is used when Transfer-Encoding is absentIf two components apply different precedence, desync emerges.
When both Transfer-Encoding and Content-Length appear together, this is dangerous ambiguity.
Best practice is to reject such requests.
If one tier accepts and another rejects/interprets differently, request smuggling becomes possible.
Attacker sends one byte stream/packet that frontend and backend parse differently:
The smuggled bytes are then prepended to the next request in queue on the backend.
Client → Frontend Proxy → Backend App
Vulnerability condition:
Result: attacker controls parsing context for subsequent traffic.
Frontend uses Content-Length
Backend uses Transfer-Encoding
Transfer-EncodingThis causes leftover bytes to become a smuggled request.
Frontend uses Transfer-Encoding
Backend uses Content-Length
Content-Length in an ambiguous messageFrontend and backend disagree on request end, producing queue desync.
Both claim to support Transfer-Encoding, but differ in parsing details:
Transfer-Encoding headers handled inconsistentlyCommon root causes tied to standards handling:
Attacker sends both:
Content-Length: 40Transfer-Encoding: chunkedFrontend reads fixed 40-byte body.
Backend stops at chunk terminator and leaves trailing bytes queued.
Those queued bytes become the start of the next backend request.
Smuggling generally needs:
An RFC violation alone may be benign in isolation.
These are downstream effects of one upstream parsing flaw.
H2 frontends often downgrade to H1 backends.
Risk point: translator emits H1 with imperfect normalization/framing controls
Vulnerable component is frequently H2→H1 conversion, not the H2 client link itself.
Watch for:
400/502 clusters after malformed requestsAt the trusted edge (e.g. CDN, reverse proxy):
CL with TE)Goal: remove ambiguity before traffic enters shared pools.
HTTP request smuggling is best understood as:
Exploitation of inconsistent HTTP message framing decisions across components that do not adhere uniformly to RFC-defined behavior.
If two components disagree on where a request ends, attackers can control what comes next.