Skip to content

Parsing issue of Duplicate Chunked Transfer-Encoding #10611

Open
@TUO-Wu

Description

@TUO-Wu

Describe the bug

Hello, I may have found a bug in aiohttp's parsing of HTTP requests with duplicate chunked Transfer-Encoding.
RFC 9112 says these:

A sender MUST NOT apply the chunked transfer coding more than once to a message body (i.e., chunking an already chunked message is not allowed).

A server that receives a request message with a transfer coding it does not understand SHOULD respond with 501 (Not Implemented).

Although the RFC only restricts the sender (A sender MUST NOT apply the chunked transfer coding more than once to a message body), this should imply that duplicate chunked Transfer-Encoding is incorrect. The server may reject the request with 501 (Not Implemented) or 400 (Bad Request).
However, aiohttp does not reject such request.

To Reproduce

  1. Run aiohttp.
  2. Send the following request to aiohttp.
POST / HTTP/1.1\r\n
Host: victim.com\r\n
Transfer-Encoding: chunked, chunked\r\n
\r\n
0\r\n
\r\n
  1. Aiohttp does not reject:
$ echo -ne "POST / HTTP/1.1\r\nHost: victim.com\r\nTransfer-Encoding: chunked, chunked\r\n\r\n0\r\n\r\n" | nc 172.18.0.8 80
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 161
Date: Thu, 20 Mar 2025 12:12:13 GMT
Server: Python/3.10 aiohttp/4.0.0a2.dev0

{"headers":[["SG9zdA==","dmljdGltLmNvbQ=="],["VHJhbnNmZXItRW5jb2Rpbmc=","Y2h1bmtlZCwgY2h1bmtlZA=="]],"body":"","method":"UE9TVA==","uri":"Lw==","version":"MS4x"}

Expected behavior

The server may reject the request with 501 (Not Implemented) or 400 (Bad Request).

Logs/tracebacks

/

Python Version

$ python --version
Python/3.10

aiohttp Version

$ python -m pip show aiohttp
aiohttp/4.0.0a2.dev0

multidict Version

$ python -m pip show multidict
/

propcache Version

$ python -m pip show propcache
/

yarl Version

$ python -m pip show yarl
/

OS

Ubuntu 11.4.0-1ubuntu1~22.04

Related component

Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions