HTTP request smuggling
HTTP request smuggling hides a request inside another to make front-end and back-end servers interpret it differently.
Material
Request smuggling happens when the front-end proxy and the back-end server disagree on where one HTTP request ends. The front-end counts the body by Content-Length, the back-end counts by Transfer-Encoding, or vice versa. A smuggled request hidden inside another body makes the back-end treat the leftover bytes as a new request while the front-end still believes it handled a single request.
How Content-Length and Transfer-Encoding work
Content-Length states the body size in bytes. Transfer-Encoding: chunked delimits the body with hex chunk sizes and a terminating zero line, and many parsers treat it as a second body after the ordinary one. When both headers appear, the front-end normally trusts the first one in order while the back-end may pick the other. That ordering gap is the classic source of smuggling.
POST / HTTP/1.1
Host: example.com
Content-Length: 68
Transfer-Encoding: chunked
0
GET /admin HTTP/1.1
Host: example.com
Content-Length: 15
x=1
The example above is the CL.TE variant: the front-end honours Content-Length and forwards 68 bytes, the back-end sees the terminating zero chunk and reads the remainder as a second request. The TE.CL variant reverses this: the front-end uses chunked encoding, the back-end uses Content-Length, and the smuggled request appears in the chunk bytes the back-end never counted.
Attack forms
- CL.TE: front-end uses Content-Length, back-end uses chunked, so the leftover body becomes a smuggled request.
- TE.CL: front-end uses chunked, back-end uses Content-Length, so the leftover chunk becomes a smuggled request.
- H2.CL and TE.H2: the front-end downgrades from HTTP/2 to HTTP/1.1 and disguises the request with CL or TE headers.
- CRLF injection: inserting line breaks to add headers the back-end never expected.
- Obfuscation: disguising Transfer-Encoding with odd spellings such as a trailing space, tabs, or mixed case.
- Chained impact: the smuggled request can capture other users requests, poison the cache, or deliver reflected XSS.
Prevention
- Never let the server accept a request carrying both Content-Length and Transfer-Encoding.
- Enable exactly one transfer encoding method globally; reject requests using both with a 400 response.
- Normalise and reject Transfer-Encoding headers with non-standard spellings before parsing.
- Use HTTP/2 at the front-end with correct stream teardown so there is no downgrade to HTTP/1.1.
- Apply the same request boundary rules at the proxy and the back-end so both count identically.
- Watch for anomalies: bodiless requests, invalid chunk sizes, or unexpectedly delayed responses.
# Uji CL.TE: front-end (Content-Length) vs back-end (chunked)
printf 'POST / HTTP/1.1\r\nHost: example.com\r\nContent-Length: 68\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: example.com\r\nContent-Length: 15\r\n\r\nx=1\r\n' | nc example.com 80Labs in this topic
Labs run on a domain separate from this site, so a payload cannot reach your account session.
Labs for this category land in Phase 2. The material is readable now.
Challenges in this category
Challenges from the PortSwigger Web Security Academy. The original labs run on PortSwigger domains, so the link opens there.