@@ -27,6 +27,13 @@ module XssThroughDom {
27
27
result = [ "name" , "value" , "title" , "alt" ]
28
28
}
29
29
30
+ /**
31
+ * Gets a DOM property name that could store user-controlled data.
32
+ */
33
+ string unsafeDomPropertyName ( ) {
34
+ result = [ "innerText" , "textContent" , "value" , "name" ]
35
+ }
36
+
30
37
/**
31
38
* A source for text from the DOM from a JQuery method call.
32
39
*/
@@ -51,14 +58,32 @@ module XssThroughDom {
51
58
}
52
59
}
53
60
61
+ /**
62
+ * A source for text from the DOM from a `d3` method call.
63
+ */
64
+ class D3TextSource extends Source {
65
+ D3TextSource ( ) {
66
+ exists ( DataFlow:: MethodCallNode call , string methodName , string argValue |
67
+ this = call and
68
+ call = D3:: d3Selection ( ) .getMember ( methodName ) .getACall ( ) and
69
+ call .getNumArgument ( ) = 1 and
70
+ call .getArgument ( 0 ) .mayHaveStringValue ( argValue )
71
+ |
72
+ methodName = "attr" and argValue = unsafeAttributeName ( )
73
+ or
74
+ methodName = "property" and argValue = unsafeDomPropertyName ( )
75
+ )
76
+ }
77
+ }
78
+
54
79
/**
55
80
* A source for text from the DOM from a DOM property read or call to `getAttribute()`.
56
81
*/
57
82
class DOMTextSource extends Source {
58
83
DOMTextSource ( ) {
59
84
exists ( DataFlow:: PropRead read | read = this |
60
85
read .getBase ( ) .getALocalSource ( ) = DOM:: domValueRef ( ) and
61
- read .mayHavePropertyName ( [ "innerText" , "textContent" , "value" , "name" ] )
86
+ read .mayHavePropertyName ( unsafeDomPropertyName ( ) )
62
87
)
63
88
or
64
89
exists ( DataFlow:: MethodCallNode mcn | mcn = this |
0 commit comments