]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: h1: restrict a bit more the syntax of chunk extensions
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2026 17:44:09 +0000 (18:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 24 Nov 2026 09:50:37 +0000 (10:50 +0100)
commit896e7ca258adb6259680211b3ff7b27f0fcd0424
tree9fa7c8e34b4149d6042c5bf793b67d684f94001b
parentf7c38d3060fed108fd98d84204abf381e5cf0033
BUG/MINOR: h1: restrict a bit more the syntax of chunk extensions

This is a complement of commit 35d63cc3c7 ("MEDIUM: h1: strictly verify
quoting in chunk extensions") in 3.4-dev4, which focused on better
dealing with quotes in chunk extensions due to some agents being
confused by the quotes there. The exact syntax of chunk extensions is:

  *( BWS ';' BWS <name> [ BWS '=' BWS <value> ] )

  where:
    name:  <token>
    value: <token> / <quoted_string>

BWS stands for "bad whitespace", a WS that might be received from legacy
senders but that new ones must not send.

There were a few aspects above that we didn't check:
  - no space is permitted before the CRLF
  - the value may not be empty
  - name must exclusively be a token
  - value must exclusively be a token if not a quoted string

This is important because bad parsers have been caught in the past
swalloing the CRLF at wrong places (inside quotes mainly), and we must
make sure that we're not receiving a mis-quoted extension that could
have fooled an upstream reverse-proxy that got its framing wrong.

This commit improves the state machine to take care ofthe equal sign,
check for BWS around and non-empty value, and make sure that <name>
is a token. It looks like a big change but actually it's a linear
parsing of simple elements and it simplifies the previous parser
that was relying on multiple states in a loop and was wrong.

This is marked minor because most of the sensitive job was in the
commit above, this one only slightly tightens it (and anyway nobody
uses chunk extensions). It could make sense to backport this where
the commit above was backported, after a period of observation.
src/h1_htx.c