Re: [mongrel2] Chunked transfer encoding
- From:
- Zed A. Shaw
- Date:
- 2010-12-27 @ 17:52
On Mon, Dec 27, 2010 at 09:23:06AM -0600, tsuraan wrote:
> > Sorry, it doesn't support chunked-encoding from the client.
> > Chunked-encoding from the client is error prone, not part of the standard,
> > and totally useless since the client knows what the size of its data
> > is from the start. Allowing chunked-ecoding from the client would allow
> > for a range of attacks where a client could eat up resources by sending
> > an endless stream of chunks.
>
> Is that an actual attack? The difference between chunked and normal
> upload is that with normal uploads, the client tells the server the
> size before it starts sending chunks, but once it's said a size, it
> can send chunks of data as quickly or slowly as it wants to. With
> chunked upload, the client doesn't tell the server in advance how much
> data it's going to send, but once the server's seen too much data, it
> can sever the connection, right? How would it be any different from a
> client figuring out the max upload size and just slowly (I assume
> that's the key to the attach) sending it that much data to tie up
> resources?
http://ha.ckers.org/slowloris/
There ya go, and that's just with headers. With CE the client can just
send and send and send, and also do a slowloris using headers in the
chunks. It's endless.
There's also an attack where using client-side CE through badly written
proxies allows for poisoning the connection.
Clients should be stating how much they're going to send and send only
that much. They can't be trusted and shouldn't be allowed to endlessly
send ever growing requests, streams of request bodies, and arbitrary
headers at any point in the stream.
> The reason that I'd like chunked post is that some browsers really
> don't function correctly without it. When trying to upload a large
> file (gigabytes), firefox and explorer (not sure about any of the
> other browsers) use massive amounts of RAM and CPU before they start
> uploading if chunked post is not available.
What? Then that is a bug you should file with the browsers, and
actually I don't think this is true. First, I've used browsers to
upload DVD sized files without this happening. Second, you say they
don't do this *if* the server supports CE client side, but how does the
browser know that? There's no mechanism to ask a server this before
sending. Also, how are you possibly sending these giant POSTs since
they'd take forever and the browser has the worst UI for upload
progress.
I think you're mistaken, but if you can work up a test I'll gladly
investigate.
> I have no idea why this happens, but chunked post support hides the
> issue. It I wanted to patch in my own support and make it available
> as a discouraged option, where would I start? I can't find anything
> in the http11_parser.rl that says anything at all about chunking, but
> from tracing the code, it looks like the error is coming from the http
> parser.
This won't happen, and I think you're going in the wrong direction.
I've not seen this happen on other sites or other projects, so there's
something you have to be doing wrong. Until you find out why, or try to
use PUT instead, I wouldn't waste time trying to get mongrel2 to support
CE just yet.
--
Zed A. Shaw
http://zedshaw.com/
Re: [mongrel2] Chunked transfer encoding
- From:
- Zed A. Shaw
- Date:
- 2010-12-27 @ 18:01
On Mon, Dec 27, 2010 at 09:52:45AM -0800, Zed A. Shaw wrote:
> This won't happen, and I think you're going in the wrong direction.
> I've not seen this happen on other sites or other projects, so there's
> something you have to be doing wrong. Until you find out why, or try to
> use PUT instead, I wouldn't waste time trying to get mongrel2 to support
> CE just yet.
But, I should clarify, I'm not totally against this, just against doing
it without making sure it really is totally necessary.
So, if you wanted to do it, go look at the
src/http11/httpclient_parser.rl as there's chunked encoding parsing in
there. Then look at how that's handled and probably it'd involve a
similar bit of parsing juggling but on the other side.
Also we hang out on irc.freenode.org#mongrel2 and if you pop in there I
can help get it going. But first make really sure it's necessary, since
what you're experiencing doesn't match what I've experienced.
--
Zed A. Shaw
http://zedshaw.com/