mirror of https://github.com/zulip/zulip.git
export: Harden s3 export against directory traversal.
This commit modifies 'zerver/lib/export.py' to raise an exception in the presence of a suspected attempt at directory traversal.
This commit is contained in:
parent
3e602a9bd4
commit
5dca599481
|
@ -1235,6 +1235,9 @@ def _save_s3_object_to_file(key: Key, output_dir: str, processing_avatars: bool,
|
|||
raise AssertionError("Suspicious key with invalid format %s" % (key.name,))
|
||||
filename = os.path.join(output_dir, key.name)
|
||||
|
||||
if "../" in filename:
|
||||
raise AssertionError("Suspicious file with invalid format %s" % (filename,))
|
||||
|
||||
dirname = os.path.dirname(filename)
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
|
|
Loading…
Reference in New Issue