-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
MAX_CONTENT_LENGHT not being respected with JSON payload #1200
Comments
Flask/Werkzeug only validate the content length when accessing the relevant request attributes. |
Could you please elaborate which relevant request attributes are being checked? The info in the documetation mentions "If set to a value in bytes, Flask will reject incoming requests with a content length greater than this by returning a 413 status code.", so I assumed that if my payload on a POST is larger than MAX_CONTENT_LENGTH it would be blocked with 413. Thanks for your patience! |
Flask lazily parses and validates incoming request data as you access e.g. |
And the same holds true for basically every request attribute that consumes the request body. |
@ispmarin Is this answer sufficient for you and can i close the issue? |
Got it, gonna investigate more the effects. Thanks |
Pardon me for reopening this. There still seems to be a possible DoS safety issue here. If an endpoint calls Here's an example server and client that demonstrate this, using the Server:
Client:
Example run:
The In other words, it sure seems like JSON servers that want to protect themselves from allocating arbitrary amounts of memory in response to a large POST must do something to cause MAX_CONTENT_LENGTH checking before using |
Closed by pallets/werkzeug#1126. |
Fixed by pallets/werkzeug#2620 |
Setting the MAX_CONTENT_LENGHT variable does nothing to limit a json payload larger than the set limit. We are using Flask Classy to write the post method and Flask to handle the requests.
Cheers
The text was updated successfully, but these errors were encountered: