Skip to content

Commit cd26d97

Browse files
authored
Merge pull request github#6549 from erik-krogh/moreDom
Approved by asgerf
2 parents 5d37748 + 8174252 commit cd26d97

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ module DataFlow {
15911591
*/
15921592
predicate localFieldStep(DataFlow::Node pred, DataFlow::Node succ) {
15931593
exists(ClassNode cls, string prop |
1594-
pred = cls.getAReceiverNode().getAPropertyWrite(prop).getRhs() or
1594+
pred = cls.getADirectSuperClass*().getAReceiverNode().getAPropertyWrite(prop).getRhs() or
15951595
pred = cls.getInstanceMethod(prop)
15961596
|
15971597
succ = cls.getAReceiverNode().getAPropertyRead(prop)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module XssThroughDom {
3030
/**
3131
* Gets a DOM property name that could store user-controlled data.
3232
*/
33-
string unsafeDomPropertyName() { result = ["innerText", "textContent", "value", "name"] }
33+
string unsafeDomPropertyName() { result = ["innerText", "textContent", "value", "name", "src"] }
3434

3535
/**
3636
* A source for text from the DOM from a JQuery method call.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ nodes
118118
| xss-through-dom.js:96:17:96:47 | $("#foo ... ].value |
119119
| xss-through-dom.js:96:17:96:47 | $("#foo ... ].value |
120120
| xss-through-dom.js:96:17:96:47 | $("#foo ... ].value |
121+
| xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
122+
| xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
123+
| xss-through-dom.js:109:45:109:55 | this.el.src |
124+
| xss-through-dom.js:109:45:109:55 | this.el.src |
121125
edges
122126
| forms.js:8:23:8:28 | values | forms.js:9:31:9:36 | values |
123127
| forms.js:8:23:8:28 | values | forms.js:9:31:9:36 | values |
@@ -186,6 +190,10 @@ edges
186190
| xss-through-dom.js:87:36:87:39 | text | xss-through-dom.js:87:16:87:40 | new ans ... s(text) |
187191
| xss-through-dom.js:93:16:93:46 | $("#foo ... ].value | xss-through-dom.js:93:16:93:46 | $("#foo ... ].value |
188192
| xss-through-dom.js:96:17:96:47 | $("#foo ... ].value | xss-through-dom.js:96:17:96:47 | $("#foo ... ].value |
193+
| xss-through-dom.js:109:45:109:55 | this.el.src | xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
194+
| xss-through-dom.js:109:45:109:55 | this.el.src | xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
195+
| xss-through-dom.js:109:45:109:55 | this.el.src | xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
196+
| xss-through-dom.js:109:45:109:55 | this.el.src | xss-through-dom.js:109:31:109:70 | "<a src ... oo</a>" |
189197
#select
190198
| 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 |
191199
| 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 |
@@ -219,3 +227,4 @@ edges
219227
| xss-through-dom.js:87:16:87:40 | new ans ... s(text) | xss-through-dom.js:84:15:84:30 | $("text").text() | xss-through-dom.js:87:16:87:40 | new ans ... s(text) | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:84:15:84:30 | $("text").text() | DOM text |
220228
| xss-through-dom.js:93:16:93:46 | $("#foo ... ].value | xss-through-dom.js:93:16:93:46 | $("#foo ... ].value | xss-through-dom.js:93:16:93:46 | $("#foo ... ].value | $@ is reinterpreted as HTML without escaping meta-characters. | xss-through-dom.js:93:16:93:46 | $("#foo ... ].value | DOM text |
221229
| 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 |
230+
| 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 |

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,17 @@
9595
for (var i = 0; i < foo.length; i++) {
9696
$("#id").html($("#foo").find(".bla")[i].value); // NOT OK.
9797
}
98-
})();
98+
})();
99+
100+
class Super {
101+
constructor() {
102+
this.el = $("#id").get(0);
103+
}
104+
}
105+
106+
class Sub extends Super {
107+
constructor() {
108+
super();
109+
$("#id").get(0).innerHTML = "<a src=\"" + this.el.src + "\">foo</a>"; // NOT OK. Attack: `<mytag id="id" src="x:&quot;&gt;&lt;img src=1 onerror=&quot;alert(1)&quot;&gt;" />`
110+
}
111+
}

0 commit comments

Comments
 (0)