C++: Support access paths for sources and sinks - #22374
Draft
MathiasVP wants to merge 10 commits into
Draft
Conversation
MathiasVP
force-pushed
the
cpp-access-paths-for-sources-and-sinks-3
branch
from
August 19, 2026 10:24
e164ec1 to
497d9b6
Compare
MathiasVP
force-pushed
the
cpp-access-paths-for-sources-and-sinks-3
branch
from
August 19, 2026 14:39
497d9b6 to
5077b54
Compare
MathiasVP
marked this pull request as ready for review
August 19, 2026 15:10
Contributor
There was a problem hiding this comment.
Pull request overview
Adds C++ models-as-data support for source and sink access paths in the IR data-flow framework.
Changes:
- Introduces flow-summary reporting nodes for modeled sources and sinks.
- Refactors argument/parameter node handling and consistency checks.
- Updates SQL injection handling, tests, and expected outputs.
Show a summary per file
| File | Description |
|---|---|
cpp/ql/test/query-tests/Security/CWE/CWE-497/semmle/tests/ExposedSystemData.expected |
Updates expected source/sink labels. |
cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted/SqlTainted.expected |
Updates SQL alert locations and labels. |
cpp/ql/test/library-tests/dataflow/models-as-data/testModels.expected |
Records new flow-summary nodes. |
cpp/ql/test/library-tests/dataflow/external-models/test.cpp |
Adds source access-path test cases. |
cpp/ql/test/library-tests/dataflow/external-models/sources.expected |
Updates expected modeled sources. |
cpp/ql/test/library-tests/dataflow/external-models/sinks.expected |
Updates expected modeled sinks. |
cpp/ql/test/library-tests/dataflow/external-models/flow.ext.yml |
Adds field and callback source models. |
cpp/ql/test/library-tests/dataflow/external-models/flow.expected |
Records updated flow graphs. |
cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql |
Supports flow-summary sink nodes. |
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll |
Refactors argument and position abstractions. |
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll |
Exposes and labels source/sink summary nodes. |
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll |
Excludes summary nodes from consistency checks. |
cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll |
Implements C++ source/sink access-path reporting. |
cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll |
Routes modeled sources and sinks through summary nodes. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll:629
- This cannot resolve index
-1, becauseCpp::Parameteronly represents zero-based explicit parameters. However,decodePositionacceptsParameter[-1]and callback-self positions also use-1, so models rooted at that source parameter and source/sink callback paths targeting a member function's receiver cannot obtain a reporting element and silently disappear. Add an explicit representation/mapping for the implicitthisparameter instead of routing it throughCpp::Parameter.
Parameter getParameter(Function f) {
result.getFunction() = f and
this.getArgumentIndex() = result.getIndex()
}
- Files reviewed: 14/14 changed files
- Comments generated: 4
- Review effort level: Balanced
Comment on lines
+577
to
+580
| override predicate summaryArgumentOf( | ||
| FlowSummaryImpl::Public::SummarizedCallable call, ArgumentPosition pos | ||
| ) { | ||
| call = call_.asSummaryCall() and |
Comment on lines
+162
to
+169
| SourceSinkReportingElement getASuccessor(Impl::Private::SummaryComponent sc) { | ||
| exists(ParameterPosition pos | sc = Impl::Private::SummaryComponent::parameter(pos) | | ||
| // Taking the address of a function | ||
| result = pos.getParameter(this.(FunctionAccess).getTarget()) | ||
| or | ||
| // Passing an object with an overloaded `operator()` | ||
| result = pos.getParameter(this.getOperatorCallFunction()) | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
Hm, I think that's true. Thanks, Copilot!
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
MathiasVP
marked this pull request as draft
August 19, 2026 15:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that #22145 has been merged we can finally add MaD support for access paths at sources and sinks.
Commit-by-commit review recommended.
ParameterNodes andArgumentNodes in dataflow which will make the main commit simpler.There's a small change to the
toStringon sources (and sinks) defined in MaD. Previously, it would be thetoStringof the underlying dataflow node. However, due to the way MaD works it's hard (impossible?) to keep this behavior.I need to update an .expected file in the internal repo as well (because of the
toStringchanges). I'll do that once this PR has been reviewed to avoid unnecessary submodule bumps.