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
Comment on lines
+82
to
+87
| func calleeReadsOnly(p *inner) { | ||
| if p == nil { | ||
| p = &inner{val: source()} | ||
| } | ||
| _ = p.val | ||
| } |
…ences Propagate PostUpdateNodes recursively along the full readStep predecessor chain (including call arguments, method receivers, address-of operands, and channel receives) and stop generating PostUpdateNodes on read-only pointer dereferences. This resolves all DataFlowConsistency reverseRead warnings across Go tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously, `calleeReadsOnly` assigned `p = &inner{val: source()}`, which
stored taint inside `[PointerContent, FieldContent(val)]` rather than
tainting `p` with an empty access path. Before removing `PostUpdateNode`s
on read-only pointer dereferences, `_ = p.val` generated `p [postupdate]`
and spurious backflow to the caller happened via `referenceStep`
(`implicit-deref p -> p [postupdate]`), an additional taint step that
only fires when `implicit-deref p` has an empty access path. As a result,
`testNoBackflowFromReadOnlyDeref` passed even without the fix.
Assign `p = taint()` from a pointer-returning source instead so `p` itself
is tainted and the test fails without the fix.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
owen-mc
force-pushed
the
go/missing-post-update-nodes
branch
from
November 27, 2026 09:17
8a281d1 to
e121a13
Compare
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.