From: Drew Northup Date: Tue, 13 Nov 2012 14:44:06 GMT Subject: Re: [BUG] gitweb: XSS vulnerability of RSS feed Message-ID: In-Reply-To: <20121112202413.GD4623@sigill.intra.peff.net> On Mon, Nov 12, 2012 at 3:24 PM, Jeff King wrote: > On Mon, Nov 12, 2012 at 01:55:46PM -0500, Drew Northup wrote: > >> On Sun, Nov 11, 2012 at 6:28 PM, glpk xypron wrote: >> > Gitweb can be used to generate an RSS feed. >> > >> > Arbitrary tags can be inserted into the XML document describing >> > the RSS feed by careful construction of the URL. >> [...] >> Something like this may be useful to defuse the "file" parameter, but >> I presume a more definitive fix is in order... >> >> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl >> index 10ed9e5..af93e65 100755 >> --- a/gitweb/gitweb.perl >> +++ b/gitweb/gitweb.perl >> @@ -1447,6 +1447,10 @@ sub validate_pathname { >> if ($input =~ m!\0!) { >> return undef; >> } >> + # No XSS inclusions >> + if ($input =~ m!()!){ >> + return undef; >> + } >> return $input; >> } > > This is the wrong fix for a few reasons: > > 1. It is on the input-validation side, whereas the real problem is on > the output-quoting side. Your patch means I could not access a file > called "". What we really want is to have the > unquoted name internally, but then make sure we quote it when > outputting as part of an HTML (or XML) file. I don't buy the argument that we don't need to clean up the input as well. There are scant few of us that are going to name a file "" in this world (I am probably one of them). Input validation is key to keeping problems like this from coming up repeatedly as those writing the guts of programs are typically more interested in getting the "assigned task" done and reporting the output to the user in a safe manner. > 2. Script tags are only part of the problem. They are what make it > obviously a security vulnerability, but it is equally incorrect for > us to show the filename "foo" as bold. I would also not be > surprised if there are other cross-site attacks one can do without > using