[New-bugs-announce] [issue34866] CGI DOS vulnerability via long post list

Matthew Belisle report at bugs.python.org
Mon Oct 1 17:23:27 EDT 2018


New submission from Matthew Belisle <matthew.belisle at workiva.com>:

Copied from email to security at python.org:

I have been doing memory profiling on a few python web frameworks and I noticed this issue in the cgi.FieldStorage class.

$ python example.py
Memory used: 523935744 bytes

The problem is there is no easy way to limit the number of MiniFieldStorage objects created by FieldStorage, so it goes unchecked in many frameworks like pyramid, pylons, webapp2, and flask. The end result is that on these frameworks, a 9MB request body (gzipped down to 9KB) can chew up ~500MB of memory on the server which is enough to effectively DOS it. The obvious way to prevent this currently is to check the content-length header and fail if it exceeds some value. But that solution has a major shortcoming because many frameworks want to allow large payloads, sometimes up to 10MB, as long as they contain a reasonable number of fields.

After talking with the security at python.org
 team and pylons dev team about it, we think the best solution is to add a max_num_fields param to the FieldStorage class, defaulting to None, which throws an error if max_num_fields is exceeded.

----------
components: Library (Lib)
messages: 326831
nosy: Matthew Belisle
priority: normal
severity: normal
status: open
title: CGI DOS vulnerability via long post list
type: security
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34866>
_______________________________________


More information about the New-bugs-announce mailing list