I found this after much head scratching wherein:
would work, but
would error (server 500), because instead of looking for config.ru,
rackup would look for "ab" as the rackup file.
This allows arbitrary execution of ruby files on the host:
http://example.com/rackup?-r/tmp/root-me
I can't find the decoding rules, but it might also be possible to do:
http://example.com/rackup?-earbitrary-ruby-code
I suggest that ARGV not be used for options parsing if rackup is being
executed as a CGI handler.
Cheers,
Sam
> I suggest that ARGV not be used for options parsing if rackup is being
> executed as a CGI handler.
Nice find. Probably not a good idea to use rackup for CGI starting
(It never was meant to).
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
> I have difficulty finding a good CGI spec, but it appears that when
> query params does not contain an = sign, at least, the query params
> are tokenized, and passed as the ARGV of the CGI script.
Which web server, btw?
Well, rackup contains code to recognize when it is being run as CGI,
and to use the CGI handler.
What other purpose could this code have if not to support rackup to be
run as a CGI script?
Btw, found some information on this behaviour:
http://hoohoo.ncsa.uiuc.edu/cgi/cl.html
It's Apache, not sure what version, whatever is default at webfaction.com.
Sam
> What other purpose could this code have if not to support rackup to be
> run as a CGI script?
Good point. ;)
I actually didn't know that argv feature. Let's clear ARGV when on
CGI, and only apply #\-lines.
> I suggest that ARGV not be used for options parsing if rackup is being
> executed as a CGI handler.
Please review and test
http://github.com/chneukirchen/rack/commit/d6d0c388ff5aa3b0e43359ec400d8238f23ed1df
Looks good, that's exactly what I did.
Cheers,
Sam