Skip to content

Python: Detect tar extraction when members may be None - #23171

Open
owen-mc wants to merge 3 commits into
github:mainfrom
owen-mc:py/fix-tarfile-extractall-fn
Open

owen-mc wants to merge 3 commits into
github:mainfrom
owen-mc:py/fix-tarfile-extractall-fn

Conversation

@owen-mc

@owen-mc owen-mc commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #23153.

Update py/tarslip to treat members=None like an omitted members argument, since both extract the entire archive. Preserve existing extraction-filter checks and handling of explicitly supplied member lists.

DCA showed one extra alert and no significant performance change.

owen-mc and others added 3 commits November 19, 2026 11:16
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat extractall members values that may be None like an omitted members argument, while retaining extraction filter checks.

Fixes github#23153.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The production py/tarslip semantics change lacks final DCA results in the PR description, including an assessment of changed results and whether any unexpected regressions were found.

1 open issue
What changed in this PR

Updates Python’s py/tarslip query to detect whole-archive extraction when members may be None, addressing the detection gap in #23153.

Changes:

  • Recognizes None values, including those passed through variables and wrapper defaults.
  • Adds regression coverage while preserving extraction-filter checks and explicit member-list handling.
  • Updates expected results and adds an analysis change note.
File Description
python/​ql/​test/​query-tests/​Security/​CWE-022-TarSlip/​tarslip.py Adds None, wrapper-default, and safe-extraction test cases.
python/​ql/​test/​query-tests/​Security/​CWE-022-TarSlip/​TarSlip.expected Records new alerts and data-flow paths.
python/​ql/​lib/​semmle/​python/​security/​dataflow/​TarSlipCustomizations.qll Treats members values reaching None like an omitted argument.
python/​ql/​lib/​change-notes/​2026-11-19-tarslip-none-members.md Documents the expanded detection.

Review effort: Max (adaptive)

Comment on lines +99 to +102
(
not exists(call.getParameter(1, "members"))
or
call.getParameter(1, "members").getAValueReachingSink().asExpr() instanceof None
@owen-mc
owen-mc requested a review from a team November 19, 2026 12:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: py/tarslip misses TarFile.extractall calls whose members argument is None, including the CVE-2007-4559 safe_extract helper

2 participants