[Mongrel] [SECURITY] DOS In cgi.rb Announced, Upgrade Your Ruby
Zed A. Shaw
zedshaw at zedshaw.com
Mon Dec 4 18:26:21 EST 2006
It's time again for your monthly cgi.rb DOS vulnerability. This latest vulnerability is different from the one that cgi_multipart_eof_fix.gem fixed. This one is related to the boundary taken from the web client being used incorrectly.
You can read about the vulnerability:
The applicable PATCH is here:
For just this vulnerability and if you want both this one and the previous then it's:
The full source is here:
And the original posting from Urabe Shyouhei:
I will NOT be releasing a similar fix gem for Mongrel, and instead will encourage people to either upgrade or apply the patch themselves. I'll sort out if I can do a Mongrel release now that doesn't have the original cgi_multipart_eof_fix gem included as well.
The vulnerability is that when the web browser sends the HTTP request it decides what the boundary should be. The web server has to protect against the client choosing malicious boundaries since it can't be trusted.
In cgi.rb the boundary variable originally was used directly in the later regex without being quoted. This means a client can pick an actual regex that eats the CPU and inject it into the final regex used to find matching boundaries.
COURSE OF ACTION
You have three possible things you can do right now:
1) Apply the above patch to cgi.rb and restart all your mongrel servers.
2) Upgrade to the 1.8.5-p2 version of ruby. Some systems have already started pushing this out.
3) If you can, restrict multipart mime requests to only the URLs that should accept them, and possibly even restrict requests that don't have only alpha-numeric characters in them and dashes. This is risky still, but it might get you over the hump.
If you are totally stuck and still need help I'll be hanging out in the Lingr room for the rest of the evening:
Feel free to bug me with questions.
Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://www.awprofessional.com/title/0321483502 -- The Mongrel Book
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
More information about the Mongrel-users