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

request.max_content_length is only enforced when parsing form data #1096

Closed
davidism opened this issue Apr 4, 2017 · 5 comments
Closed

request.max_content_length is only enforced when parsing form data #1096

davidism opened this issue Apr 4, 2017 · 5 comments
Milestone

Comments

@davidism
Copy link
Member

davidism commented Apr 4, 2017

It should be enforced for raw get_data as well. Not sure if it should apply to stream, since at that point you probably know what you're doing.

Also, it's only enforced if the Content-Length header is set, so chunked requests can spin forever and consume memory.

One solution might be to provide a max_input_length to get_input_stream and always return a LimitedStream if it is set.

@davidism
Copy link
Member Author

To summarize: pass request.max_content_length to get_input_stream as a keyword argument for backwards compat, defaulting to None. If content_length and max_content_length are None, return the stream. Otherwise, return a LimitedStream with the minimum of the two values.

@reinderien
Copy link

I'm puzzled that this is closed. Using werkzeug via Flask, MAX_CONTENT_LENGTH has no effect unless parsing form data, but it should also take effect in general when receiving a body with Content-Length > 0.

@davidism
Copy link
Member Author

davidism commented Jun 4, 2020

It's three years old, I'm sure I closed it for a reason, but I don't remember what it was off the top of my head.

This is unreliable anyway, use your HTTP server to control the allowed request size.

@reinderien
Copy link

Sure; but if it's unreliable, I would offer that it should be removed altogether, rather than staying in with surprising behaviour.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
@davidism
Copy link
Member Author

Fixed by #2620

@davidism davidism added this to the 2.3.0 milestone Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants