Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test taints only p.val, not the pointer, so it can pass with the old unconditional post-update behavior and fail to detect the regression.
1 open issue
What changed in this PR
Improves CodeQL’s Go data-flow graph by propagating post-update nodes through nested read chains while avoiding unnecessary nodes for read-only pointer dereferences.
Changes:
- Unifies mutation triggers and extends propagation through field reads, indexing, dereferences, and channel receives.
- Removes unconditional post-update nodes for pointer reads, reducing spurious caller updates and redundant paths.
- Adds regression tests, updates expected results, and documents the analysis change.
| File | Description |
|---|---|
go/ql/test/query-tests/Security/CWE-918/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-770/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-643/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-640/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-601/OpenUrlRedirect/OpenUrlRedirect.expected |
Removes redundant post-update path steps. |
go/ql/test/query-tests/Security/CWE-601/OpenUrlRedirect/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-601/BadRedirectCheck/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-347/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-327/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-312/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-190/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-117/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-089/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-079/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-078/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-022/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-020/MissingRegexpAnchor/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegexp/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/query-tests/RedundantCode/DeadStoreOfLocal/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/Types/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/WebSocket/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/frameworks/Twirp/RequestForgery.expected |
Removes spurious parameter-return paths. |
go/ql/test/library-tests/semmle/go/frameworks/Twirp/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/TaintSteps/TaintStep.expected |
Adds propagated post-update taint steps. |
go/ql/test/library-tests/semmle/go/frameworks/TaintSteps/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/SystemCommandExecutors/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/frameworks/Slog/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/frameworks/Revel/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Protobuf/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/GoMicro/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Gin/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Fasthttp/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.expected |
Removes redundant post-update path steps. |
go/ql/test/library-tests/semmle/go/frameworks/Echo/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Chi/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/frameworks/BeegoOrm/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/frameworks/Beego/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/frameworks/Afero/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/dataflow/ThreatModels/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/dataflow/SSA/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/dataflow/PromotedFields/LocalFlowStep.expected |
Removes post-update edges from read-only uses. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.ql |
Limits node assertions to test.go. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go |
Adds read-chain and channel-receive cases. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected |
Updates expected post-update node generation. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/Flows.ql |
Adds the inline flow-test query. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/flows.go |
Tests nested mutations and read-only calls. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/Flows.expected |
Records expected clean flow-test results. |
go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/library-tests/semmle/go/dataflow/GlobalVariableSideEffects/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/dataflow/GlobalValueNumbering/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/dataflow/ExternalValueFlow/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/dataflow/DefaultTaintSanitizer/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/library-tests/semmle/go/concepts/HTTP/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/Unsafe/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/frameworks/CleverGo/CONSISTENCY/DataFlowConsistency.expected |
Clears a reverse-read warning expectation. |
go/ql/test/experimental/CWE-942/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-918/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-840/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-807/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-522-DecompressionBombs/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-369/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-321-V2/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-287/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/experimental/CWE-203/CONSISTENCY/DataFlowConsistency.expected |
Clears reverse-read warning expectations. |
go/ql/test/example-tests/snippets/typeinfo.expected |
Removes a read-only post-update node. |
go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll |
Unifies triggers and propagates nodes through reads. |
go/ql/lib/change-notes/2026-11-25-post-update-nodes.md |
Documents the data-flow analysis improvements. |
Review effort: Max
owen-mc
force-pushed
the
go/missing-post-update-nodes
branch
2 times, most recently
from
December 1, 2026 10:39
e121a13 to
28f0099
Compare
owen-mc
marked this pull request as ready for review
December 1, 2026 10:39
Cover nested receivers and arguments, channel receives, address-of fields, and spurious caller updates after read-only dereferences. Record baseline MISSING and SPURIOUS expectations so later commits expose their effects. Also check value flow through an explicit double-pointer field write. This protects necessary post-update nodes when unconditional dereference nodes are removed, complementing the implicit-dereference cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract insnDirectlyHasPostUpdateNode and inline the write and receiver helpers. Express their existing recursive definitions as closures, keeping the same per-trigger propagation and all dereference triggers. Normalize expression-to-instruction lookups and remove the redundant Method check. This commit changes no test or consistency output; the next commit broadens propagation to all post-update triggers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply predecessor closure to every post-update trigger, rather than only to writes and promoted method receivers, and include channel receives. This adds the missing nodes for nested arguments, receivers, and addresses and resolves the existing reverseRead consistency warnings. Update flow expectations and snapshots for propagation alone. Keep the unconditional dereference triggers and the SPURIOUS backflow expectations so their removal is visible independently in the next commit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop creating post-update nodes merely because a value is dereferenced. The read-chain propagation added in the preceding commit retains the nodes needed for writes and calls, including the explicit double-dereference write covered by the first commit's regression test. This prevents a callee's local pointer reassignment from spuriously flowing back to its caller through a read-only dereference. Remove the SPURIOUS expectations and update the affected node and path snapshots separately from the propagation change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
owen-mc
force-pushed
the
go/missing-post-update-nodes
branch
from
December 1, 2026 11:23
28f0099 to
6d585f9
Compare
aschackmull
reviewed
Dec 3, 2026
aschackmull
reviewed
Dec 3, 2026
aschackmull
left a comment
Contributor
There was a problem hiding this comment.
Besides the nit about the change note, this LGTM.
This branch has not been deployed
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.

Fixes all
Origin of readStep is missing a PostUpdateNode(reverseRead) data-flow consistency warnings in Go and removes spuriousPostUpdateNodes on read-only pointer dereferences.Changes
PostUpdateNodes along the fullreadStepchain: Unified direct triggers ininsnDirectlyHasPostUpdateNode, addedRecvExpr(<-ch) and.stripParens()handling togetAccessPathPredecessorInsn, and definedinsnHasPostUpdateNoderecursively overgetAccessPathPredecessorInsn. Previously, only direct component/pointer writes propagatedPostUpdateNodes up the read chain, leaving call arguments (f(a.b)), method receivers (a.b.m()), and address-of operands (&a.b) withoutPostUpdateNodes on outer bases.PostUpdateNodes on read-only pointer dereferences: Removed unconditionalPostUpdateNodecreation onStarExpr.getBase(),DerefExpr.getOperand(), andEvalImplicitDerefInstruction.getOperand(). Actual mutations through pointers (*x = y,f(*x),(*x).m(),&(*x)) still propagatePostUpdateNodes tox, while pure reads (req.Method,len(params.Text)) no longer turn pointer parameters into taint out-parameters or add redundant[postupdate]path steps.This fixes all data flow consistency alerts, and removes unnecessary edges from 6
.expectedfiles.DCA is neutral. I ran QA on 5000 repos. Performance changes were minimal and not statistically significant. There were alert changes on 69 (repo, query) pairs (with some duplication due to forks). I triaged several of these and they were all correct as far as this PR goes (many were FPs for pre-existing reasons).