Fix an exploitable bug in CGI multipart parsing.


Copyright 2006, 2007 Cloudburst, LLC. Portions copyright 2006 Jeremy Kemper, Jamis Buck, Zed A. Shaw, and Yukihiro Matsumoto, and used with permission. See the included LICENSE file.


Fixes an exploitable bug in CGI multipart parsing which affects Ruby <= 1.8.5. When multipart boundary attributes contain non-halting regular expression strings, the boundary searcher in the CGI module does not properly escape the parameter and will execute arbitrary regular expressions. This fix adds escaping for the user data.

  • Affected application servers: standalone CGI, Mongrel, WEBrick

  • Unaffected: FastCGI, Ruby 1.8.6 (all servers)

  • Unknown: mod_ruby

This fix will not modify versions of Ruby greater than 1.8.5, and is cumulative with previous CGI multipart vulnerability fixes.


Install the gem:

sudo gem install cgi_multipart_eof_fix

Run the included test to verify that the patch works as intended. Then, require the gem in every affected application, as follows:

require 'rubygems' 
require 'cgi_multipart_eof_fix'

Currently mongrel_rails requires this gem automatically. However, Mongrel may change in the future.

Reporting problems

Further resources