Skip to content

Commit bbc7441

Browse files
author
Richard Jones
committed
fix security hole in serve_static_file
1 parent 928bad9 commit bbc7441

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

CHANGES.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ Feature:
88
- implement __nonzero__ for HTMLProperty
99

1010

11-
2004-05-?? 0.7.3
11+
2004-05-28 0.7.3
1212
Fixed:
1313
- add "checked" to truth values for Boolean input
1414
- fixed import in metakit backend
1515
- fix SearchAction use of Class.filter(), and clarify API docs for same
16+
- ensure static files may only be served out of the tracker's "static
17+
files" directory
1618

1719

18-
2004-05-?? 0.7.2
20+
2004-05-17 0.7.2
1921
Fixed:
2022
- anydbm sorting with None values (sf bug 952853)
2123
- roundup-server -g option not recognised (sf bug 952310)
@@ -200,7 +202,14 @@ Cleanup:
200202
class
201203

202204

203-
2004-??-?? 0.6.9
205+
2004-05-17 0.6.10
206+
Fixed:
207+
- mysql backend wasn't locking tracker
208+
- ensure static files may only be served out of the tracker's "static
209+
files" directory
210+
211+
212+
2004-04-18 0.6.9
204213
Fixed:
205214
- paging in classhelp popup was broken
206215
- 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.177 2004-05-11 13:32:05 a1s Exp $
1+
# $Id: client.py,v 1.178 2004-05-27 21:51:43 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -519,7 +519,13 @@ def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')):
519519
def serve_static_file(self, file):
520520
''' Serve up the file named from the templates dir
521521
'''
522-
filename = os.path.join(self.instance.config.TEMPLATES, file)
522+
# figure the filename - ensure the load doesn't try to poke
523+
# outside of the static files dir
524+
prefix = getattr(self.instance.config, 'STATIC_FILES',
525+
self.instance.config.TEMPLATES)
526+
filename = os.path.normpath(os.path.join(prefix, file))
527+
if not filename.startswith(prefix):
528+
raise NotFound, file
523529

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

0 commit comments

Comments
 (0)