Skip to content

Commit 2ad9b84

Browse files
committed
JS: fix FP for js/unsafe-jquery-plugin
1 parent cfd567f commit 2ad9b84

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

javascript/ql/src/semmle/javascript/security/dataflow/UnsafeJQueryPlugin.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ module UnsafeJQueryPlugin {
3232
DataFlow::localFieldStep(src, sink)
3333
}
3434

35+
override predicate isSanitizerEdge(DataFlow::Node pred, DataFlow::Node succ) {
36+
// prefixing prevents forced html/css confusion:
37+
38+
// prefixing through concatenation:
39+
succ.asExpr().(AddExpr).getRightOperand().flow() = pred
40+
or
41+
// prefixing through a poor-mans templating system:
42+
exists(DataFlow::MethodCallNode replace |
43+
replace = succ and
44+
pred = replace.getArgument(1) and
45+
replace.getMethodName() = "replace"
46+
)
47+
}
48+
3549
override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode node) {
3650
super.isSanitizerGuard(node) or
3751
node instanceof IsElementSanitizer or

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@ nodes
110110
| unsafe-jquery-plugin.js:157:44:157:59 | options.target.a |
111111
| unsafe-jquery-plugin.js:160:38:160:44 | options |
112112
| unsafe-jquery-plugin.js:160:38:160:44 | options |
113-
| unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target |
114-
| unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target |
115-
| unsafe-jquery-plugin.js:161:17:161:23 | options |
116-
| unsafe-jquery-plugin.js:161:17:161:30 | options.target |
117-
| unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) |
118-
| unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) |
119-
| unsafe-jquery-plugin.js:163:40:163:46 | options |
120-
| unsafe-jquery-plugin.js:163:40:163:53 | options.target |
121113
| unsafe-jquery-plugin.js:165:7:165:29 | target |
122114
| unsafe-jquery-plugin.js:165:16:165:22 | options |
123115
| unsafe-jquery-plugin.js:165:16:165:29 | options.target |
@@ -230,18 +222,8 @@ edges
230222
| unsafe-jquery-plugin.js:157:44:157:50 | options | unsafe-jquery-plugin.js:157:44:157:57 | options.target |
231223
| unsafe-jquery-plugin.js:157:44:157:57 | options.target | unsafe-jquery-plugin.js:157:44:157:59 | options.target.a |
232224
| unsafe-jquery-plugin.js:157:44:157:57 | options.target | unsafe-jquery-plugin.js:157:44:157:59 | options.target.a |
233-
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:161:17:161:23 | options |
234-
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:161:17:161:23 | options |
235-
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:163:40:163:46 | options |
236-
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:163:40:163:46 | options |
237225
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:165:16:165:22 | options |
238226
| unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:165:16:165:22 | options |
239-
| unsafe-jquery-plugin.js:161:17:161:23 | options | unsafe-jquery-plugin.js:161:17:161:30 | options.target |
240-
| unsafe-jquery-plugin.js:161:17:161:30 | options.target | unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target |
241-
| unsafe-jquery-plugin.js:161:17:161:30 | options.target | unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target |
242-
| unsafe-jquery-plugin.js:163:40:163:46 | options | unsafe-jquery-plugin.js:163:40:163:53 | options.target |
243-
| unsafe-jquery-plugin.js:163:40:163:53 | options.target | unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) |
244-
| unsafe-jquery-plugin.js:163:40:163:53 | options.target | unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) |
245227
| unsafe-jquery-plugin.js:165:7:165:29 | target | unsafe-jquery-plugin.js:170:6:170:11 | target |
246228
| unsafe-jquery-plugin.js:165:7:165:29 | target | unsafe-jquery-plugin.js:170:6:170:11 | target |
247229
| unsafe-jquery-plugin.js:165:16:165:22 | options | unsafe-jquery-plugin.js:165:16:165:29 | options.target |
@@ -268,6 +250,4 @@ edges
268250
| unsafe-jquery-plugin.js:155:33:155:38 | target | unsafe-jquery-plugin.js:153:38:153:44 | options | unsafe-jquery-plugin.js:155:33:155:38 | target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:153:19:158:2 | functio ... gged\\n\\t} | '$.fn.my_plugin' plugin |
269251
| unsafe-jquery-plugin.js:156:41:156:54 | options.target | unsafe-jquery-plugin.js:153:38:153:44 | options | unsafe-jquery-plugin.js:156:41:156:54 | options.target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:153:19:158:2 | functio ... gged\\n\\t} | '$.fn.my_plugin' plugin |
270252
| unsafe-jquery-plugin.js:157:44:157:59 | options.target.a | unsafe-jquery-plugin.js:153:38:153:44 | options | unsafe-jquery-plugin.js:157:44:157:59 | options.target.a | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:153:19:158:2 | functio ... gged\\n\\t} | '$.fn.my_plugin' plugin |
271-
| unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target | unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:161:5:161:30 | anyPref ... .target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:160:19:173:2 | functio ... \\t\\t}\\n\\n\\t} | '$.fn.my_plugin' plugin |
272-
| unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) | unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:163:5:163:54 | somethi ... target) | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:160:19:173:2 | functio ... \\t\\t}\\n\\n\\t} | '$.fn.my_plugin' plugin |
273253
| unsafe-jquery-plugin.js:170:6:170:11 | target | unsafe-jquery-plugin.js:160:38:160:44 | options | unsafe-jquery-plugin.js:170:6:170:11 | target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:160:19:173:2 | functio ... \\t\\t}\\n\\n\\t} | '$.fn.my_plugin' plugin |

0 commit comments

Comments
 (0)