Skip to content

Commit 16c95d8

Browse files
authored
Merge pull request github#1876 from esben-semmle/js/more-delimiter-stripping-whitelisting
Approved by xiemaisi
2 parents 6d8a438 + a9665f5 commit 16c95d8

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

change-notes/1.23/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
| **Query** | **Expected impact** | **Change** |
2121
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
22+
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false-positive results | This rule now recognizes additional ways delimiters can be stripped away. |
2223
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
2324
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving functions that manipulate DOM event handler attributes are now recognized. |
2425
| Prototype pollution (`js/prototype-pollution`) | More results | The query now highlights vulnerable uses of jQuery and Angular, and the results are shown on LGTM by default. |

javascript/ql/src/Security/CWE-116/IncompleteSanitization.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ predicate isDelimiterUnwrapper(
122122
left = "{" and right = "}"
123123
or
124124
left = "(" and right = ")"
125+
or
126+
left = "\"" and right = "\""
127+
or
128+
left = "'" and right = "'"
125129
|
126130
removesFirstOccurence(leftUnwrap, left) and
127131
removesFirstOccurence(rightUnwrap, right) and

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,8 @@ app.get('/some/path', function(req, res) {
192192
var indirect = /'/;
193193
return s.replace(indirect, ""); // NOT OK
194194
});
195+
196+
(function (s) {
197+
s.replace('"', '').replace('"', ''); // OK
198+
s.replace("'", "").replace("'", ""); // OK
199+
});

0 commit comments

Comments
 (0)