Skip to content

Commit bab53e5

Browse files
committed
issue2550701, issue2550891 deal with path traversal issue in TAL based template finding code. Use standard method.
1 parent ea3eab2 commit bab53e5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ Fixed:
286286
Had to explicitly manage transactions with BEGIN IMMEDIATE and call
287287
sql_commit. Note that this reduces performance in return for accuracy.
288288
Problem reported by Matt Mackall (mpm) (John Rouillard).
289+
- issue2550701: Path traversal from template names. This affects the
290+
tal based template engines (zopetal, chameleon). If a directory
291+
with a specific name is created in the html subdirectory, the
292+
template name in the url can be used to get access to files outside
293+
of the tracker html directory. This has been fixed by normalizing
294+
the path and comparing to the normalized path for the html directory.
289295

290296
2016-01-11: 1.5.1
291297

roundup/cgi/templating.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__docformat__ = 'restructuredtext'
2121

2222

23-
import cgi, urllib, re, os.path, mimetypes, csv
23+
import cgi, urllib, re, os.path, mimetypes, csv, string
2424
import calendar
2525
import textwrap
2626

@@ -116,9 +116,14 @@ def __init__(self, dir):
116116
def _find(self, name):
117117
""" Find template, return full path and filename of the
118118
template if it is found, None otherwise."""
119+
realsrc = os.path.realpath(self.dir)
119120
for extension in ['', '.html', '.xml']:
120121
f = name + extension
121-
src = os.path.join(self.dir, f)
122+
src = os.path.join(realsrc, f)
123+
realpath = os.path.realpath(src)
124+
print f, src, realpath, realsrc
125+
if string.find(realpath, realsrc) != 0:
126+
return # will raise invalid template
122127
if os.path.exists(src):
123128
return (src, f)
124129

0 commit comments

Comments
 (0)