HTTP Request Smuggling, Explained: When Two Servers Disagree Where a Request Ends
Key takeaways
- Request smuggling happens when a front-end proxy and a back-end server disagree about where one HTTP/1.1 request ends and the next one begins.
- The classic case sends both Content-Length and Transfer-Encoding. The proxy trusts one header, the server trusts the other, and the leftover bytes get glued onto the next user's request.
- It lets an attacker slip past the proxy's access rules, capture other users' requests and poison caches.
- The strongest fix is HTTP/2 end to end with no downgrade to HTTP/1.1. Next best is to reject any request that carries both length headers and to close the connection after a parse error.
Picture a mail room. The front desk receives a stack of paper and passes it to the back office. Both need to agree where one letter ends and the next begins. If the front desk thinks it handed over one long letter, but the back office sees one short letter plus the first page of a second, that extra page gets stapled onto whatever arrives next, which is somebody else’s letter.
That is HTTP request smuggling. It is also called a desync attack, and it was first documented in a 2005 Watchfire paper. It came back in a big way in 2019 when James Kettle at PortSwigger published HTTP Desync Attacks, and he showed in 2025 that it is still widespread with HTTP/1.1 must die, which also added newer variants such as 0.CL.
This post explains it with pictures and a tiny Python script you can run offline.
TL;DR
- Modern sites put a proxy (CDN, load balancer, WAF) in front of the app server, and the two often reuse one connection for many users’ requests.
- HTTP/1.1 has two ways to say how long a body is:
Content-LengthandTransfer-Encoding: chunked. Send both, and each server may pick a different one.- The bytes one side ignores become the start of the next request, which belongs to someone else.
- Fix: HTTP/2 end to end, or reject ambiguous requests and close the connection on any parse error.
Why there are two servers at all
Your browser rarely talks to the app directly. It talks to a front-end: Cloudflare, an AWS load balancer, nginx, HAProxy, a WAF. That front-end forwards requests to the back-end server, and for speed it keeps a few connections open and sends many users’ requests down the same one, one after another.
This only works if both sides cut the stream in exactly the same places.

Two ways to measure a body
An HTTP/1.1 request with a body has to say where the body stops. There are two ways:
Content-Length: 37means “the body is exactly 37 bytes”.Transfer-Encoding: chunkedmeans “the body comes in chunks, each prefixed with its size in hex, and a chunk of size0marks the end”.
Both are fine on their own. The trouble starts when a request carries both and two servers resolve the conflict differently.
The actual bytes
Here is a classic CL.TE request: the front-end trusts Content-Length, the back-end trusts Transfer-Encoding.

The front-end counts 37 bytes, sees one complete POST and forwards it. The back-end reads the chunked body, hits 0 and stops. The last two lines are still sitting on the connection. The back-end assumes they are the beginning of the next request and waits for the rest.
The next request on that connection belongs to another user. Their GET /cart with their session cookie gets appended to X-Ignore: X, so their real request line turns into a harmless header value, and the back-end serves GET /admin with the victim’s cookie attached. The victim gets back a response to a request they never made. To read the /admin response themselves, attackers send their own follow-up request on the same connection instead of waiting for a victim.
Run it yourself (no network)
This script plays both servers on the same bytes. It never opens a socket, so it is safe to run anywhere.
"""Two toy HTTP/1.1 parsers read the same bytes. One trusts Content-Length, the other Transfer-Encoding.
No network: it only shows where each one thinks the first request ends."""
BODY = b"0\r\n\r\nGET /admin HTTP/1.1\r\nX-Ignore: X"
RAW = (b"POST /search HTTP/1.1\r\n"
b"Host: shop.example\r\n"
b"Content-Length: " + str(len(BODY)).encode() + b"\r\n"
b"Transfer-Encoding: chunked\r\n"
b"\r\n" + BODY)
def split_head(buf):
head, _, rest = buf.partition(b"\r\n\r\n")
headers = dict(l.split(b": ", 1) for l in head.split(b"\r\n")[1:])
return headers, rest
def front_end(buf):
"""Proxy that only looks at Content-Length."""
h, rest = split_head(buf)
n = int(h[b"Content-Length"])
return rest[:n], rest[n:]
def back_end(buf):
"""Server that honors chunked encoding (RFC 9112 says Transfer-Encoding wins when both are present)."""
h, rest = split_head(buf)
body = b""
while True:
size_line, _, rest = rest.partition(b"\r\n")
size = int(size_line, 16)
if size == 0:
return body, rest[2:] # skip the CRLF after the last chunk
body, rest = body + rest[:size], rest[size + 2:]
def show(b):
for line in b.decode().rstrip("\r\n").split("\r\n"):
print(" | " + line)
fb, fleft = front_end(RAW)
bb, bleft = back_end(RAW)
print(f"front-end: Content-Length says the body is {len(fb)} bytes, {len(fleft)} left over -> ONE request")
print(f"back-end : chunked body is {len(bb)} bytes, {len(bleft)} left over -> start of a SECOND request:")
show(bleft)
nxt = b"GET /cart HTTP/1.1\r\nHost: shop.example\r\nCookie: session=victim\r\n\r\n"
print("the next user's request lands on the same connection, so the back-end reads:")
show(bleft + nxt)
Output:
front-end: Content-Length says the body is 37 bytes, 0 left over -> ONE request
back-end : chunked body is 0 bytes, 32 left over -> start of a SECOND request:
| GET /admin HTTP/1.1
| X-Ignore: X
the next user's request lands on the same connection, so the back-end reads:
| GET /admin HTTP/1.1
| X-Ignore: XGET /cart HTTP/1.1
| Host: shop.example
| Cookie: session=victim
Same bytes, two different answers, and that disagreement is the bug.
The family names
The variants are named by what the front-end reads, then what the back-end reads.

