File tree Expand file tree Collapse file tree
query-tests/Security/CWE-079 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -291,11 +291,27 @@ module DOM {
291291 */
292292 abstract class Range extends DataFlow:: Node { }
293293
294+ private string getADomPropertyName ( ) {
295+ exists ( ExternalInstanceMemberDecl decl |
296+ result = decl .getName ( ) and
297+ isDomRootType ( decl .getDeclaringType ( ) .getASupertype * ( ) )
298+ )
299+ }
300+
294301 private class DefaultRange extends Range {
295302 DefaultRange ( ) {
296303 this .asExpr ( ) .( VarAccess ) .getVariable ( ) instanceof DOMGlobalVariable
297304 or
298- this = domValueRef ( ) .getAPropertyRead ( )
305+ exists ( DataFlow:: PropRead read |
306+ this = read and
307+ read = domValueRef ( ) .getAPropertyRead ( )
308+ |
309+ not read .mayHavePropertyName ( _)
310+ or
311+ read .mayHavePropertyName ( getADomPropertyName ( ) )
312+ or
313+ read .mayHavePropertyName ( any ( string s | exists ( s .toInt ( ) ) ) )
314+ )
299315 or
300316 this = domElementCreationOrQuery ( )
301317 or
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ test_locationRef
44| customization.js:3:3:3:14 | doc.location |
55test_domValueRef
66| customization.js:4:3:4:28 | doc.get ... 'test') |
7+ | tst.js:49:3:49:8 | window |
8+ | tst.js:50:3:50:8 | window |
Original file line number Diff line number Diff line change 1+ /** @externs */
2+
3+ /**
4+ * @constructor
5+ * @name EventTarget
6+ */
7+ function EventTarget ( ) { }
8+
9+ /** @type {EventTarget } */
10+ var window ;
Original file line number Diff line number Diff line change 3939 factory2 ( ) ;
4040
4141} ) ( ) ;
42+
43+ ( function pollute ( ) {
44+ class C {
45+ foo ( ) {
46+ this . x ; // Should not be a domValueRef
47+ }
48+ }
49+ window . myApp = new C ( ) ;
50+ window . myApp . foo ( ) ;
51+ } ) ( ) ;
Original file line number Diff line number Diff line change 2525function EventTarget ( ) { }
2626
2727/**
28- * @type {!EventTarget }
28+ * Stub for the DOM hierarchy.
29+ *
30+ * @constructor
31+ * @extends {EventTarget }
32+ */
33+ function DomObjectStub ( ) { }
34+
35+ /**
36+ * @type {!DomObjectStub }
37+ */
38+ DomObjectStub . prototype . body ;
39+
40+ /**
41+ * @type {!DomObjectStub }
42+ */
43+ DomObjectStub . prototype . value ;
44+
45+ /**
46+ * @type {!DomObjectStub }
2947 */
3048var document ;
You can’t perform that action at this time.
0 commit comments