Skip to content

Python: Fix argument positions and parameter names in py/tarslip sinks - #23119

Open
sam-robson wants to merge 1 commit into
mainfrom
sam-robson/py-tarslip-sink-args
Open

sam-robson wants to merge 1 commit into
mainfrom
sam-robson/py-tarslip-sink-args

Conversation

@sam-robson

@sam-robson sam-robson commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #23114

API::CallNode.getParameter(i) indexes arguments from 0 without counting self, so the py/tarslip sinks were off against TarFile:

TarFile.extract(   member,   path="", ...)        # 0: "member"
TarFile.extractall(path=".", members=None, ...)   # 0: "path", 1: "members"

ExtractSink now matches member= keyword calls, and ExtractAllSink and ExtractMembersSink check members at index 1 instead of 2 and 0.

@sam-robson
sam-robson marked this pull request as ready for review November 12, 2026 17:09
@sam-robson
sam-robson requested a review from a team as a code owner November 12, 2026 17:09
Copilot AI auto review requested due to automatic review settings November 12, 2026 17:09

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 change alters production py/tarslip sink semantics, but the review lacks DCA results for the final version to assess changed alerts and unexpected regressions.

1 open issue
What changed in this PR

This pull request corrects py/tarslip sink modeling for TarFile.extract and TarFile.extractall, ensuring positional and keyword arguments map to the proper parameters and adding regression coverage.

Changes:

  • Updates sink definitions to recognize extract(member=...) and use the correct zero-based extractall member position.
  • Adds regression tests for keyword and positional argument handling.
  • Updates generated query expectations and adds a minor analysis change note.
File Description
python/​ql/​test/​query-tests/​Security/​CWE-022-TarSlip/​tarslip.py Adds regression cases covering keyword extract arguments and positional extractall member arguments.
python/​ql/​test/​query-tests/​Security/​CWE-022-TarSlip/​TarSlip.expected Records the expected query results for the added TarSlip regression cases.
python/​ql/​lib/​semmle/​python/​security/​dataflow/​TarSlipCustomizations.qll Corrects sink parameter names and positions for extract and extractall calls.
python/​ql/​lib/​change-notes/​2026-11-12-tarslip-sink-arguments.md Documents the TarSlip sink-modeling analysis correction.

Review effort: Lite (auto)

call =
API::moduleImport("tarfile").getMember("open").getReturn().getMember("extract").getACall() and
this = call.getArg(0) and
this = call.getParameter(0, "member").asSink() and

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: Do the py/tarslip sinks use the wrong argument positions for TarFile.extract and TarFile.extractall?

2 participants