Giter Site home page Giter Site logo

Comments (4)

etianen avatar etianen commented on May 9, 2024

We have to buffer the entire request in order to prevent slow network
clients from stalling the wsgi worker threads. However, the current
situation is not ideal.

I think it needs to be possible to configure a max request size for the
wsgi handler, which will reject an incoming request with the appropriate
status code if it's above the allowed size. Setting it to a default value
of 100MB or so would seem to mitigate malicious attacks while still
allowing most sensible files through.

Sound reasonable?
On Thu, 3 Mar 2016 at 22:42, Marcel Hellkamp [email protected]
wrote:

The WSGI adapter reads the complete request body into memory. This results
in extreme memory consumption for large file uploads and makes it very easy
to run denial-of-service attacks.

curl --data-binary "@/dev/zero" http://example.com/wsgi


Reply to this email directly or view it on GitHub
#7.

from aiohttp-wsgi.

defnull avatar defnull commented on May 9, 2024

Stalling the worker thread pool is always better than exhausting the server memory. It brings down only the WSGI application, not the whole server.

With a hard per-request limit, you could still get the server into swapping with multiple smaller requests. Also, uploading bigger files would no longer be possible.

Why not buffer into a reasonably sized tempfile.SpooledTemporaryFile, chunk by chunk? Then, a maximum of memory_limit_per_tempfile * thread_pool_size of memory is used and bigger requests are still allowed. Bottle does it this way.

from aiohttp-wsgi.

etianen avatar etianen commented on May 9, 2024

A spoiled temporary file seems good too, but I think a max upload size is
still sensible. Most webservers have this built in. Nginx limits to 5MB by
default, I think, which is tiny!
On Fri, 4 Mar 2016 at 11:08, Marcel Hellkamp [email protected]
wrote:

Then you could still get the server into swapping with multiple smaller
requests. Also, uploading bigger files would no longer be possible. Why not
buffer into a reasonably sized tempfile.SpooledTemporaryFile, chunk by
chunk?

Other than that, stalling the worker thread pool is still better than
exhausting the server memory. It brings down only the WSGI application, not
the whole server.


Reply to this email directly or view it on GitHub
#7 (comment).

from aiohttp-wsgi.

etianen avatar etianen commented on May 9, 2024

Here we go: https://github.com/etianen/aiohttp-wsgi/blob/master/CHANGELOG.rst#040

from aiohttp-wsgi.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.