Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #622 (defect)

Opened 2 years ago

Last modified 10 months ago

Client may not receive socket output if request body is not read

Status: closed (fixed)

Reported by: fumanchu Assigned to: fumanchu
Priority: low Milestone: 3.1
Component: CherryPy code Keywords:
Cc:

The following applies to wsgiserver, rev [1534].

In some cases, a client will send a request body that is never read, or never read fully. This can occur when the request entity is too large (and 413 is returned), and also when InternalRedirect is raised before the request body is read. In both cases, the server will write a response to the socket. What happens next depends on whether the server then chooses to close the connection or not:

  • When the connection is closed, there are rare cases where the client will not be able to read the server response from the socket before the socket is closed. When this happens, the user will not see the response, and will usually only see an error on the socket.read call. Due to the nature of TCP, there's really no way for the client to distinguish between this situation and the case of the server simply not responding.
  • When the connection is not closed, the next attempt to read a request from the stream will error, since the first line in the previous, lingering request body is probably not a valid Request-Line (but if it is, this may be an exploitable hole that needs further investigation). When this happens, the server will close the connection.

Apache had this same problem and addressed it with the ap_lingering_close function. Given that solution's long and interesting history, and the rarity of the problem, I'm not sure we need to rush a fix for this. But be aware there's at least one test case in our current suite which can run into this (the early_ir call inside test_core).

Change History

12/18/06 11:49:21: Modified by fumanchu

Note that this is addressed in RFC 2616:

"If an origin server receives a request that does not include an Expect request-header field with the "100-continue" expectation, the request includes a request body, and the server responds with a final status code before reading the entire request body from the transport connection, then the server SHOULD NOT close the transport connection until it has read the entire request, or until the client closes the connection. Otherwise, the client might not reliably receive the response message. However, this requirement is not be construed as preventing a server from defending itself against denial-of-service attacks, or from badly broken client implementations."

http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3

10/27/07 19:55:57: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 3.1.

Fixed in [1786].

Hosted by WebFaction

Log in as guest/cpguest to create tickets