11/**
2- * Provides default sources, sinks and sanitizers for reasoning about
3- * XML External Entity (XXE) vulnerabilities, as well as extension
4- * points for adding your own.
2+ * Provides default sources, sinks and sanitizers for detecting
3+ * " XML External Entity (XXE)"
4+ * vulnerabilities, as well as extension points for adding your own.
55 */
66
7- import javascript
8- import semmle.javascript.security.dataflow.DOM
7+ private import python
8+ private import semmle.python.dataflow.new.DataFlow
9+ private import experimental.semmle.python.Concepts
10+ private import semmle.python.dataflow.new.RemoteFlowSources
911
12+ /**
13+ * Provides default sources, sinks and sanitizers for detecting "XML External Entity (XXE)"
14+ * vulnerabilities, as well as extension points for adding your own.
15+ */
1016module Xxe {
1117 /**
1218 * A data flow source for XXE vulnerabilities.
@@ -28,24 +34,16 @@ module Xxe {
2834 RemoteFlowSourceAsSource ( ) { this instanceof RemoteFlowSource }
2935 }
3036
31- /**
32- * An access to `document.location`, considered as a flow source for XXE vulnerabilities.
33- */
34- class LocationAsSource extends Source , DataFlow:: ValueNode {
35- LocationAsSource ( ) { isLocation ( astNode ) }
36- }
37-
3837 /**
3938 * A call to an XML parser that performs external entity expansion, viewed
4039 * as a data flow sink for XXE vulnerabilities.
4140 */
42- class XmlParsingWithExternalEntityResolution extends Sink , DataFlow :: ValueNode {
41+ class XmlParsingWithExternalEntityResolution extends Sink {
4342 XmlParsingWithExternalEntityResolution ( ) {
44- exists ( XML:: ParserInvocation parse | astNode = parse .getSourceArgument ( ) |
45- parse .resolvesEntities ( XML:: ExternalEntity ( _) )
46- or
47- parse .resolvesEntities ( XML:: ParameterEntity ( true ) ) and
48- parse .resolvesEntities ( XML:: InternalEntity ( ) )
43+ exists ( ExperimentalXML:: XMLParsing parsing , ExperimentalXML:: XMLVulnerabilityKind kind |
44+ kind .isXxe ( ) and
45+ parsing .vulnerableTo ( kind ) and
46+ this = parsing .getAnInput ( )
4947 )
5048 }
5149 }
0 commit comments