Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 9e4ee0a

Browse files
committed
OAuth2 constant state query: trace local URLs across reference operations and Sprintf calls
1 parent 050a823 commit 9e4ee0a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ql/src/experimental/CWE-352/ConstantOauth2State.ql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,27 @@ class PrivateUrlFlowsToAuthCodeUrlCall extends DataFlow::Configuration {
6565
/**
6666
* Propagates a URL written to a RedirectURL field to the whole Config object.
6767
*/
68-
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
68+
predicate isUrlTaintingConfigStep(DataFlow::Node pred, DataFlow::Node succ) {
6969
exists(Write w, Field f | f.hasQualifiedName("golang.org/x/oauth2", "Config", "RedirectURL") |
7070
w.writesField(succ.(DataFlow::PostUpdateNode).getPreUpdateNode(), f, pred)
7171
)
7272
}
7373

74+
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
75+
// Propagate from a RedirectURL field to a whole Config
76+
isUrlTaintingConfigStep(pred, succ)
77+
or
78+
// Propagate across deref and address-taking steps
79+
TaintTracking::referenceStep(pred, succ)
80+
or
81+
// Propagate across Sprintf and similar calls
82+
exists(DataFlow::CallNode c |
83+
c = any(Fmt::Sprinter s).getACall() and
84+
pred = c.getAnArgument() and
85+
succ = c.getResult()
86+
)
87+
}
88+
7489
predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) {
7590
exists(AuthCodeURL m | call = m.getACall() | sink = call.getReceiver())
7691
}

0 commit comments

Comments
 (0)