Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/1.1: Chunked message bodies incorrectly terminated on \r\n\r\n instead of 0\r\n\r\n #24455

Open
kenballus opened this issue Jul 6, 2024 · 2 comments
Labels
bug Something isn't working correctly ext/http related to ext/http upstream Changes in upstream are required to solve these issues

Comments

@kenballus
Copy link

Version

deno 1.44.4 (debug, x86_64-unknown-linux-gnu)
v8 12.7.224.9
typescript 5.5.2

Description

Deno HTTP/1.1 servers allow chunked message bodies to be terminated by \r\n\r\n alone (i.e., not 0\r\n\r\n).

To reproduce

  1. Run a Deno HTTP server that echos back message bodies, such as this one.
  2. Send it a chunked request that's missing the final chunk-size, and extract the echoed message body:
printf 'POST / HTTP/1.1\r\nHost: whatever\r\nTransfer-Encoding: chunked\r\n\r\n1\r\nZ\r\n\r\n\r\n' \
    | timeout 1 nc localhost 80 \
    | grep '"body"' \
    | jq '.["body"]' \
    | xargs echo \
    | base64 -d \
    | xxd
  1. Observe that Deno interprets the message body as Z.
00000000: 5a                                       Z

Suggested fix

Respond 400 to requests with invalid chunked message bodies. This is what nearly all other HTTP implementations do, including AIOHTTP, Apache httpd, Cheroot, FastHTTP, Go net/http, Gunicorn, H2O, HAProxy, Hypercorn, Jetty, Lighttpd, Nginx, Node.js, Puma, Tomcat, Twisted, Uvicorn, and WEBrick do.

@lucacasonato lucacasonato added bug Something isn't working correctly ext/http related to ext/http labels Jul 9, 2024
@lucacasonato
Copy link
Member

Will be fixed by hyperium/hyper#3698

@lucacasonato lucacasonato added the upstream Changes in upstream are required to solve these issues label Jul 9, 2024
@bartlomieju
Copy link
Member

Need to land #24237 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly ext/http related to ext/http upstream Changes in upstream are required to solve these issues
Projects
None yet
Development

No branches or pull requests

3 participants