Skip to content

Commit

Permalink
Do not allow access to resources outside of static.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosmann authored and tcstewar committed Apr 17, 2018
1 parent e343b13 commit a876b11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nengo_gui/guibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ def login_page(self):
@RequireAuthentication('/login')
def serve_static(self):
"""Handles http://host:port/static/* by returning pkg data"""
fn = os.path.join('static', self.resource)
assert self.resource[0] == '/'
static_dir = 'static' + os.sep
fn = os.path.normpath(self.resource[1:])
if os.path.commonprefix((static_dir, fn)) != static_dir:
raise server.Forbidden()
mimetype, encoding = mimetypes.guess_type(fn)
data = pkgutil.get_data('nengo_gui', fn)
return server.HttpResponse(data, mimetype)
Expand Down

0 comments on commit a876b11

Please sign in to comment.