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

pywsgi.py:Input._do_read isn't secure againt truncated and malformed POST requests #92

Closed
denik opened this issue Sep 13, 2012 · 0 comments
Milestone

Comments

@denik
Copy link
Member

denik commented Sep 13, 2012

What steps will reproduce the problem?

  1. Launch dummy WSGI app that processes POST requests with "python gevent-server.py"
  2. Inject truncated request with "nc localhost 80 -q 2 < hack-gevent-wsgi"

What is the expected output?

There should be some kind of exception or treatment that makes the app aware of the fact that the request is malformed.

What do you see instead?

Absolutely no warning from gevent.
Infinite loop when the app tries to read wsgi.input according to CONTENT_LENGTH

What version of the gevent are you using?

gevent-0.13.6

What version of libevent are you using?

On what operating system?

Debian and Ubuntu (GNU/Linux)

On what Python?

tested with 2.6 and 2.7

Notes:

The test app may look naive, but actually reproduces the behavior of many web frameworks.

There should be an exception that lets the app know that the POST or PUT request is malformed. This is a serious security issue.

Reported by bezverky.


earlier comments

schmir said, at 2011-10-14T21:20:48.000Z:

There's at least one code path that throws an IOError when receiving a truncated POST request. It happens when using chunked encoding and one of the chunks is truncated. I will implement the suggested behaviour (raising IOError) - unless Denis objects.

Denis?

maluke said, at 2011-10-14T21:23:15.000Z:

You can just borrow code from webob.

Denis.Bilenko said, at 2011-10-15T05:08:39.000Z:

I think raising IOError on truncated POST request is fine.

schmir said, at 2011-10-26T21:17:18.000Z:

IOErrors are now being raised by the Input class on truncated requests...

@denik denik closed this as completed Sep 13, 2012
hashbrowncipher pushed a commit to hashbrowncipher/gevent that referenced this issue Oct 20, 2018
Log more info when catch OSError while doing a popen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant