gromero commented on code in PR #13751:
URL: https://github.com/apache/tvm/pull/13751#discussion_r1066285222
##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -657,7 +657,26 @@ def generate_project(self, model_library_format_path,
standalone_crt_dir, projec
# Populate extra_files
if extra_files_tar:
with tarfile.open(extra_files_tar, mode="r:*") as tf:
- tf.extractall(project_dir)
+
+ def is_within_directory(directory, target):
+
+ abs_directory = os.path.abspath(directory)
+ abs_target = os.path.abspath(target)
+
+ prefix = os.path.commonprefix([abs_directory, abs_target])
+
+ return prefix == abs_directory
+
+ def safe_extract(tar, path=".", members=None, *,
numeric_owner=False):
+
+ for member in tar.getmembers():
+ member_path = os.path.join(path, member.name)
+ if not is_within_directory(path, member_path):
+ raise Exception("Attempted Path Traversal in Tar
File")
Review Comment:
Same as above about adding the CVE #.
(edit) It seems the I missed to include the above comment I mention here.
what I suggested was something similar to:
`"Attempted Path Traversal in Tar File attack. See CVE-2007-4559."`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]