Skip to content

Commit 4dec7c5

Browse files
authored
Merge pull request #127 from xiemaisi/js/incomplete-sanitisation-doc-improvement
Approved by esben-semmle
2 parents 5d5febf + 58e3845 commit 4dec7c5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

change-notes/1.18/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
| Comparison between inconvertible types | Lower severity | The severity of this rule has been revised to "warning". |
104104
| CORS misconfiguration for credentials transfer | More true-positive results | This rule now treats header names case-insensitively. |
105105
| Hard-coded credentials | More true-positive results | This rule now recognizes secret cryptographic keys. |
106-
| Incomplete sanitization | More true-positive results | This rule now recognizes incomplete URL encoding and decoding. |
106+
| Incomplete string escaping or encoding | Better name, more true-positive results | This rule has been renamed to more clearly reflect its purpose. Also, it now recognizes incomplete URL encoding and decoding. |
107107
| Insecure randomness | More true-positive results | This rule now recognizes secret cryptographic keys. |
108108
| Missing rate limiting | More true-positive results, fewer false-positive results | This rule now recognizes additional rate limiters and expensive route handlers. |
109109
| Missing X-Frame-Options HTTP header | Fewer false-positive results | This rule now treats header names case-insensitively. |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ sanitization. In the latter case, preceding a meta-character with a backslash le
2020
backslash being escaped, but the meta-character appearing un-escaped, which again makes the
2121
sanitization ineffective.
2222
</p>
23+
<p>
24+
Even if the escaped string is not used in a security-critical context, incomplete escaping may
25+
still have undesirable effects, such as badly rendered or confusing output.
26+
</p>
2327
</overview>
2428

2529
<recommendation>

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @name Incomplete sanitization
3-
* @description A sanitizer that does not replace or escape all occurrences of a
4-
* problematic substring may be ineffective.
2+
* @name Incomplete string escaping or encoding
3+
* @description A string transformer that does not replace or escape all occurrences of a
4+
* meta-character may be ineffective.
55
* @kind problem
66
* @problem.severity warning
77
* @precision high
@@ -16,9 +16,6 @@ import javascript
1616

1717
/**
1818
* Gets a character that is commonly used as a meta-character.
19-
*
20-
* We heuristically assume that string replacements involving one of these
21-
* characters are meant to be sanitizers.
2219
*/
2320
string metachar() {
2421
result = "'\"\\&<>\n\r\t*|{}[]%$".charAt(_)
@@ -75,7 +72,7 @@ predicate isBackslashEscape(MethodCallExpr mce, RegExpLiteral re) {
7572
}
7673

7774
/**
78-
* Holds if data flowing into `nd` has no unescaped backslashes.
75+
* Holds if data flowing into `nd` has no un-escaped backslashes.
7976
*/
8077
predicate allBackslashesEscaped(DataFlow::Node nd) {
8178
// `JSON.stringify` escapes backslashes

0 commit comments

Comments
 (0)