The H2 variants matter because many teams think “we use HTTP/2, so we’re fine”. If the front-end downgrades to HTTP/1.1 for the back-end, the ambiguity comes right back. HTTP/2 removes this length ambiguity because every frame carries its own length, though buggy implementations still exist.
What an attacker gets, and what stops it

The fixes, in the order I would apply them:
- Use HTTP/2 from the front-end to the back-end. No downgrade means no Content-Length versus Transfer-Encoding ambiguity. Kettle’s 2025 research makes this case strongly.
- Reject requests with both
Content-LengthandTransfer-Encoding. RFC 9112 says Transfer-Encoding wins and such a message “ought to be handled as an error” (section 6.3), that a proxy forwarding it must strip Content-Length first, and that a server must close the connection after responding (section 6.1). Rejecting it outright is simpler and safer. - Normalize at the front-end. The proxy should rewrite every request into one clean, unambiguous form before forwarding, or refuse it. Malformed
Transfer-Encodingheaders (whitespace before the colon, values likechunked, identity, duplicate lines) get a 400, not a best guess. - Close the connection on any parse error. A server that keeps the connection after a confusing request is the one that lets leftover bytes survive.
- Patch and test. Proxy and server vendors fix desync bugs regularly. Burp Suite’s free HTTP Request Smuggler extension finds these in your own stack. Test only systems you own or are allowed to test.
Disabling connection reuse between the front-end and back-end also kills most variants, but it costs performance, so most teams treat it as a stopgap.
Why this keeps coming back
DNS tunneling, the subject of the previous post in this series, abuses a channel that everyone trusts. Request smuggling abuses the assumption that two well-behaved programs will read the same bytes the same way. Every new proxy, CDN feature or protocol downgrade is another chance for them not to.
If you run a proxy in front of anything, the one question to ask this week is: does every hop between the browser and the app speak HTTP/2, and if not, what does each hop do when it sees both length headers?
References
- PortSwigger Web Security Academy, HTTP request smuggling
- James Kettle, HTTP Desync Attacks: Request Smuggling Reborn (2019)
- James Kettle, HTTP/1.1 must die: the desync endgame (2025)
- IETF, RFC 9112: HTTP/1.1, sections 6.1 and 6.3
- OWASP, Web Security Testing Guide
Frequently asked questions
- Does HTTPS prevent HTTP request smuggling?
- No. TLS protects the bytes between the client and the proxy. Smuggling is about how the proxy and the back-end interpret those bytes after decryption, so it works the same over HTTPS.
- Does using HTTP/2 make me safe?
- Only if HTTP/2 is used all the way to the back-end. Many setups speak HTTP/2 to the browser and rewrite to HTTP/1.1 for the server, which brings the ambiguity back and adds new variants such as H2.CL and H2.TE.
- What does RFC 9112 say about a request with both Content-Length and Transfer-Encoding?
- Transfer-Encoding overrides Content-Length, the message ought to be treated as an error because it may be a smuggling attempt (section 6.3), a proxy that forwards it must remove Content-Length first, and the server must close the connection after responding (section 6.1).
About the author
Security Engineer & Technical Writer
Security engineer and technical writer based in Batam, Indonesia. I review and harden MCP servers and AI agents, build security automation, and write up what holds and what fails. I also train on DNS security as a PANDI .id Academy trainer.
Related articles
-
8 min read
The eMudhra Fallout, Part 2: I Scanned 30 Docker Images. 10 Still Trust the Root Chrome Is Dropping
Chrome drops emSign ECC Root CA - G3 on October 27. I read the CA bundles in 30 popular Docker images: a third still ship the root, some built after the fix.
- Security Engineering
- Deployment
-
6 min read
PHP2Shell: The Patch Is Out. Is It Running in Your Containers?
PHP2Shell patches for CVE-2026-109618 and CVE-2026-109619 are out. Five checks to prove the fix is running in your containers, not just released.
- Security Engineering
- Deployment
-
6 min read
The eMudhra CA Keys Were One Byte Long. Does Your Container Still Trust Them?
Eight eMudhra CA keys were one-byte numbers. Browsers blocked them in hours, but containers may not. A 15-minute trust store audit for Docker, Python, Java.
- Security Engineering
- Deployment
All writing | RSS | Markdown