Skip to content

Commit 9f100ef

Browse files
committed
add local flow when recognizing Object.assign calls for library-inputs
1 parent 5157d4d commit 9f100ef

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

javascript/ql/lib/semmle/javascript/PackageExports.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ private DataFlow::Node getAValueExportedByPackage() {
200200
or
201201
// Object.assign and friends
202202
exists(ExtendCall assign |
203-
getAValueExportedByPackage() = [assign, assign.getDestinationOperand()] and
203+
getAValueExportedByPackage() =
204+
[assign, assign.getDestinationOperand(), assign.getDestinationOperand().getALocalSource()]
205+
|
204206
result = assign.getASourceOperand()
205207
)
206208
or

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/PolynomialBackTracking.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
| lib/lib.js:36:3:36:4 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3636
| lib/lib.js:42:29:42:30 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3737
| lib/lib.js:45:29:45:30 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
38+
| lib/lib.js:53:6:53:7 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3839
| lib/moduleLib/moduleLib.js:2:3:2:4 | a* | Strings with many repetitions of 'a' can start matching anywhere after the start of the preceeding a*b |
3940
| lib/otherLib/js/src/index.js:2:3:2:4 | a* | Strings with many repetitions of 'a' can start matching anywhere after the start of the preceeding a*b |
4041
| lib/snapdragon.js:7:28:7:29 | a* | Strings starting with 'a' and with many repetitions of 'a' can start matching anywhere after the start of the preceeding aa*$ |

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/PolynomialReDoS.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ nodes
3737
| lib/lib.js:44:12:44:25 | name.substr(1) |
3838
| lib/lib.js:45:17:45:20 | name |
3939
| lib/lib.js:45:17:45:20 | name |
40+
| lib/lib.js:52:22:52:25 | name |
41+
| lib/lib.js:52:22:52:25 | name |
42+
| lib/lib.js:53:16:53:19 | name |
43+
| lib/lib.js:53:16:53:19 | name |
4044
| lib/moduleLib/moduleLib.js:1:28:1:31 | name |
4145
| lib/moduleLib/moduleLib.js:1:28:1:31 | name |
4246
| lib/moduleLib/moduleLib.js:2:13:2:16 | name |
@@ -268,6 +272,10 @@ edges
268272
| lib/lib.js:44:5:44:25 | name | lib/lib.js:45:17:45:20 | name |
269273
| lib/lib.js:44:12:44:15 | name | lib/lib.js:44:12:44:25 | name.substr(1) |
270274
| lib/lib.js:44:12:44:25 | name.substr(1) | lib/lib.js:44:5:44:25 | name |
275+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
276+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
277+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
278+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
271279
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
272280
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
273281
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
@@ -461,6 +469,7 @@ edges
461469
| lib/lib.js:36:2:36:17 | /f*g/.test(name) | lib/lib.js:32:32:32:40 | arguments | lib/lib.js:36:13:36:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:36:3:36:4 | f* | regular expression | lib/lib.js:32:32:32:40 | arguments | library input |
462470
| lib/lib.js:42:17:42:33 | name.match(/f*g/) | lib/lib.js:41:32:41:35 | name | lib/lib.js:42:17:42:20 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:42:29:42:30 | f* | regular expression | lib/lib.js:41:32:41:35 | name | library input |
463471
| lib/lib.js:45:17:45:33 | name.match(/f*g/) | lib/lib.js:41:32:41:35 | name | lib/lib.js:45:17:45:20 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:45:29:45:30 | f* | regular expression | lib/lib.js:41:32:41:35 | name | library input |
472+
| lib/lib.js:53:5:53:20 | /f*g/.test(name) | lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:53:6:53:7 | f* | regular expression | lib/lib.js:52:22:52:25 | name | library input |
464473
| lib/moduleLib/moduleLib.js:2:2:2:17 | /a*b/.test(name) | lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'a'. | lib/moduleLib/moduleLib.js:2:3:2:4 | a* | regular expression | lib/moduleLib/moduleLib.js:1:28:1:31 | name | library input |
465474
| lib/otherLib/js/src/index.js:2:2:2:17 | /a*b/.test(name) | lib/otherLib/js/src/index.js:1:28:1:31 | name | lib/otherLib/js/src/index.js:2:13:2:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'a'. | lib/otherLib/js/src/index.js:2:3:2:4 | a* | regular expression | lib/otherLib/js/src/index.js:1:28:1:31 | name | library input |
466475
| lib/snapdragon.js:7:15:7:32 | this.match(/aa*$/) | lib/snapdragon.js:3:34:3:38 | input | lib/snapdragon.js:7:15:7:18 | this | This $@ that depends on $@ may run slow on strings starting with 'a' and with many repetitions of 'a'. | lib/snapdragon.js:7:28:7:29 | a* | regular expression | lib/snapdragon.js:3:34:3:38 | input | library input |

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/lib/lib.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ module.exports.foo = function (name) {
4343

4444
name = name.substr(1);
4545
var data2 = name.match(/f*g/); // NOT OK
46-
}
46+
}
47+
48+
var indirectAssign = {};
49+
module.exports.indirectAssign = indirectAssign;
50+
51+
Object.assign(indirectAssign, {
52+
myThing: function (name) {
53+
/f*g/.test(name); // NOT OK
54+
},
55+
});

0 commit comments

Comments
 (0)