Skip to content

Commit 76aca02

Browse files
committed
change the pseudo-property on URL to a two-stage process
1 parent e525cf0 commit 76aca02

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodes
2+
edges
3+
#select

javascript/ql/src/semmle/javascript/dataflow/TaintTracking.qll

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,21 @@ module TaintTracking {
615615
}
616616

617617
/**
618-
* A pseudo-property used to store a value on a `URLSearchParams` that
619-
* can be obtained with a `get` or `getAll` call.
618+
* A pseudo-property a `URL` that stores a value that can be obtained
619+
* with a `get` or `getAll` call to the `searchParams` property.
620620
*/
621621
private string hiddenUrlPseudoProperty() {
622622
result = "$hiddenSearchPararms"
623623
}
624624

625+
/**
626+
* A pseudo-property on a `URLSearchParams` that can be obtained
627+
* with a `get` or `getAll` call.
628+
*/
629+
private string getableUrlPseudoProperty() {
630+
result = "$gettableSearchPararms"
631+
}
632+
625633
/**
626634
* A taint propagating data flow edge arising from URL parameter parsing.
627635
*/
@@ -654,17 +662,18 @@ module TaintTracking {
654662
pred = newUrl.getArgument(0)
655663
)
656664
or
657-
prop = hiddenUrlPseudoProperty() and
665+
prop = getableUrlPseudoProperty() and
658666
isUrlSearchParams(succ, pred)
659667
}
660668

661669
/**
662-
* Holds if the property `prop` should be copied from the object `pred` to the object `succ`.
670+
* Holds if the property `loadStep` should be copied from the object `pred` to the property `storeStep` of object `succ`.
663671
*
664672
* This step is used to copy a value the value of our pseudo-property that can later be accessed using a `get` or `getAll` call.
665673
*/
666-
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
667-
prop = hiddenUrlPseudoProperty() and
674+
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string loadProp, string storeProp) {
675+
loadProp = hiddenUrlPseudoProperty() and
676+
storeProp = getableUrlPseudoProperty() and
668677
exists(DataFlow::PropRead write | write = succ |
669678
write.getPropertyName() = "searchParams" and
670679
write.getBase() = pred
@@ -677,7 +686,7 @@ module TaintTracking {
677686
* This step is used to load the value stored in the hidden pseudo-property.
678687
*/
679688
override predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
680-
prop = hiddenUrlPseudoProperty() and
689+
prop = getableUrlPseudoProperty() and
681690
// this is a call to `get` or `getAll` on a `URLSearchParams` object
682691
exists(string m, DataFlow::MethodCallNode call | call = succ |
683692
call.getMethodName() = m and

javascript/ql/test/query-tests/Security/CWE-079/tst.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,8 @@ function URLPseudoProperties() {
335335
let params = getTaintedUrl().searchParams;
336336
$('name').html(params.get('name'));
337337

338+
// OK (.get is not defined on a URL)
339+
let myUrl = getTaintedUrl();
340+
$('name').html(myUrl.get('name'));
341+
338342
}

0 commit comments

Comments
 (0)