# HG changeset patch # User Mads Kiilerich # Date 2019-02-11 21:36:55 # Node ID 109b068ba6e5efc80b4479a2dc7b6c2edd259b57 # Parent 2ac4499b25eb814bee28917692dd02fcee85d228 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 @@ -298,7 +298,7 @@ $(document).ready(function(){ var title_tmpl = ${h.jshtml(_('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);