Skip to content

Commit 37e02e4

Browse files
committed
Added escape as StringManipulationTaintStep.
1 parent 4c77ee2 commit 37e02e4

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ module TaintTracking {
494494
succ = c and
495495
c =
496496
DataFlow::globalVarRef([
497-
"encodeURI", "decodeURI", "encodeURIComponent", "decodeURIComponent", "unescape"
497+
"encodeURI", "decodeURI", "encodeURIComponent", "decodeURIComponent", "unescape",
498+
"escape"
498499
]).getACall() and
499500
pred = c.getArgument(0)
500501
)

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/Xss.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
| string-manipulations.js:8:16:8:48 | documen ... mLeft() | string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() | Cross-site scripting vulnerability due to $@. | string-manipulations.js:8:16:8:37 | documen ... on.href | user-provided value |
121121
| string-manipulations.js:9:16:9:58 | String. ... n.href) | string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:9:36:9:57 | documen ... on.href | user-provided value |
122122
| string-manipulations.js:10:16:10:45 | String( ... n.href) | string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:10:23:10:44 | documen ... on.href | user-provided value |
123+
| string-manipulations.js:11:16:11:45 | escape( ... n.href) | string-manipulations.js:11:23:11:44 | documen ... on.href | string-manipulations.js:11:16:11:45 | escape( ... n.href) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:11:23:11:44 | documen ... on.href | user-provided value |
124+
| string-manipulations.js:12:16:12:61 | escape( ... href))) | string-manipulations.js:12:37:12:58 | documen ... on.href | string-manipulations.js:12:16:12:61 | escape( ... href))) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:12:37:12:58 | documen ... on.href | user-provided value |
123125
| tainted-url-suffix-arguments.js:6:22:6:22 | y | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:6:22:6:22 | y | Cross-site scripting vulnerability due to $@. | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | user-provided value |
124126
| tooltip.jsx:10:25:10:30 | source | tooltip.jsx:6:20:6:30 | window.name | tooltip.jsx:10:25:10:30 | source | Cross-site scripting vulnerability due to $@. | tooltip.jsx:6:20:6:30 | window.name | user-provided value |
125127
| tooltip.jsx:11:25:11:30 | source | tooltip.jsx:6:20:6:30 | window.name | tooltip.jsx:11:25:11:30 | source | Cross-site scripting vulnerability due to $@. | tooltip.jsx:6:20:6:30 | window.name | user-provided value |
@@ -490,6 +492,10 @@ edges
490492
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() | provenance | |
491493
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | provenance | |
492494
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | |
495+
| string-manipulations.js:11:23:11:44 | documen ... on.href | string-manipulations.js:11:16:11:45 | escape( ... n.href) | provenance | |
496+
| string-manipulations.js:12:23:12:60 | escape( ... .href)) | string-manipulations.js:12:16:12:61 | escape( ... href))) | provenance | |
497+
| string-manipulations.js:12:30:12:59 | escape( ... n.href) | string-manipulations.js:12:23:12:60 | escape( ... .href)) | provenance | |
498+
| string-manipulations.js:12:37:12:58 | documen ... on.href | string-manipulations.js:12:30:12:59 | escape( ... n.href) | provenance | |
493499
| tainted-url-suffix-arguments.js:3:17:3:17 | y | tainted-url-suffix-arguments.js:6:22:6:22 | y | provenance | |
494500
| tainted-url-suffix-arguments.js:11:11:11:36 | url | tainted-url-suffix-arguments.js:12:17:12:19 | url | provenance | |
495501
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:11:11:11:36 | url | provenance | |
@@ -1116,6 +1122,12 @@ nodes
11161122
| string-manipulations.js:9:36:9:57 | documen ... on.href | semmle.label | documen ... on.href |
11171123
| string-manipulations.js:10:16:10:45 | String( ... n.href) | semmle.label | String( ... n.href) |
11181124
| string-manipulations.js:10:23:10:44 | documen ... on.href | semmle.label | documen ... on.href |
1125+
| string-manipulations.js:11:16:11:45 | escape( ... n.href) | semmle.label | escape( ... n.href) |
1126+
| string-manipulations.js:11:23:11:44 | documen ... on.href | semmle.label | documen ... on.href |
1127+
| string-manipulations.js:12:16:12:61 | escape( ... href))) | semmle.label | escape( ... href))) |
1128+
| string-manipulations.js:12:23:12:60 | escape( ... .href)) | semmle.label | escape( ... .href)) |
1129+
| string-manipulations.js:12:30:12:59 | escape( ... n.href) | semmle.label | escape( ... n.href) |
1130+
| string-manipulations.js:12:37:12:58 | documen ... on.href | semmle.label | documen ... on.href |
11191131
| tainted-url-suffix-arguments.js:3:17:3:17 | y | semmle.label | y |
11201132
| tainted-url-suffix-arguments.js:6:22:6:22 | y | semmle.label | y |
11211133
| tainted-url-suffix-arguments.js:11:11:11:36 | url | semmle.label | url |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/XssWithAdditionalSources.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ nodes
322322
| string-manipulations.js:9:36:9:57 | documen ... on.href | semmle.label | documen ... on.href |
323323
| string-manipulations.js:10:16:10:45 | String( ... n.href) | semmle.label | String( ... n.href) |
324324
| string-manipulations.js:10:23:10:44 | documen ... on.href | semmle.label | documen ... on.href |
325+
| string-manipulations.js:11:16:11:45 | escape( ... n.href) | semmle.label | escape( ... n.href) |
326+
| string-manipulations.js:11:23:11:44 | documen ... on.href | semmle.label | documen ... on.href |
327+
| string-manipulations.js:12:16:12:61 | escape( ... href))) | semmle.label | escape( ... href))) |
328+
| string-manipulations.js:12:23:12:60 | escape( ... .href)) | semmle.label | escape( ... .href)) |
329+
| string-manipulations.js:12:30:12:59 | escape( ... n.href) | semmle.label | escape( ... n.href) |
330+
| string-manipulations.js:12:37:12:58 | documen ... on.href | semmle.label | documen ... on.href |
325331
| tainted-url-suffix-arguments.js:3:17:3:17 | y | semmle.label | y |
326332
| tainted-url-suffix-arguments.js:6:22:6:22 | y | semmle.label | y |
327333
| tainted-url-suffix-arguments.js:11:11:11:36 | url | semmle.label | url |
@@ -934,6 +940,10 @@ edges
934940
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() | provenance | |
935941
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | provenance | |
936942
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | |
943+
| string-manipulations.js:11:23:11:44 | documen ... on.href | string-manipulations.js:11:16:11:45 | escape( ... n.href) | provenance | |
944+
| string-manipulations.js:12:23:12:60 | escape( ... .href)) | string-manipulations.js:12:16:12:61 | escape( ... href))) | provenance | |
945+
| string-manipulations.js:12:30:12:59 | escape( ... n.href) | string-manipulations.js:12:23:12:60 | escape( ... .href)) | provenance | |
946+
| string-manipulations.js:12:37:12:58 | documen ... on.href | string-manipulations.js:12:30:12:59 | escape( ... n.href) | provenance | |
937947
| tainted-url-suffix-arguments.js:3:17:3:17 | y | tainted-url-suffix-arguments.js:6:22:6:22 | y | provenance | |
938948
| tainted-url-suffix-arguments.js:11:11:11:36 | url | tainted-url-suffix-arguments.js:12:17:12:19 | url | provenance | |
939949
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:11:11:11:36 | url | provenance | |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/string-manipulations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ document.write(document.location.href.toUpperCase()); // $ Alert
88
document.write(document.location.href.trimLeft()); // $ Alert
99
document.write(String.fromCharCode(document.location.href)); // $ Alert
1010
document.write(String(document.location.href)); // $ Alert
11-
document.write(escape(document.location.href)); // OK - for now
12-
document.write(escape(escape(escape(document.location.href)))); // OK - for now
11+
document.write(escape(document.location.href)); // $ SPURIOUS: Alert
12+
document.write(escape(escape(escape(document.location.href)))); // $ SPURIOUS: Alert

0 commit comments

Comments
 (0)