Skip to content

Commit 671a2fe

Browse files
author
Richard Jones
committed
fix security hole in serve_static_file
1 parent e701212 commit 671a2fe

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGES.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Fixed:
66
- add "checked" to truth values for Boolean input
77
- fixed import in metakit backend
88
- fix SearchAction use of Class.filter(), and clarify API docs for same
9+
- ensure static files may only be served out of the tracker's "static
10+
files" directory
911

1012

1113
2004-05-17 0.7.2
@@ -193,7 +195,14 @@ Cleanup:
193195
class
194196

195197

196-
2004-??-?? 0.6.9
198+
2004-05-17 0.6.10
199+
Fixed:
200+
- mysql backend wasn't locking tracker
201+
- ensure static files may only be served out of the tracker's "static
202+
files" directory
203+
204+
205+
2004-04-18 0.6.9
197206
Fixed:
198207
- paging in classhelp popup was broken
199208
- socket timeout error logging can fail

roundup/cgi/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.176 2004-05-04 05:56:54 richard Exp $
1+
# $Id: client.py,v 1.176.2.1 2004-05-27 21:52:44 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -455,7 +455,13 @@ def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')):
455455
def serve_static_file(self, file):
456456
''' Serve up the file named from the templates dir
457457
'''
458-
filename = os.path.join(self.instance.config.TEMPLATES, file)
458+
# figure the filename - ensure the load doesn't try to poke
459+
# outside of the static files dir
460+
prefix = getattr(self.instance.config, 'STATIC_FILES',
461+
self.instance.config.TEMPLATES)
462+
filename = os.path.normpath(os.path.join(prefix, file))
463+
if not filename.startswith(prefix):
464+
raise NotFound, file
459465

460466
# last-modified time
461467
lmt = os.stat(filename)[stat.ST_MTIME]

0 commit comments

Comments
 (0)