Uvicorn: Add websocket max size

Created on 23 Feb 2019  路  6Comments  路  Source: encode/uvicorn

Uvicorn does not appear to support setting a web socket max message size.

Without such an option an attacker can overwhelm the memory of an application running within Uvicorn (a denial of service).

Other frameworks such as aiohttp, tornado and Sanic have max message size options. Hypercorn also has a max message size:

https://gitlab.com/pgjones/hypercorn/blob/master/hypercorn/config.py#L55

It is discussed/documented here: https://pgjones.gitlab.io/hypercorn/dos_mitigations.html#large-websocket-message

Cheers!

enhancement websockets

Most helpful comment

It would be worth looking at the wsproto

I don't think wsproto has something for this (may have forgotten), but I do this in Hypercorn - firstly there is a config setting then it is checked in the message buffer. Also see Some commentary

All 6 comments

It would be worth looking at the wsproto and websockets packages here. Do either of them include a limit by default? (We support either)

But either way, yes we should definitely have this as a configuration setting.

Hey, any updates on this?

@cgarciae Nope - we'd use this ticket if there was any progress.
If anyone wants to take a crack at a pull request for it I'd happily help review & get it in.

It would be worth looking at the wsproto

I don't think wsproto has something for this (may have forgotten), but I do this in Hypercorn - firstly there is a config setting then it is checked in the message buffer. Also see Some commentary

Looks like #538 fixes this, but has been collecting dust? Needing to switch to a different web server just to have control over that option is unfortunate :(

Many thanks for your time spent on this project.

Was this page helpful?
0 / 5 - 0 ratings