Skip to content

Gunicorn incorrectly accepts requests that don't have the 2nd CRLF in the final chunk #3382

Description

@saadiqnafis

When Gunicorn receives a request that's missing the second CRLF in the final chunk, it doesn't reject the request.

To see this for yourself,

  1. Start a Gunicorn server, such as this one:
python3 -m gunicorn --worker-class=gevent --workers=1 --worker-connections=1000 --bind 0.0.0.0:80 server:app
  1. Send it a request that's missing the final chunk's second CRLF
printf 'POST / HTTP/1.1\r\nHost: a\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n' \
 | ncat localhost 80
  1. Observe that it still responds:
HTTP/1.1 200 OK
Server: gunicorn
Date: Sat, 12 Apr 2025 22:57:45 GMT
Connection: keep-alive
Content-type: application/json
Content-Length: 145

{"headers":[["SE9TVA==","YQ=="],["VFJBTlNGRVJfRU5DT0RJTkc=","Y2h1bmtlZA=="]],"body":"","version":"SFRUUC8xLjE=","uri":"Lw==","method":"UE9TVA=="}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions