Menu

Things my HTTP/1.1 parser now refuses with a 400 after I read up on request smuggling

Reading 0:00
15s threshold

I've been writing my own HTTP/1.1 parser for a web framework in V, and the part that took the longest wasn't making it fast, it was deciding what to refuse.

Most smuggling bugs come from two hops disagreeing on where a request ends. The proxy trusts Content-Length, the backend trusts Transfer-Encoding (or the other way around), and the leftover bytes turn into the start of somebody else's request. So I gave up on being lenient and the parser now answers 400 for anything with ambiguous framing:

Transfer-Encoding and Content-Length both present

duplicate Content-Length headers, even when the values match

Content-Length with anything that isn't a digit (signs, spaces, whatever)

obs-fold, the old header continuation lines

bare CR or bare LF where there should be CRLF

A couple of these are stricter than the RFC. Matching duplicate CLs are technically fine, and for obs-fold you're allowed to just replace it with a space.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.