Repository navigation
Safer tarfile extraction - #556
Conversation
Malicicious tarfile can overwrite arbitrary files by including files with absolute paths or paths containing .. components. [PEP-706](https://peps.python.org/pep-0706/) (implemented in Python 3.12) specifies a new 'filter' argument which allows rejecting the most common types of issues. This PR specifies filter='data', which is the new safer default since python 3.14 https://docs.python.org/3/library/tarfile.html#tarfile.data_filter This also removes an ad-hoc validation added in #316. Closes #555 Closes #487
2473d96 to
b20f1da
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #556 +/- ##
==========================================
+ Coverage 76.40% 76.88% +0.47%
==========================================
Files 18 18
Lines 1776 1765 -11
==========================================
Hits 1357 1357
+ Misses 419 408 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The standard-library data filter addresses the vulnerability and is compatible with the minimum supported Python version.
0 open findings
What changed in this PR
Replaces unsafe tar extraction with Python’s PEP 706 data filter.
Changes:
- Applies
filter="data"to both tar extraction paths. - Removes the flawed custom path-traversal validation.
| File | Description |
|---|---|
aiidalab/fetch.py |
Secures fetched tar archive extraction. |
aiidalab/app.py |
Secures app archive installation and removes custom validation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Cool! Thanks for protecting us against all those malicicicious tarfiles 🙂
Malicicious tarfile can overwrite arbitrary files by including files with absolute paths or paths
containing
..components.PEP-706 (implemented in Python 3.12) specifies a new
filterargument which allows rejecting the most common types of issues.This PR specifies
filter='data', which is the new safer default since python 3.14https://docs.python.org/3/library/tarfile.html#tarfile.data_filter
This also removes an ad-hoc validation added in #316.
Closes #555
Closes #487