Content-Length: 282998 | pFad | https://github.com/python/cpython/issues/103204

95 `http.server` parses HTTP version numbers too permissively. · Issue #103204 · python/cpython · GitHub
Skip to content

http.server parses HTTP version numbers too permissively. #103204

@kenballus

Description

@kenballus

http.server parses HTTP version numbers too permissively.

http.server accepts request lines with HTTP version numbers that have '_', '+', and '-'.

Reproduction steps:

(Requires netcat)

python3 -m http.server --bind 127.0.0.1
printf 'GET / HTTP/-9_9_9.+9_9_9\r\n\r\n' | nc 127.0.0.1 8000

Justification

Here are the HTTP-version definitions from each of the three HTTP RFCs:

  • RFC 2616:
HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
  • RFC 7230:
HTTP-version  = HTTP-name "/" DIGIT "." DIGIT
HTTP-name     = %x48.54.54.50 ; "HTTP", case-sensitive
  • RFC 9112:
HTTP-version  = HTTP-name "/" DIGIT "." DIGIT
HTTP-name     = %s"HTTP"

I understand allowing multiple digits for backwards-compatibility with RFC 2616, but I don't think it makes sense to let the specifics of int leak out into the world. We should at least ensure that only digits are permitted in HTTP version numbers.

My environment

  • CPython 3.12.0a6+
  • Operating system and architecture: Arch Linux on x86_64

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/103204

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy