# HG changeset patch # User Mads Kiilerich # Date 2019-02-11 21:36:55 # Node ID c9bd000a45675b1029fa19fd25b3db2c37169560 # Parent e74aa69f6827e1f6da4ae94ea2bcac10c98d0203 templates/summary: escape branch/tag/bookmark names in 'Download as zip' links to prevent XSS On a repository summary page, in the 'Download' section where you can download an archive of the repository at a given revision, the branch/tag names were not correctly escaped. This means that if an attacker is able to push a branch/tag/bookmark containing HTML/JavaScript in its name, then that code would be evaluated. This is a cross-site scripting (XSS) vulnerability. Fix the problem by correctly escaping the branch/tag/bookmarks. Reported by Bob Hogg (thanks!). diff --git a/kallithea/templates/summary/summary.html b/kallithea/templates/summary/summary.html --- a/kallithea/templates/summary/summary.html +++ b/kallithea/templates/summary/summary.html @@ -293,7 +293,7 @@ $(document).ready(function(){ var title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}"; title_tmpl= title_tmpl.replace('__CS_NAME__',new_cs.text); title_tmpl = title_tmpl.replace('__CS_EXT__',k); - title_tmpl = ' '+ title_tmpl; + title_tmpl = ' '+ title_tmpl.html_escape(); var url = tmpl_links[k].replace('__CS__',new_cs.id); var subrepos = $('#archive_subrepos').is(':checked'); url = url.replace('__SUB__',subrepos);