File tree Expand file tree Collapse file tree 2 files changed +7
-19
lines changed
src/semmle/javascript/security/dataflow
test/query-tests/Security/CWE-079 Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ module XssThroughDom {
12
12
import Xss:: XssThroughDom
13
13
private import semmle.javascript.security.dataflow.Xss:: DomBasedXss as DomBasedXss
14
14
private import semmle.javascript.dataflow.InferredTypes
15
+ private import semmle.javascript.security.dataflow.UnsafeJQueryPluginCustomizations:: UnsafeJQueryPlugin as UnsafeJQuery
15
16
16
17
/**
17
18
* A taint-tracking configuration for reasoning about XSS through the DOM.
@@ -30,7 +31,7 @@ module XssThroughDom {
30
31
31
32
override predicate isSanitizerGuard ( TaintTracking:: SanitizerGuardNode guard ) {
32
33
guard instanceof TypeTestGuard or
33
- guard instanceof HasNodePropertySanitizerGuard
34
+ guard instanceof UnsafeJQuery :: PropertyPresenceSanitizer
34
35
}
35
36
}
36
37
@@ -122,22 +123,4 @@ module XssThroughDom {
122
123
e = typeof .getOperand ( )
123
124
}
124
125
}
125
-
126
- /**
127
- * The precense of a `nodeType` or `jquery` property indicates that the value is a DOM node, and not the text of a DOM node.
128
- *
129
- * This sanitizer helps prune infeasible paths in type-overloaded functions.
130
- */
131
- class HasNodePropertySanitizerGuard extends TaintTracking:: SanitizerGuardNode {
132
- DataFlow:: PropRead read ;
133
-
134
- HasNodePropertySanitizerGuard ( ) {
135
- read = this and
136
- read .getPropertyName ( ) = [ "nodeType" , "jquery" ]
137
- }
138
-
139
- override predicate sanitizes ( boolean outcome , Expr e ) {
140
- e = read .getBase ( ) .asExpr ( ) and outcome = true
141
- }
142
- }
143
126
}
Original file line number Diff line number Diff line change 62
62
63
63
var valMethod = $ ( "textarea" ) . val ;
64
64
$ ( "#id" ) . get ( 0 ) . innerHTML = valMethod ( ) ; // NOT OK
65
+
66
+ var myValue = $ ( document ) . find ( "option" ) . attr ( "value" ) ;
67
+ if ( myValue . property ) {
68
+ $ ( "#id" ) . get ( 0 ) . innerHTML = myValue ; // OK.
69
+ }
65
70
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments