Skip to content

Commit b11d48e

Browse files
committed
add files in the DOM as a source for js/xss-through-dom
1 parent 6c70cb4 commit b11d48e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/XssThroughDomCustomizations.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ module XssThroughDom {
162162
}
163163
}
164164

165+
/** The `files` property of an `<input />` element */
166+
class FilesSource extends Source {
167+
FilesSource() { this = DOM::domValueRef().getAPropertyRead("files") }
168+
}
169+
165170
/**
166171
* A module for form inputs seen as sources for xss-through-dom.
167172
*/

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ nodes
129129
| xss-through-dom.js:115:16:115:18 | src |
130130
| xss-through-dom.js:117:26:117:28 | src |
131131
| xss-through-dom.js:117:26:117:28 | src |
132+
| xss-through-dom.js:120:23:120:37 | ev.target.files |
133+
| xss-through-dom.js:120:23:120:37 | ev.target.files |
134+
| xss-through-dom.js:120:23:120:40 | ev.target.files[0] |
135+
| xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name |
136+
| xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name |
132137
edges
133138
| forms.js:8:23:8:28 | values | forms.js:9:31:9:36 | values |
134139
| forms.js:8:23:8:28 | values | forms.js:9:31:9:36 | values |
@@ -207,6 +212,10 @@ edges
207212
| xss-through-dom.js:114:11:114:52 | src | xss-through-dom.js:117:26:117:28 | src |
208213
| xss-through-dom.js:114:17:114:52 | documen ... k").src | xss-through-dom.js:114:11:114:52 | src |
209214
| xss-through-dom.js:114:17:114:52 | documen ... k").src | xss-through-dom.js:114:11:114:52 | src |
215+
| xss-through-dom.js:120:23:120:37 | ev.target.files | xss-through-dom.js:120:23:120:40 | ev.target.files[0] |
216+
| xss-through-dom.js:120:23:120:37 | ev.target.files | xss-through-dom.js:120:23:120:40 | ev.target.files[0] |
217+
| xss-through-dom.js:120:23:120:40 | ev.target.files[0] | xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name |
218+
| xss-through-dom.js:120:23:120:40 | ev.target.files[0] | xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name |
210219
#select
211220
| forms.js:9:31:9:40 | values.foo | forms.js:8:23:8:28 | values | forms.js:9:31:9:40 | values.foo | $@ is reinterpreted as HTML without escaping meta-characters. | forms.js:8:23:8:28 | values | DOM text |
212221
| forms.js:12:31:12:40 | values.bar | forms.js:11:24:11:29 | values | forms.js:12:31:12:40 | values.bar | $@ is reinterpreted as HTML without escaping meta-characters. | forms.js:11:24:11:29 | values | DOM text |
@@ -242,3 +251,4 @@ edges
242251
| xss-through-dom.js:96:17:96:47 | $("#foo ... ].value | xss-through-dom.js:96:17:96:47 | $("#foo ... ].value | xss-through-dom.js:96:17:96:47 | $("#foo ... ].value | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:96:17:96:47 | $("#foo ... ].value | DOM text |
243252
| xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" | xss-through-dom.js:109:45:109:55 | this.el.src | xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:109:45:109:55 | this.el.src | DOM text |
244253
| xss-through-dom.js:115:16:115:18 | src | xss-through-dom.js:114:17:114:52 | documen ... k").src | xss-through-dom.js:115:16:115:18 | src | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:114:17:114:52 | documen ... k").src | DOM text |
254+
| xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name | xss-through-dom.js:120:23:120:37 | ev.target.files | xss-through-dom.js:120:23:120:45 | ev.targ ... 0].name | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:120:23:120:37 | ev.target.files | DOM text |

javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/xss-through-dom.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,8 @@ class Sub extends Super {
115115
$("#id").html(src); // NOT OK.
116116

117117
$("#id").attr("src", src); // OK
118+
119+
$("input.foo")[0].onchange = function (ev) {
120+
$("#id").html(ev.target.files[0].name); // NOT OK.
121+
}
118122
})();

0 commit comments

Comments
 (0)