8000 Safer tarfile extraction by danielhollas · Pull Request #556 · aiidalab/aiidalab · GitHub
[go: up one dir, main page]

Skip to content

Safer tarfile extraction - #556

Merged
danielhollas merged 1 commit into
mainfrom
extractall-filter
Oct 13, 2026
Merged

danielhollas merged 1 commit into
mainfrom
extractall-filter

Conversation

@danielhollas
@danielhollas danielhollas commented Oct 13, 2026 •
Copy link
Copy Markdown
Contributor

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 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

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
@codecov
codecov Bot commented Oct 13, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.88%. Comparing base (5f284df) to head (b20f1da).

Files with missing lines Patch % Lines
aiidalab/app.py 0.00% 1 Missing ⚠️
aiidalab/fetch.py 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
py-3.12 76.88% <0.00%> (+0.47%) ⬆️
py-3.14 76.77% <0.00%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

8000
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@edan-bainglass edan-bainglass left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks for protecting us against all those malicicicious tarfiles 🙂

@danielhollas
danielhollas merged commit ca4414f into main Oct 13, 2026
9 of 10 checks passed
@danielhollas
danielhollas deleted the extractall-filter branch October 13, 2026 20:52
@danielhollas danielhollas added the enhancement New feature or request label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TarFile.extractall DeprecationWarning safe_extract function is unsafe

3 participants

0