Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase tar Security #7

Open
peterstory opened this issue Mar 5, 2024 · 1 comment
Open

Increase tar Security #7

peterstory opened this issue Mar 5, 2024 · 1 comment

Comments

@peterstory
Copy link
Contributor

Python's tarfile module has options to increase the security of files received. We should enable this option after updating to Python 3.12.

https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall
https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter

@peterstory peterstory self-assigned this Mar 5, 2024
@peterstory
Copy link
Contributor Author

Enabling this option will be a one-line change:

diff --git a/src/pydiode/tar.py b/src/pydiode/tar.py
index 991b43e..ecfce64 100644
--- a/src/pydiode/tar.py
+++ b/src/pydiode/tar.py
@@ -36,7 +36,7 @@ def main():
     elif "path" in args:
         try:
             with tarfile.open(fileobj=sys.stdin.buffer, mode="r|") as tar:
-                tar.extractall(args.path)
+                tar.extractall(args.path, filter="data")
         # Don't print the full stack trace for known error types
         except tarfile.ReadError as e:
             if str(e) == "empty file":

@peterstory peterstory removed their assignment Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant