comparison mercurial/hgweb/hgweb_mod.py @ 26120:1a45e49a6bed stable 3.5.1

hgweb: fix trust of templates path (BC) Long ago we disabled trust of the templates path with a comment describing the (insecure) behavior before the change. At some later refactor, the code was apparently changed back to match the comment, unaware that the intent of the comment was to describe the behavior to avoid. This change disables the trust and updates the comment to explicitly say not only what the old problem was, but also that it was in fact a problem and the action taken to prevent it. Impact: prior to this change, if you had a UNIX-based hgweb server where users can write hgrc files, those users could potentially read any file readable by the web server. This is marked as a backwards compatibility issue because people may have configured templates without proper trust settings. Issue spotted by Greg Szorc.
author Matt Mackall <mpm@selenic.com>
date Tue, 01 Sep 2015 16:08:07 -0500
parents 1c2a8db33b8f
children f77a3f27cea5 ee31ede3afb8
comparison
equal deleted inserted replaced
26119:65d2538ac993 26120:1a45e49a6bed
87 self.repostate = ((-1, -1), (-1, -1)) 87 self.repostate = ((-1, -1), (-1, -1))
88 self.mtime = -1 88 self.mtime = -1
89 self.reponame = name 89 self.reponame = name
90 self.archives = 'zip', 'gz', 'bz2' 90 self.archives = 'zip', 'gz', 'bz2'
91 self.stripecount = 1 91 self.stripecount = 1
92 # a repo owner may set web.templates in .hg/hgrc to get any file 92 # we use untrusted=False to prevent a repo owner from using
93 # readable by the user running the CGI script 93 # web.templates in .hg/hgrc to get access to any file readable
94 self.templatepath = self.config('web', 'templates') 94 # by the user running the CGI script
95 self.templatepath = self.config('web', 'templates', untrusted=False)
95 self.websubtable = self.loadwebsub() 96 self.websubtable = self.loadwebsub()
96 97
97 # The CGI scripts are often run by a user different from the repo owner. 98 # The CGI scripts are often run by a user different from the repo owner.
98 # Trust the settings from the .hg/hgrc files by default. 99 # Trust the settings from the .hg/hgrc files by default.
99 def config(self, section, name, default=None, untrusted=True): 100 def config(self, section, name, default=None, untrusted=True):