-
-
- Using user-supplied information to construct an XPath query for XML data can
- result in an XPath injection flaw. By sending intentionally malformed information,
- an attacker can access data that he may not normally have access to.
- He/She may even be able to elevate his privileges on the web site if the XML data
- is being used for authentication (such as an XML based user file).
-
-
-
-
- XPath injection can be prevented using parameterized XPath interface or escaping the user input to make it safe to include in a dynamically constructed query.
- If you are using quotes to terminate untrusted input in a dynamically constructed XPath query, then you need to escape that quote in the untrusted input to ensure the untrusted data can’t try to break out of that quoted context.
-
-
- Another better mitigation option is to use a precompiled XPath query. Precompiled XPath queries are already preset before the program executes, rather than created on the fly after the user’s input has been added to the string. This is a better route because you don’t have to worry about missing a character that should have been escaped.
-
-
-
- In the example below, the xpath query is controlled by the user and hence leads to a vulnerability.
-
- This can be fixed by using a parameterized query as shown below.
-
-
-
- OWASP XPath injection : />>
-
-
diff --git a/python/ql/src/experimental/Security/CWE-643/XpathInjection.ql b/python/ql/src/experimental/Security/CWE-643/XpathInjection.ql
deleted file mode 100644
index 67b4741f610..00000000000
--- a/python/ql/src/experimental/Security/CWE-643/XpathInjection.ql
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * @name XPath query built from user-controlled sources
- * @description Building a XPath query from user-controlled sources is vulnerable to insertion of
- * malicious Xpath code by the user.
- * @kind path-problem
- * @problem.severity error
- * @precision high
- * @id py/xpath-injection
- * @tags security
- * external/cwe/cwe-643
- */
-
-private import python
-private import semmle.python.Concepts
-private import semmle.python.dataflow.new.TaintTracking
-private import semmle.python.Concepts
-private import semmle.python.ApiGraphs
-private import semmle.python.dataflow.new.RemoteFlowSources
-private import semmle.python.dataflow.new.BarrierGuards
-import XpathInjection::XpathInjection
-import DataFlow::PathGraph
-
-class XpathInjectionConfiguration extends TaintTracking::Configuration {
- XpathInjectionConfiguration() { this = "PathNotNormalizedConfiguration" }
-
- override predicate isSource(DataFlow::Node source) { source instanceof Source }
-
- override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
-}
-
-from XpathInjectionConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
-where config.hasFlowPath(source, sink)
-select sink, source, sink, "This Xpath query depends on $@.", source, "a user-provided value"
diff --git a/python/ql/src/experimental/Security/CWE-643/XpathInjectionCustomizations.qll b/python/ql/src/experimental/Security/CWE-643/XpathInjectionCustomizations.qll
deleted file mode 100644
index 4a939253636..00000000000
--- a/python/ql/src/experimental/Security/CWE-643/XpathInjectionCustomizations.qll
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Provides class and predicates to track external data that
- * may represent malicious xpath query objects.
- *
- * This module is intended to be imported into a taint-tracking query.
- */
-
-private import python
-private import semmle.python.Concepts
-private import semmle.python.dataflow.new.TaintTracking
-private import semmle.python.Concepts
-private import semmle.python.ApiGraphs
-private import semmle.python.dataflow.new.RemoteFlowSources
-private import semmle.python.dataflow.new.BarrierGuards
-
-/** Models Xpath Injection related classes and functions */
-module XpathInjection {
- /**
- * A data flow source for "XPath injection" vulnerabilities.
- */
- abstract class Source extends DataFlow::Node { }
-
- /**
- * A data flow sink for "XPath injection" vulnerabilities.
- */
- abstract class Sink extends DataFlow::Node { }
-
- /**
- * A sanitizer for "XPath injection" vulnerabilities.
- */
- abstract class Sanitizer extends DataFlow::Node { }
-
- /**
- * A sanitizer guard for "XPath injection" vulnerabilities.
- */
- abstract class SanitizerGuard extends DataFlow::BarrierGuard { }
-
- /**
- * A source of remote user input, considered as a flow source.
- */
- class RemoteFlowSourceAsSource extends Source, RemoteFlowSource { }
-
- /** Returns an API node referring to `lxml.etree` */
- API::Node etree() { result = API::moduleImport("lxml").getMember("etree") }
-
- /** Returns an API node referring to `lxml.etree` */
- API::Node etreeFromString() { result = etree().getMember("fromstring") }
-
- /** Returns an API node referring to `lxml.etree.parse` */
- API::Node etreeParse() { result = etree().getMember("parse") }
-
- /** Returns an API node referring to `lxml.etree.parse` */
- API::Node libxml2parseFile() { result = API::moduleImport("libxml2").getMember("parseFile") }
-
- /**
- * A Sink representing an argument to `etree.XPath` or `etree.ETXPath` call.
- *
- * from lxml import etree
- * root = etree.XML("