This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author v+python
Recipients orsenthil, v+python
Date 2012-04-12.19:01:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334257271.24.0.449019497726.issue14566@psf.upfronthosting.co.za>
In-reply-to
Content
While is_cgi carefully normalizes the path using _url_collapse_path, if it returns True, then run_cgi is called... which sort of starts out using the cgi_info created by is_cgi, but then compares and searches using the original self.path value instead.  This effectively bypasses both the normalization done by _url_collapse_path and the bugs and potential security problems that the normalization was intended to fix!

A simple cure is to replace the first two lines of run_cgi:

        path = self.path
        dir, rest = self.cgi_info

with:

        dir, rest = self.cgi_info
        path = '/'.join([ dir, rest ])

While this works, one might wonder why is_cgi splits the normalized path into two pieces to start with, if it gets recombined, and generally, dir and rest, although initialized from cgi_info, often get recalculated in the loop which immediately follows in run_cgi... more often than you might expect, if an unnormalized path is in the original request, but if the path comes in normalized (or the above fix is applied), and the CGI program actually resides directly in one of the cgi_directories directories (rather than below it), then the dir and rest calculated by is_cgi are actually used, and the loop performs only one half iteration.
History
Date User Action Args
2012-04-12 19:01:11v+pythonsetrecipients: + v+python, orsenthil
2012-04-12 19:01:11v+pythonsetmessageid: <1334257271.24.0.449019497726.issue14566@psf.upfronthosting.co.za>
2012-04-12 19:01:10v+pythonlinkissue14566 messages
2012-04-12 19:01:10v+pythoncreate