]> git.ipfire.org Git - thirdparty/tornado.git/commit
http1connection: Make content-length parsing more strict
authorBen Darnell <ben@bendarnell.com>
Wed, 9 Aug 2023 01:55:02 +0000 (21:55 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 11 Aug 2023 02:39:22 +0000 (22:39 -0400)
commit217295b1dd30f556ea374d62007f6821688f00f0
tree62491252cdc84631a9f9d2bf757c6de44b820bc5
parente3aa6c5e2943242d8ab25448c2798365b3cb9945
http1connection: Make content-length parsing more strict

Content-length and chunk size parsing now strictly matches the RFCs.
We previously used the python int() function which accepted leading
plus signs and internal underscores, which are not allowed by the
HTTP RFCs (it also accepts minus signs, but these are less problematic
in this context since they'd result in errors elsewhere)

It is important to fix this because when combined with certain proxies,
the lax parsing could result in a request smuggling vulnerability (if
both Tornado and the proxy accepted an invalid content-length but
interpreted it differently). This is known to occur with old versions
of haproxy, although the current version of haproxy is unaffected.
tornado/http1connection.py
tornado/test/httpserver_test.py