mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-08-27 13:24:03 -05:00
NAS: Prevent download path attack.
This commit is contained in:
@@ -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'):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user