Skip to content

httputil: Make parse_request_start_line stricter#3473

Merged
bdarnell merged 3 commits intotornadoweb:masterfrom
bdarnell:http-abnf
Mar 30, 2025
Merged

httputil: Make parse_request_start_line stricter#3473
bdarnell merged 3 commits intotornadoweb:masterfrom
bdarnell:http-abnf

Conversation

@bdarnell
Copy link
Member

The method is now restricted to being valid token characters as defined
in RFC 9110, allowing us to correctly issue status code 400 or 405
as appropriate (this can make a difference with some caching proxies).

The request-target no longer allows control characters. This is less
strict than the RFC (which does not allow non-ascii characters),
but prioritizes backwards compatibility.

Fixes #3415
Closes #3338

This will make it easier to stay in strict conformance with the RFCs.
Note that this commit makes a few small semantic changes to response
start-line parsing: status codes must be exactly three digits, and
control characters are not allowed in reason phrases.
The method is now restricted to being valid token characters as defined
in RFC 9110, allowing us to correctly issue status code 400 or 405
as appropriate (this can make a difference with some caching proxies).

The request-target no longer allows control characters. This is less
strict than the RFC (which does not allow non-ascii characters),
but prioritizes backwards compatibility.

Fixes tornadoweb#3415
Closes tornadoweb#3338
@bdarnell bdarnell merged commit aa66a67 into tornadoweb:master Mar 30, 2025
15 checks passed
@bdarnell bdarnell deleted the http-abnf branch March 30, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tornado not sufficiently validating HTTP method

1 participant