Skip to content
Smuggling / CRLF Write-up Advanced

The HAProxy bug - sending both Transfer-Encoding and Content-Length

HAProxy's legacy HTTP decoder failed to recognise a Transfer-Encoding header when a vertical tab or form feed preceded the 'chunked' value, so it used Content-Length instead and forwarded both headers to the backend. If the backend also mishandled the malformed Transfer-Encoding and prioritised it, an attacker could desynchronise the connection and smuggle requests to other users.

nathandavison.com

Published on nathandavison.com

The following describes a technique to achieve HTTP request smuggling against infrastructure behind a HAProxy server when using specific configuration around backend connection reuse. This was tested against HAProxy versions 1.7.9, 1.7.11, 1.8.19, 1.8.21, 1.9.10, and 2.0.5.

The author, on nathandavison.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could poison the backend connection and smuggle requests to other users, but only if the backend also mishandles the malformed Transfer-Encoding header and HAProxy is configured with http-reuse always.

What the attacker needed

HAProxy with http-reuse always; backend accepts malformed Transfer-Encoding; backend supports keep-alive; attacker can send requests to HAProxy

The fix

The HAProxy bug was fixed in 2.0.6, and users on 1.9 can switch to the new HTTP decoder with option http-use-htx; avoiding http-reuse always also reduces the risk.

How it was found

  1. Configure HAProxy with http-reuse always so backend connections are reused.
  2. Run a backend that accepts the malformed Transfer-Encoding header and prioritises it over Content-Length.
  3. Send a request with both Content-Length and a Transfer-Encoding value containing a vertical tab or form feed.
  4. Send follow-up victim requests over the same HAProxy-to-backend connection.
  5. Observe a victim response containing the smuggled header from the attacker request.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a web server sits in front of another server, it must agree with the backend on where one HTTP request ends and the next begins. Here HAProxy and the backend disagreed because of a hidden control character in a header, so an attacker could slip extra data that the backend treated as the start of the next user's request.

What is Smuggling / CRLF?

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.