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

Add a size limit for request bodies #1170

Closed
dav20011 opened this issue Oct 16, 2018 · 4 comments
Closed

Add a size limit for request bodies #1170

dav20011 opened this issue Oct 16, 2018 · 4 comments

Comments

@dav20011
Copy link

Upon reading the request body Django's request objects check the content length and compare it to a size limit set in the config:

# Limit the maximum request data size that will be handled in-memory.
if (settings.DATA_UPLOAD_MAX_MEMORY_SIZE is not None and
        int(self.META.get('CONTENT_LENGTH') or 0) > settings.DATA_UPLOAD_MAX_MEMORY_SIZE):
    raise RequestDataTooBig('Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.')

AsgiRequest objects do not perform this check, which is very dangerous. I was able to spam the server with only a few large request, which made the server incapable of handling any other request.

@andrewgodwin
Copy link
Member

Definitely agree, this is verging on a DoS attack.

@ross-weir
Copy link
Contributor

Hi @andrewgodwin . Could I please have a go at adding this one?

@andrewgodwin
Copy link
Member

@ross-weir Feel free to have a go and open a pull request with your work!

@jpic
Copy link
Contributor

jpic commented Feb 7, 2019

FYI, this is being re-discussed in #1240 which you're invited to review.

shjohnson-pi pushed a commit to shjohnson-pi/channels that referenced this issue May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants