Skip to content

Commit 0f0ecf6

Browse files
committed
gitweb: escape html in rss title
The title of an RSS feed is generated from many components, including the filename provided as a query parameter, but we failed to quote it. Besides showing the wrong output, this is a vector for XSS attacks. Signed-off-by: Jeff King <[email protected]>
1 parent 7e20105 commit 0f0ecf6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8055,6 +8055,7 @@ sub git_feed {
80558055
$feed_type = 'history';
80568056
}
80578057
$title .= " $feed_type";
8058+
$title = esc_html($title);
80588059
my $descr = git_get_project_description($project);
80598060
if (defined $descr) {
80608061
$descr = esc_html($descr);

t/t9502-gitweb-standalone-parse-output.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,20 @@ test_expect_success 'forks: project_index lists all projects (incl. forks)' '
185185
test_cmp expected actual
186186
'
187187

188+
xss() {
189+
echo >&2 "Checking $1..." &&
190+
gitweb_run "$1" &&
191+
if grep "$TAG" gitweb.body; then
192+
echo >&2 "xss: $TAG should have been quoted in output"
193+
return 1
194+
fi
195+
return 0
196+
}
197+
198+
test_expect_success 'xss checks' '
199+
TAG="<magic-xss-tag>" &&
200+
xss "a=rss&p=$TAG" &&
201+
xss "a=rss&p=foo.git&f=$TAG"
202+
'
188203

189204
test_done

0 commit comments

Comments
 (0)