mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: Adjust Xxe/XmlBomb for Python
I changed a few QLdocs so they fit the style we have used in Python... although I surely do regret having introduced a new style for how these QLDocs look :D
This commit is contained in:
committed by
Rasmus Wriedt Larsen
parent
65907c9762
commit
e45f9d69cc
@@ -6,14 +6,14 @@
|
|||||||
* @problem.severity error
|
* @problem.severity error
|
||||||
* @security-severity 9.1
|
* @security-severity 9.1
|
||||||
* @precision high
|
* @precision high
|
||||||
* @id js/xxe
|
* @id py/xxe
|
||||||
* @tags security
|
* @tags security
|
||||||
* external/cwe/cwe-611
|
* external/cwe/cwe-611
|
||||||
* external/cwe/cwe-827
|
* external/cwe/cwe-827
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
import python
|
||||||
import semmle.javascript.security.dataflow.XxeQuery
|
import experimental.semmle.python.security.dataflow.XxeQuery
|
||||||
import DataFlow::PathGraph
|
import DataFlow::PathGraph
|
||||||
|
|
||||||
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
* @problem.severity warning
|
* @problem.severity warning
|
||||||
* @security-severity 7.5
|
* @security-severity 7.5
|
||||||
* @precision high
|
* @precision high
|
||||||
* @id js/xml-bomb
|
* @id py/xml-bomb
|
||||||
* @tags security
|
* @tags security
|
||||||
* external/cwe/cwe-776
|
* external/cwe/cwe-776
|
||||||
* external/cwe/cwe-400
|
* external/cwe/cwe-400
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
import python
|
||||||
import semmle.javascript.security.dataflow.XmlBombQuery
|
import experimental.semmle.python.security.dataflow.XmlBombQuery
|
||||||
import DataFlow::PathGraph
|
import DataFlow::PathGraph
|
||||||
|
|
||||||
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Provides default sources, sinks and sanitizers for reasoning about
|
* Provides default sources, sinks and sanitizers for detecting
|
||||||
* XML-bomb vulnerabilities, as well as extension points for adding
|
* "XML bomb"
|
||||||
* your own.
|
* vulnerabilities, as well as extension points for adding your own.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
private import python
|
||||||
import semmle.javascript.security.dataflow.DOM
|
private import semmle.python.dataflow.new.DataFlow
|
||||||
|
private import experimental.semmle.python.Concepts
|
||||||
|
private import semmle.python.dataflow.new.RemoteFlowSources
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default sources, sinks and sanitizers for detecting "XML bomb"
|
||||||
|
* vulnerabilities, as well as extension points for adding your own.
|
||||||
|
*/
|
||||||
module XmlBomb {
|
module XmlBomb {
|
||||||
/**
|
/**
|
||||||
* A data flow source for XML-bomb vulnerabilities.
|
* A data flow source for XML-bomb vulnerabilities.
|
||||||
@@ -28,21 +34,16 @@ module XmlBomb {
|
|||||||
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
|
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* An access to `document.location`, considered as a flow source for XML bomb vulnerabilities.
|
|
||||||
*/
|
|
||||||
class LocationAsSource extends Source, DataFlow::ValueNode {
|
|
||||||
LocationAsSource() { isLocation(astNode) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A call to an XML parser that performs internal entity expansion, viewed
|
* A call to an XML parser that performs internal entity expansion, viewed
|
||||||
* as a data flow sink for XML-bomb vulnerabilities.
|
* as a data flow sink for XML-bomb vulnerabilities.
|
||||||
*/
|
*/
|
||||||
class XmlParsingWithEntityResolution extends Sink, DataFlow::ValueNode {
|
class XmlParsingWithEntityResolution extends Sink {
|
||||||
XmlParsingWithEntityResolution() {
|
XmlParsingWithEntityResolution() {
|
||||||
exists(XML::ParserInvocation parse | astNode = parse.getSourceArgument() |
|
exists(ExperimentalXML::XMLParsing parsing, ExperimentalXML::XMLVulnerabilityKind kind |
|
||||||
parse.resolvesEntities(XML::InternalEntity())
|
(kind.isBillionLaughs() or kind.isQuadraticBlowup()) and
|
||||||
|
parsing.vulnerableTo(kind) and
|
||||||
|
this = parsing.getAnInput()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Provides a taint tracking configuration for reasoning about
|
* Provides a taint-tracking configuration for detecting "XML bomb" vulnerabilities.
|
||||||
* XML-bomb vulnerabilities.
|
|
||||||
*
|
*
|
||||||
* Note, for performance reasons: only import this file if
|
* Note, for performance reasons: only import this file if
|
||||||
* `XmlBomb::Configuration` is needed, otherwise
|
* `Configuration` is needed, otherwise
|
||||||
* `XmlBombCustomizations` should be imported instead.
|
* `XmlBombCustomizations` should be imported instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
import python
|
||||||
|
import semmle.python.dataflow.new.DataFlow
|
||||||
|
import semmle.python.dataflow.new.TaintTracking
|
||||||
import XmlBombCustomizations::XmlBomb
|
import XmlBombCustomizations::XmlBomb
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A taint-tracking configuration for reasoning about XML-bomb vulnerabilities.
|
* A taint-tracking configuration for detecting "XML bomb" vulnerabilities.
|
||||||
*/
|
*/
|
||||||
class Configuration extends TaintTracking::Configuration {
|
class Configuration extends TaintTracking::Configuration {
|
||||||
Configuration() { this = "XmlBomb" }
|
Configuration() { this = "XmlBomb" }
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Provides default sources, sinks and sanitizers for reasoning about
|
* Provides default sources, sinks and sanitizers for detecting
|
||||||
* XML External Entity (XXE) vulnerabilities, as well as extension
|
* "XML External Entity (XXE)"
|
||||||
* points for adding your own.
|
* vulnerabilities, as well as extension points for adding your own.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
private import python
|
||||||
import semmle.javascript.security.dataflow.DOM
|
private import semmle.python.dataflow.new.DataFlow
|
||||||
|
private import experimental.semmle.python.Concepts
|
||||||
|
private import semmle.python.dataflow.new.RemoteFlowSources
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default sources, sinks and sanitizers for detecting "XML External Entity (XXE)"
|
||||||
|
* vulnerabilities, as well as extension points for adding your own.
|
||||||
|
*/
|
||||||
module Xxe {
|
module Xxe {
|
||||||
/**
|
/**
|
||||||
* A data flow source for XXE vulnerabilities.
|
* A data flow source for XXE vulnerabilities.
|
||||||
@@ -28,24 +34,16 @@ module Xxe {
|
|||||||
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
|
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* An access to `document.location`, considered as a flow source for XXE vulnerabilities.
|
|
||||||
*/
|
|
||||||
class LocationAsSource extends Source, DataFlow::ValueNode {
|
|
||||||
LocationAsSource() { isLocation(astNode) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A call to an XML parser that performs external entity expansion, viewed
|
* A call to an XML parser that performs external entity expansion, viewed
|
||||||
* as a data flow sink for XXE vulnerabilities.
|
* as a data flow sink for XXE vulnerabilities.
|
||||||
*/
|
*/
|
||||||
class XmlParsingWithExternalEntityResolution extends Sink, DataFlow::ValueNode {
|
class XmlParsingWithExternalEntityResolution extends Sink {
|
||||||
XmlParsingWithExternalEntityResolution() {
|
XmlParsingWithExternalEntityResolution() {
|
||||||
exists(XML::ParserInvocation parse | astNode = parse.getSourceArgument() |
|
exists(ExperimentalXML::XMLParsing parsing, ExperimentalXML::XMLVulnerabilityKind kind |
|
||||||
parse.resolvesEntities(XML::ExternalEntity(_))
|
kind.isXxe() and
|
||||||
or
|
parsing.vulnerableTo(kind) and
|
||||||
parse.resolvesEntities(XML::ParameterEntity(true)) and
|
this = parsing.getAnInput()
|
||||||
parse.resolvesEntities(XML::InternalEntity())
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Provides a taint tracking configuration for reasoning about XML
|
* Provides a taint-tracking configuration for detecting "XML External Entity (XXE)" vulnerabilities.
|
||||||
* External Entity (XXE) vulnerabilities.
|
|
||||||
*
|
*
|
||||||
* Note, for performance reasons: only import this file if
|
* Note, for performance reasons: only import this file if
|
||||||
* `Xxe::Configuration` is needed, otherwise `XxeCustomizations`
|
* `Configuration` is needed, otherwise
|
||||||
* should be imported instead.
|
* `XxeCustomizations` should be imported instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javascript
|
import python
|
||||||
|
import semmle.python.dataflow.new.DataFlow
|
||||||
|
import semmle.python.dataflow.new.TaintTracking
|
||||||
import XxeCustomizations::Xxe
|
import XxeCustomizations::Xxe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A taint-tracking configuration for reasoning about XXE vulnerabilities.
|
* A taint-tracking configuration for detecting "XML External Entity (XXE)" vulnerabilities.
|
||||||
*/
|
*/
|
||||||
class Configuration extends TaintTracking::Configuration {
|
class Configuration extends TaintTracking::Configuration {
|
||||||
Configuration() { this = "Xxe" }
|
Configuration() { this = "Xxe" }
|
||||||
|
|||||||
Reference in New Issue
Block a user