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 {
1212 import Xss:: XssThroughDom
1313 private import semmle.javascript.security.dataflow.Xss:: DomBasedXss as DomBasedXss
1414 private import semmle.javascript.dataflow.InferredTypes
15+ private import semmle.javascript.security.dataflow.UnsafeJQueryPluginCustomizations:: UnsafeJQueryPlugin as UnsafeJQuery
1516
1617 /**
1718 * A taint-tracking configuration for reasoning about XSS through the DOM.
@@ -30,7 +31,7 @@ module XssThroughDom {
3031
3132 override predicate isSanitizerGuard ( TaintTracking:: SanitizerGuardNode guard ) {
3233 guard instanceof TypeTestGuard or
33- guard instanceof HasNodePropertySanitizerGuard
34+ guard instanceof UnsafeJQuery :: PropertyPresenceSanitizer
3435 }
3536 }
3637
@@ -122,22 +123,4 @@ module XssThroughDom {
122123 e = typeof .getOperand ( )
123124 }
124125 }
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- }
143126}
Original file line number Diff line number Diff line change 6262
6363 var valMethod = $ ( "textarea" ) . val ;
6464 $ ( "#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+ }
6570} ) ( ) ;
You can’t perform that action at this time.
0 commit comments