Skip to content

Commit e09c124

Browse files
authored
Merge pull request #7105 from erik-krogh/flagJqueryUI
JS: have the aliasPropertyPresenceStep step over extend calls
2 parents 34cc61e + 5d901ef commit e09c124

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

javascript/ql/lib/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,17 @@ module AccessPath {
426426
result = AccessPath::getAReferenceTo(root, accessPath)
427427
)
428428
or
429+
// step over extend calls. Handle aliasing both ways through the extend call.
430+
exists(
431+
DataFlow::SourceNode rootOne, DataFlow::SourceNode rootTwo, string accessPath,
432+
ExtendCall extendCall
433+
|
434+
rootOne = [extendCall, extendCall.getAnOperand().getALocalSource()] and
435+
rootTwo = [extendCall, extendCall.getAnOperand().getALocalSource()] and
436+
node = pragma[only_bind_into](AccessPath::getAReferenceTo(rootOne, accessPath)) and
437+
result = AccessPath::getAReferenceTo(rootTwo, accessPath)
438+
)
439+
or
429440
result = node.getALocalSource()
430441
}
431442

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ nodes
121121
| unsafe-jquery-plugin.js:179:5:179:11 | options |
122122
| unsafe-jquery-plugin.js:179:5:179:18 | options.target |
123123
| unsafe-jquery-plugin.js:179:5:179:18 | options.target |
124+
| unsafe-jquery-plugin.js:185:28:185:34 | options |
125+
| unsafe-jquery-plugin.js:185:28:185:34 | options |
126+
| unsafe-jquery-plugin.js:186:21:186:27 | options |
127+
| unsafe-jquery-plugin.js:186:21:186:30 | options.of |
128+
| unsafe-jquery-plugin.js:192:19:192:28 | options.of |
129+
| unsafe-jquery-plugin.js:192:19:192:28 | options.of |
124130
edges
125131
| unsafe-jquery-plugin.js:2:38:2:44 | options | unsafe-jquery-plugin.js:3:5:3:11 | options |
126132
| unsafe-jquery-plugin.js:2:38:2:44 | options | unsafe-jquery-plugin.js:3:5:3:11 | options |
@@ -245,6 +251,11 @@ edges
245251
| unsafe-jquery-plugin.js:178:27:178:33 | options | unsafe-jquery-plugin.js:179:5:179:11 | options |
246252
| unsafe-jquery-plugin.js:179:5:179:11 | options | unsafe-jquery-plugin.js:179:5:179:18 | options.target |
247253
| unsafe-jquery-plugin.js:179:5:179:11 | options | unsafe-jquery-plugin.js:179:5:179:18 | options.target |
254+
| unsafe-jquery-plugin.js:185:28:185:34 | options | unsafe-jquery-plugin.js:186:21:186:27 | options |
255+
| unsafe-jquery-plugin.js:185:28:185:34 | options | unsafe-jquery-plugin.js:186:21:186:27 | options |
256+
| unsafe-jquery-plugin.js:186:21:186:27 | options | unsafe-jquery-plugin.js:186:21:186:30 | options.of |
257+
| unsafe-jquery-plugin.js:186:21:186:30 | options.of | unsafe-jquery-plugin.js:192:19:192:28 | options.of |
258+
| unsafe-jquery-plugin.js:186:21:186:30 | options.of | unsafe-jquery-plugin.js:192:19:192:28 | options.of |
248259
#select
249260
| unsafe-jquery-plugin.js:3:5:3:11 | options | unsafe-jquery-plugin.js:2:38:2:44 | options | unsafe-jquery-plugin.js:3:5:3:11 | options | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:2:19:63:2 | functio ... \\t\\t}\\n\\n\\t} | '$.fn.my_plugin' plugin |
250261
| unsafe-jquery-plugin.js:5:5:5:18 | options.target | unsafe-jquery-plugin.js:2:38:2:44 | options | unsafe-jquery-plugin.js:5:5:5:18 | options.target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:2:19:63:2 | functio ... \\t\\t}\\n\\n\\t} | '$.fn.my_plugin' plugin |
@@ -268,3 +279,4 @@ edges
268279
| 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 ... NCY]\\n\\t} | '$.fn.my_plugin' plugin |
269280
| 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 |
270281
| unsafe-jquery-plugin.js:179:5:179:18 | options.target | unsafe-jquery-plugin.js:178:27:178:33 | options | unsafe-jquery-plugin.js:179:5:179:18 | options.target | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:178:18:180:2 | functio ... T OK\\n\\t} | '$.fn.my_plugin' plugin |
282+
| unsafe-jquery-plugin.js:192:19:192:28 | options.of | unsafe-jquery-plugin.js:185:28:185:34 | options | unsafe-jquery-plugin.js:192:19:192:28 | options.of | Potential XSS vulnerability in the $@. | unsafe-jquery-plugin.js:185:18:194:2 | functio ... et);\\n\\t} | '$.fn.position' plugin |

javascript/ql/test/query-tests/Security/CWE-079/UnsafeJQueryPlugin/unsafe-jquery-plugin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,14 @@
182182
$(document).find(options.target); // OK
183183
}});
184184

185+
$.fn.position = function( options ) {
186+
if ( !options || !options.of ) {
187+
return doSomethingElse( this, arguments );
188+
}
189+
// extending options
190+
options = $.extend( {}, options );
191+
192+
var target = $( options.of ); // NOT OK
193+
console.log(target);
194+
};
185195
});

0 commit comments

Comments
 (0)