WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@bohmiiidd
Copy link

This patch updates the DechunkedInput class to:

  • Validate chunk lengths properly, rejecting negative or invalid chunk sizes.
  • Correctly detect the final zero-length chunk and consume its terminating newline.
  • Prevent infinite loops by raising errors if chunk terminators are missing or the stream ends prematurely.
  • Enforce strict compliance with the HTTP chunked transfer specification to mitigate DoS attacks.
  • Enforce a maximum allowed request body size (16MB by default) to mitigate resource exhaustion.

These changes harden Werkzeug against malicious chunked HTTP requests.


fixes #3051


  • Added tests to verify correct chunked input handling and DoS mitigation.
  • Updated docstrings in DechunkedInput for clarity.
  • Added changelog entry describing the fix.
  • Marked relevant code changes with .. versionchanged:: where applicable.

@davidism
Copy link
Member

davidism commented Jul 2, 2025

It looks like you're using an AI to report this issue and write this PR, without reviewing it's output. Don't do that. You completely stripped all comments and typing from the file/class. You gave no explanation of how the previous code was wrong, and how the new code addresses that, so it's difficult to review this other than "it's different now".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

development server chunked transfer encoding will stream forever

2 participants