Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Assignees
gpshead
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@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.1printf'GET / HTTP/-9_9_9.+9_9_9\r\n\r\n'| nc 127.0.0.1 8000

Justification

Here are theHTTP-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 "." DIGITHTTP-name     = %x48.54.54.50 ; "HTTP", case-sensitive
  • RFC 9112:
HTTP-version  = HTTP-name "/" DIGIT "." DIGITHTTP-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 ofint 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

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp