NAS: Prevent download path attack.

This commit is contained in:
Admiral H. Curtiss
2014-05-27 15:01:59 +02:00
parent e7ff9e5a67
commit c6cb8d0f6f

View File

@@ -149,8 +149,14 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
action = post["action"]
ret = ""
dlcpath = "dlc/" + post["gamecd"]
dlcdir = os.path.abspath('dlc')
dlcpath = os.path.abspath("dlc/" + post["gamecd"])
dlc_contenttype = False
if os.path.commonprefix([dlcdir, dlcpath]) != dlcdir:
logging.log(logging.WARNING, 'Attempted directory traversal attack "%s", cancelling.', dlcpath)
self.send_response(403)
return
def safeloadfi(fn, mode='rb'):
'''