@@ -23,13 +23,13 @@ class AbstractDOMParser extends Class {
2323
2424class DisableDefaultEntityResolution extends Function {
2525 DisableDefaultEntityResolution ( ) {
26- this .hasQualifiedName ( _, "XercesDOMParser " , "disableDefaultEntityResolution " )
26+ this .hasQualifiedName ( _, "AbstractOMParser " , "setDisableDefaultEntityResolution " )
2727 }
2828}
2929
3030class SetCreateEntityReferenceNodes extends Function {
3131 SetCreateEntityReferenceNodes ( ) {
32- this .hasQualifiedName ( _, "XercesDOMParser " , "setCreateEntityReferenceNodes" )
32+ this .hasQualifiedName ( _, "AbstractDOMParser " , "setCreateEntityReferenceNodes" )
3333 }
3434}
3535
@@ -39,18 +39,36 @@ class CreateLSParser extends Function {
3939 }
4040}
4141
42+ class SetSecurityManager extends Function {
43+ SetSecurityManager ( ) {
44+ this .hasQualifiedName ( _, "AbstractDOMParser" , "setSecurityManager" )
45+ }
46+ }
47+
48+ class SAXParser extends Class {
49+ SAXParser ( ) { this .hasName ( "SAXParser" ) }
50+ }
51+
4252class XercesXXEConfiguration extends DataFlow:: Configuration {
4353 XercesXXEConfiguration ( ) { this = "XercesXXEConfiguration" }
4454
45- override predicate isSource ( DataFlow:: Node node ) {
55+ override predicate isSource ( DataFlow:: Node node , string flowstate ) {
4656 exists ( CallInstruction call |
4757 node .asInstruction ( ) .( WriteSideEffectInstruction ) .getDestinationAddress ( ) = call .getThisArgument ( ) and
48- call .getStaticCallTarget ( ) .( Constructor ) .getDeclaringType ( ) instanceof XercesDOMParser
58+ call .getStaticCallTarget ( ) .( Constructor ) .getDeclaringType ( ) instanceof XercesDOMParser and
59+ flowstate = "XercesDOM"
4960 )
5061 or
5162 exists ( Call call |
5263 call .getTarget ( ) instanceof CreateLSParser and
53- call = node .asExpr ( )
64+ call = node .asExpr ( ) and
65+ flowstate = "XercesDOM"
66+ )
67+ or
68+ exists ( CallInstruction call |
69+ node .asInstruction ( ) .( WriteSideEffectInstruction ) .getDestinationAddress ( ) = call .getThisArgument ( ) and
70+ call .getStaticCallTarget ( ) .( Constructor ) .getDeclaringType ( ) instanceof SAXParser and
71+ flowstate = "SAXParser"
5472 )
5573 }
5674
@@ -62,23 +80,40 @@ class XercesXXEConfiguration extends DataFlow::Configuration {
6280 )
6381 }
6482
65- override predicate isBarrier ( DataFlow:: Node node ) {
66- exists ( Call first , Call second |
83+ override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , string state1 , DataFlow:: Node node2 , string state2 ) {
84+ exists ( Call call |
85+ node1 .asConvertedExpr ( ) = call .getQualifier ( ) and
86+ node2 .asDefiningArgument ( ) = call .getQualifier ( ) and
87+ (
88+ call .getTarget ( ) instanceof DisableDefaultEntityResolution and
89+ state1 = "XercesDOM" and
90+ state2 = "XercesDOM-DDER"
91+ or
92+ call .getTarget ( ) instanceof SetCreateEntityReferenceNodes and
93+ state1 = "XercesDOM" and
94+ state2 = "XercesDOM-SCERN"
95+ )
96+ )
97+ }
98+
99+ override predicate isBarrier ( DataFlow:: Node node , string flowstate ) {
100+ exists ( Call call |
67101 (
68- first . getTarget ( ) instanceof DisableDefaultEntityResolution and
69- second .getTarget ( ) instanceof SetCreateEntityReferenceNodes
102+ flowstate = "XercesDOM-DDER" and
103+ call .getTarget ( ) instanceof SetCreateEntityReferenceNodes
70104 or
71- first . getTarget ( ) instanceof SetCreateEntityReferenceNodes and
72- second .getTarget ( ) instanceof DisableDefaultEntityResolution
105+ flowstate = "XercesDOM-SCERN" and
106+ call .getTarget ( ) instanceof DisableDefaultEntityResolution
73107 ) and
74- DataFlow:: localExprFlow ( first .getQualifier ( ) , second .getQualifier ( ) ) and
75- second .getQualifier ( ) = node .asDefiningArgument ( )
108+ call .getQualifier ( ) = node .asDefiningArgument ( )
76109 )
77110 or
78111 exists ( Call setSecurityManager |
79112 // todo: security manager setup
80- setSecurityManager .getQualifier ( ) = node .asDefiningArgument ( )
113+ setSecurityManager .getQualifier ( ) = node .asDefiningArgument ( ) and
114+ setSecurityManager .getTarget ( ) instanceof SetSecurityManager
81115 )
116+ //or
82117 }
83118}
84119
0 commit comments