Skip to content

Commit a9665f5

Browse files
author
Esben Sparre Andreasen
committed
JS: whitelist quote stripping for js/incomplete-sanitization
1 parent 641232a commit a9665f5

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

change-notes/1.23/analysis-javascript.md

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

1818
| **Query** | **Expected impact** | **Change** |
1919
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
20+
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false-positive results | This rule now recognizes additional ways delimiters can be stripped away. |
2021
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
2122
| Prototype pollution (`js/prototype-pollution`) | Same results | The results are now shown on LGTM by default. |
2223

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)