Skip to content

Unified: Fix taint inheritance for captured variables - #23326

Draft
asgerf wants to merge 2 commits into
mainfrom
asgerf-capture-taint-inheritance
Draft

asgerf wants to merge 2 commits into
mainfrom
asgerf-capture-taint-inheritance

Conversation

@asgerf

@asgerf asgerf commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: c107ae17fbf43699d698877b303cb4022a06a40a

Dimension Assessment Rationale
Change confidence 9/10 ↑ Focused unified data-flow test passes for negative closure leakage and positive field, tuple, array, and captured-taint cases.
↓ Full unified test suite was not run.
Diagnosis confidence 9.5/10 ↑ A closure taint leak reproduced before the change; the filter prevents it while the new test confirms pre-existing captured taint still propagates.
Evidence fit 9/10 ↑ The regression now covers the exact requested case: a concatenated tainted value captured and read inside a closure.
↓ No broader production reproduction was provided.

Stops converting reads of a captured variable content into a taint step.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Dec 2, 2026
@asgerf
asgerf requested an adaptive review from Copilot December 2, 2026 13:13

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

A positive test is missing to verify that taint already attached to a captured value is preserved when read inside a closure.

1 open issue
What changed in this PR

Refines unified taint tracking so tainted closures no longer automatically taint their captured variables.

Changes:

  • Restricts read-derived taint steps to taint-inheriting contents.
  • Adds Swift regression cases for captures, fields, tuples, and arrays.
File Description
unified/​ql/​test/​library-tests/​dataflow/​test.expected Updates expected dataflow results.
unified/​ql/​test/​library-tests/​dataflow/​capture.swift Adds taint-inheritance regression cases.
unified/​ql/​lib/​codeql/​unified/​internal/​dataflow/​TaintTrackingInstantiation.qll Filters read-derived taint steps.
unified/​ql/​lib/​codeql/​unified/​internal/​dataflow/​Content.qll Defines taint-inheriting contents, excluding captured variables.

Review effort: Max (adaptive)

DataFlowInput::readStep(src, _, sink) and model = ""
exists(ContentSet c |
DataFlowInput::readStep(src, c, sink) and
c.getAReadContent() instanceof TaintInheritingContent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a regression where a concatenated, already-tainted value is captured and read inside a closure. The focused unified data-flow test passes.

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

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

Labels

no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants