From 35a6fdb58907954ebc0c27e57e7fe7da894c071a Mon Sep 17 00:00:00 2001
From: intrigus
Date: Thu, 26 Mar 2020 20:18:16 +0100
Subject: [PATCH 01/20] Add XPath framework models
---
ql/src/semmle/go/frameworks/XPath.qll | 168 ++++++++++++++++++
ql/src/semmle/go/security/XPathInjection.qll | 35 ++++
.../security/XPathInjectionCustomizations.qll | 59 ++++++
.../Security/CWE-643/XPathInjection.expected | 10 ++
.../Security/CWE-643/XPathInjection.go | 30 ++++
.../Security/CWE-643/XPathInjection.qlref | 1 +
6 files changed, 303 insertions(+)
create mode 100644 ql/src/semmle/go/frameworks/XPath.qll
create mode 100644 ql/src/semmle/go/security/XPathInjection.qll
create mode 100644 ql/src/semmle/go/security/XPathInjectionCustomizations.qll
create mode 100644 ql/test/query-tests/Security/CWE-643/XPathInjection.expected
create mode 100644 ql/test/query-tests/Security/CWE-643/XPathInjection.go
create mode 100644 ql/test/query-tests/Security/CWE-643/XPathInjection.qlref
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
new file mode 100644
index 00000000000..5fdaa32e29a
--- /dev/null
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -0,0 +1,168 @@
+/**
+ * Provides classes for working with XPath-related concepts such as XPath expressions.
+ */
+
+import go
+
+/** Provides classes for working with XPath-related APIs. */
+module XPath {
+ /** Provides classes for working with XPath expression strings. */
+ module XPathExpressionString {
+ /**
+ * A data-flow node whose string value is interpreted as (part of) an XPath expression.
+ *
+ * Extend this class to model new APIs.
+ */
+ abstract class Range extends DataFlow::Node { }
+
+ /** An XPath expression string used in an API function of the https://github.com/antchfx/xpath package. */
+ private class AntchfxxpathXPathExpressionString extends Range {
+ AntchfxxpathXPathExpressionString() {
+ exists(Function f, string name | name.matches("Compile%") |
+ f.hasQualifiedName("github.com/antchfx/xpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("MustCompile%") |
+ f.hasQualifiedName("github.com/antchfx/xpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("Select%") |
+ f.hasQualifiedName("github.com/antchfx/xpath", name) and
+ this = f.getACall().getArgument(1)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/antchfx/htmlquery package. */
+ private class AntchfxhtmlqueryXPathExpressionString extends Range {
+ AntchfxhtmlqueryXPathExpressionString() {
+ exists(Function f, string name | name.matches("Find%") |
+ f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f, string name | name.matches("Query%") |
+ f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f |
+ f.hasQualifiedName("github.com/antchfx/htmlquery", "getQuery") and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/antchfx/xmlquery package. */
+ private class AntchfxxmlqueryXPathExpressionString extends Range {
+ AntchfxxmlqueryXPathExpressionString() {
+ exists(Function f, string name | name.matches("Find%") |
+ f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f, string name | name.matches("Query%") |
+ f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f, string name | name.matches("Select%") |
+ f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f |
+ f.hasQualifiedName("github.com/antchfx/xmlquery", "getQuery") and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/antchfx/jsonquery package. */
+ private class AntchfxjsonqueryXPathExpressionString extends Range {
+ AntchfxjsonqueryXPathExpressionString() {
+ exists(Function f, string name | name.matches("Find%") |
+ f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f, string name | name.matches("Query%") |
+ f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
+ this = f.getACall().getArgument(1)
+ )
+ or
+ exists(Function f |
+ f.hasQualifiedName("github.com/antchfx/jsonquery", "getQuery") and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/go-xmlpath/xmlpath package. */
+ private class GoxmlpathxmlpathXPathExpressionString extends Range {
+ GoxmlpathxmlpathXPathExpressionString() {
+ exists(Function f, string name | name.matches("Compile%") |
+ f.hasQualifiedName("github.com/go-xmlpath/xmlpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("MustCompile%") |
+ f.hasQualifiedName("github.com/go-xmlpath/xmlpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/ChrisTrenkamp/goxpath package. */
+ private class ChrisTrenkampgoxpathXPathExpressionString extends Range {
+ ChrisTrenkampgoxpathXPathExpressionString() {
+ exists(Function f, string name | name.matches("Parse%") |
+ f.hasQualifiedName("github.com/ChrisTrenkamp/goxpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("MustParse%") |
+ f.hasQualifiedName("github.com/ChrisTrenkamp/goxpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/santhosh-tekuri/xpathparser package. */
+ private class AnthoshtekurixpathparserXPathExpressionString extends Range {
+ AnthoshtekurixpathparserXPathExpressionString() {
+ exists(Function f, string name | name.matches("Parse%") |
+ f.hasQualifiedName("github.com/santhosh-tekuri/xpathparser", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("MustParse%") |
+ f.hasQualifiedName("github.com/santhosh-tekuri/xpathparser", name) and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+
+ /** An XPath expression string used in an API function of the https://github.com/moovweb/gokogiri package. */
+ private class MoovwebgokogiriXPathExpressionString extends Range {
+ MoovwebgokogiriXPathExpressionString() {
+ exists(Function f, string name | name.matches("Compile%") |
+ f.hasQualifiedName("github.com/moovweb/gokogiri/xpath", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("Search%") |
+ f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
+ this = f.getACall().getArgument(0)
+ )
+ or
+ exists(Function f, string name | name.matches("EvalXPath%") |
+ f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
+ this = f.getACall().getArgument(0)
+ )
+ }
+ }
+ }
+}
diff --git a/ql/src/semmle/go/security/XPathInjection.qll b/ql/src/semmle/go/security/XPathInjection.qll
new file mode 100644
index 00000000000..dedaa16575f
--- /dev/null
+++ b/ql/src/semmle/go/security/XPathInjection.qll
@@ -0,0 +1,35 @@
+/**
+ * Provides a taint tracking configuration for reasoning about untrusted user input used in an XPath expression.
+ *
+ * Note: for performance reasons, only import this file if `XPathInjection::Configuration` is needed,
+ * otherwise `XPathInjectionCustomizations` should be imported instead.
+ */
+
+import go
+
+/**
+ * Provides a taint tracking configuration for reasoning about untrusted user input used in an XPath expression.
+ */
+module XPathInjection {
+ import XPathInjectionCustomizations::XPathInjection
+
+ /**
+ * A taint-tracking configuration for reasoning about untrusted user input used in an XPath expression.
+ */
+ class Configuration extends TaintTracking::Configuration {
+ Configuration() { this = "XPathInjection" }
+
+ override predicate isSource(DataFlow::Node source) { source instanceof Source }
+
+ override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
+
+ override predicate isSanitizer(DataFlow::Node node) {
+ super.isSanitizer(node) or
+ node instanceof Sanitizer
+ }
+
+ override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
+ guard instanceof SanitizerGuard
+ }
+ }
+}
diff --git a/ql/src/semmle/go/security/XPathInjectionCustomizations.qll b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
new file mode 100644
index 00000000000..2bd3da1cbf3
--- /dev/null
+++ b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
@@ -0,0 +1,59 @@
+/**
+ * Provides default sources, sinks and sanitizers for reasoning about untrusted user input used in an XPath expression,
+ * as well as extension points for adding your own.
+ */
+
+import go
+
+/**
+ * Provides extension points for reasoning about untrusted user input used in an XPath expression.
+ */
+module XPathInjection {
+ /**
+ * A data flow source for untrusted user input used in an XPath expression.
+ */
+ abstract class Source extends DataFlow::Node { }
+
+ /**
+ * A data flow sink for untrusted user input used in an XPath expression.
+ */
+ abstract class Sink extends DataFlow::ExprNode { }
+
+ /**
+ * A sanitizer for untrusted user input used in an XPath expression.
+ */
+ abstract class Sanitizer extends DataFlow::ExprNode { }
+
+ /**
+ * A sanitizer guard for untrusted user input used in an XPath expression.
+ */
+ abstract class SanitizerGuard extends DataFlow::BarrierGuard { }
+
+ /** A source of untrusted data, used in an XPath expression. */
+ class UntrustedFlowAsSource extends Source {
+ UntrustedFlowAsSource() { this instanceof UntrustedFlowSource }
+ }
+
+ /** An XPath expression string, considered as a taint sink for XPath injection. */
+ class XPathExpressionStringAsSink extends Sink {
+ XPathExpressionStringAsSink() { this instanceof XPath::XPathExpressionString::Range }
+ }
+
+ // TODO: This probably belongs somewhere, but I'm not sure where
+ /** The []byte type */
+ class ByteSliceType extends SliceType {
+ ByteSliceType() { this.getElementType() instanceof Uint8Type }
+ }
+
+ //TODO add runes?
+ /**
+ * A call to `filepath.Rel`, considered as a sanitizer for path traversal.
+ */
+ /*class NonStringByteSanitizer extends Sanitizer {
+ NonStringByteSanitizer() {
+ exists(Type t | t = this.getType().getUnderlyingType() |
+ not t instanceof StringType or not t instanceof ByteSliceType
+ )
+ }
+ }*/
+}
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
new file mode 100644
index 00000000000..9a3d8c7805a
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
@@ -0,0 +1,10 @@
+edges
+| XPathInjection.go:13:14:13:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... |
+| XPathInjection.go:14:14:14:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... |
+nodes
+| XPathInjection.go:13:14:13:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:14:14:14:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:17:29:17:132 | ...+... | semmle.label | ...+... |
+#select
+| XPathInjection.go:17:29:17:132 | ...+... | XPathInjection.go:13:14:13:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:13:14:13:19 | selection of Form | A user-provided value |
+| XPathInjection.go:17:29:17:132 | ...+... | XPathInjection.go:14:14:14:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:14:14:14:19 | selection of Form | A user-provided value |
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.go b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
new file mode 100644
index 00000000000..8d7f57ae16c
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "fmt"
+ "net/http"
+
+ "github.com/ChrisTrenkamp/goxpath"
+ "github.com/ChrisTrenkamp/goxpath/tree"
+)
+
+func processRequest(r *http.Request, doc tree.Node) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+ password := r.Form.Get("password")
+
+ // BAD: User input used directly in an XPath expression
+ xPath := goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+ unsafeRes, _ := xPath.ExecBool(doc)
+ fmt.Println(unsafeRes)
+
+ // GOOD: Value of parameters is defined here instead of directly in the query
+ opt := func(o *goxpath.Opts) {
+ o.Vars["username"] = tree.String(username)
+ o.Vars["password"] = tree.String(password)
+ }
+ // GOOD: Uses parameters to avoid including user input directly in XPath expression
+ xPath = goxpath.MustParse("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()")
+ safeRes, _ := xPath.ExecBool(doc, opt)
+ fmt.Println(safeRes)
+}
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref b/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref
new file mode 100644
index 00000000000..c48e056141c
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.qlref
@@ -0,0 +1 @@
+Security/CWE-643/XPathInjection.ql
From 03023e8205dc19969f20e6dcbc38df44b5e25a91 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Thu, 26 Mar 2020 20:19:19 +0100
Subject: [PATCH 02/20] Add XPath model to default imports
---
ql/src/go.qll | 1 +
1 file changed, 1 insertion(+)
diff --git a/ql/src/go.qll b/ql/src/go.qll
index dfdd54726cf..c176857a282 100644
--- a/ql/src/go.qll
+++ b/ql/src/go.qll
@@ -26,6 +26,7 @@ import semmle.go.dataflow.SSA
import semmle.go.frameworks.HTTP
import semmle.go.frameworks.SystemCommandExecutors
import semmle.go.frameworks.SQL
+import semmle.go.frameworks.XPath
import semmle.go.frameworks.Stdlib
import semmle.go.security.FlowSources
import semmle.go.Util
From be50db1cc7b752cafa553da7c73824ac55b99abc Mon Sep 17 00:00:00 2001
From: intrigus
Date: Thu, 26 Mar 2020 20:19:58 +0100
Subject: [PATCH 03/20] Move XPath injection query to supported query
The XPath injection query is moved to the supported queries.
Removed unnecessary code from the go test file
---
.../Security/CWE-643/XPathInjection.go | 0
.../Security/CWE-643/XPathInjection.qhelp | 0
ql/src/Security/CWE-643/XPathInjection.ql | 19 ++
.../Security/CWE-643/XPathInjection.ql | 188 ------------------
4 files changed, 19 insertions(+), 188 deletions(-)
rename ql/src/{experimental => }/Security/CWE-643/XPathInjection.go (100%)
rename ql/src/{experimental => }/Security/CWE-643/XPathInjection.qhelp (100%)
create mode 100644 ql/src/Security/CWE-643/XPathInjection.ql
delete mode 100644 ql/src/experimental/Security/CWE-643/XPathInjection.ql
diff --git a/ql/src/experimental/Security/CWE-643/XPathInjection.go b/ql/src/Security/CWE-643/XPathInjection.go
similarity index 100%
rename from ql/src/experimental/Security/CWE-643/XPathInjection.go
rename to ql/src/Security/CWE-643/XPathInjection.go
diff --git a/ql/src/experimental/Security/CWE-643/XPathInjection.qhelp b/ql/src/Security/CWE-643/XPathInjection.qhelp
similarity index 100%
rename from ql/src/experimental/Security/CWE-643/XPathInjection.qhelp
rename to ql/src/Security/CWE-643/XPathInjection.qhelp
diff --git a/ql/src/Security/CWE-643/XPathInjection.ql b/ql/src/Security/CWE-643/XPathInjection.ql
new file mode 100644
index 00000000000..141004ee60f
--- /dev/null
+++ b/ql/src/Security/CWE-643/XPathInjection.ql
@@ -0,0 +1,19 @@
+/**
+ * @name XPath injection
+ * @description Building an XPath expression from user-controlled sources is vulnerable to insertion of
+ * malicious code by the user.
+ * @kind path-problem
+ * @problem.severity error
+ * @id go/xml/xpath-injection
+ * @tags security
+ * external/cwe/cwe-643
+ */
+
+import go
+import semmle.go.security.XPathInjection::XPathInjection
+import DataFlow::PathGraph
+
+from Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink
+where config.hasFlowPath(source, sink)
+select sink.getNode(), source, sink, "$@ flows here and is used in an XPath expression.",
+ source.getNode(), "A user-provided value"
diff --git a/ql/src/experimental/Security/CWE-643/XPathInjection.ql b/ql/src/experimental/Security/CWE-643/XPathInjection.ql
deleted file mode 100644
index 453710d71e0..00000000000
--- a/ql/src/experimental/Security/CWE-643/XPathInjection.ql
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * @name XPath injection
- * @description Building an XPath expression from user-controlled sources is vulnerable to insertion of
- * malicious code by the user.
- * @kind path-problem
- * @problem.severity error
- * @id go/xml/xpath-injection
- * @tags security
- * external/cwe/cwe-643
- */
-
-import go
-import DataFlow::PathGraph
-
-class ByteSliceType extends SliceType {
- ByteSliceType() { this.getElementType() instanceof Uint8Type }
-}
-
-class XPathInjectionConfiguration extends TaintTracking::Configuration {
- XPathInjectionConfiguration() { this = "XPathInjectionConfiguration" }
-
- override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
-
- override predicate isSink(DataFlow::Node sink) { sink instanceof XPathInjectionSink }
-
- override predicate isSanitizer(DataFlow::Node node) {
- exists(Type t | t = node.getType().getUnderlyingType() |
- not t instanceof StringType or not t instanceof ByteSliceType
- )
- }
-}
-
-abstract class XPathInjectionSink extends DataFlow::Node { }
-
-// https://github.com/antchfx/xpath
-class XPathSink extends XPathInjectionSink {
- XPathSink() {
- exists(Function f, string name | name.matches("Compile%") |
- f.hasQualifiedName("github.com/antchfx/xpath", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("MustCompile%") |
- f.hasQualifiedName("github.com/antchfx/xpath", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("Select%") |
- f.hasQualifiedName("github.com/antchfx/xpath", name) and
- this = f.getACall().getArgument(1)
- )
- }
-}
-
-// https://github.com/antchfx/htmlquery
-class HtmlQuerySink extends XPathInjectionSink {
- HtmlQuerySink() {
- exists(Function f, string name | name.matches("Find%") |
- f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f, string name | name.matches("Query%") |
- f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/htmlquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/antchfx/xmlquery
-class XmlQuerySink extends XPathInjectionSink {
- XmlQuerySink() {
- exists(Function f, string name | name.matches("Find%") |
- f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f, string name | name.matches("Query%") |
- f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f, string name | name.matches("Select%") |
- f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/xmlquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/antchfx/jsonquery
-class JsonQuerySink extends XPathInjectionSink {
- JsonQuerySink() {
- exists(Function f, string name | name.matches("Find%") |
- f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f, string name | name.matches("Query%") |
- f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
- this = f.getACall().getArgument(1)
- )
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/jsonquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/go-xmlpath/xmlpath
-class XmlPathSink extends XPathInjectionSink {
- XmlPathSink() {
- exists(Function f, string name | name.matches("Compile%") |
- f.hasQualifiedName("github.com/go-xmlpath/xmlpath", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("MustCompile%") |
- f.hasQualifiedName("github.com/go-xmlpath/xmlpath", name) and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/ChrisTrenkamp/goxpath
-class GoXPathSink extends XPathInjectionSink {
- GoXPathSink() {
- exists(Function f, string name | name.matches("Parse%") |
- f.hasQualifiedName("github.com/ChrisTrenkamp/goxpath", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("MustParse%") |
- f.hasQualifiedName("github.com/ChrisTrenkamp/goxpath", name) and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/santhosh-tekuri/xpathparser
-class XPathParserSink extends XPathInjectionSink {
- XPathParserSink() {
- exists(Function f, string name | name.matches("Parse%") |
- f.hasQualifiedName("github.com/santhosh-tekuri/xpathparser", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("MustParse%") |
- f.hasQualifiedName("github.com/santhosh-tekuri/xpathparser", name) and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-// https://github.com/moovweb/gokogiri
-class GokogiriSink extends XPathInjectionSink {
- GokogiriSink() {
- exists(Function f, string name | name.matches("Compile%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xpath", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("Search%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
- this = f.getACall().getArgument(0)
- )
- or
- exists(Function f, string name | name.matches("EvalXPath%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
- this = f.getACall().getArgument(0)
- )
- }
-}
-
-from DataFlow::PathNode source, DataFlow::PathNode sink, XPathInjectionConfiguration c
-where c.hasFlowPath(source, sink)
-select sink.getNode(), source, sink, "$@ flows here and is used in an XPath expression.",
- source.getNode(), "A user-provided value"
From 5eaaa4264a2c491021fc4e1b3518edc878f02c81 Mon Sep 17 00:00:00 2001
From: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com>
Date: Fri, 27 Mar 2020 13:42:30 +0100
Subject: [PATCH 04/20] Apply suggestions from code review
Co-Authored-By: Sauyon Lee
---
ql/src/semmle/go/frameworks/XPath.qll | 28 +++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index 5fdaa32e29a..8b548f24ce2 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -16,8 +16,8 @@ module XPath {
abstract class Range extends DataFlow::Node { }
/** An XPath expression string used in an API function of the https://github.com/antchfx/xpath package. */
- private class AntchfxxpathXPathExpressionString extends Range {
- AntchfxxpathXPathExpressionString() {
+ private class AntchfxXpathXPathExpressionString extends Range {
+ AntchfxXpathXPathExpressionString() {
exists(Function f, string name | name.matches("Compile%") |
f.hasQualifiedName("github.com/antchfx/xpath", name) and
this = f.getACall().getArgument(0)
@@ -36,8 +36,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/antchfx/htmlquery package. */
- private class AntchfxhtmlqueryXPathExpressionString extends Range {
- AntchfxhtmlqueryXPathExpressionString() {
+ private class AntchfxHtmlqueryXPathExpressionString extends Range {
+ AntchfxHtmlqueryXPathExpressionString() {
exists(Function f, string name | name.matches("Find%") |
f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
this = f.getACall().getArgument(1)
@@ -81,8 +81,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/antchfx/jsonquery package. */
- private class AntchfxjsonqueryXPathExpressionString extends Range {
- AntchfxjsonqueryXPathExpressionString() {
+ private class AntchfxJsonqueryXPathExpressionString extends Range {
+ AntchfxJsonqueryXPathExpressionString() {
exists(Function f, string name | name.matches("Find%") |
f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
this = f.getACall().getArgument(1)
@@ -101,8 +101,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/go-xmlpath/xmlpath package. */
- private class GoxmlpathxmlpathXPathExpressionString extends Range {
- GoxmlpathxmlpathXPathExpressionString() {
+ private class GoXmlpathXmlpathXPathExpressionString extends Range {
+ GoXmlpathXmlpathXPathExpressionString() {
exists(Function f, string name | name.matches("Compile%") |
f.hasQualifiedName("github.com/go-xmlpath/xmlpath", name) and
this = f.getACall().getArgument(0)
@@ -116,8 +116,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/ChrisTrenkamp/goxpath package. */
- private class ChrisTrenkampgoxpathXPathExpressionString extends Range {
- ChrisTrenkampgoxpathXPathExpressionString() {
+ private class ChrisTrenkampGoxpathXPathExpressionString extends Range {
+ ChrisTrenkampGoxpathXPathExpressionString() {
exists(Function f, string name | name.matches("Parse%") |
f.hasQualifiedName("github.com/ChrisTrenkamp/goxpath", name) and
this = f.getACall().getArgument(0)
@@ -131,8 +131,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/santhosh-tekuri/xpathparser package. */
- private class AnthoshtekurixpathparserXPathExpressionString extends Range {
- AnthoshtekurixpathparserXPathExpressionString() {
+ private class SanthoshTekuriXpathparserXPathExpressionString extends Range {
+ SanthoshTekuriXpathparserXPathExpressionString() {
exists(Function f, string name | name.matches("Parse%") |
f.hasQualifiedName("github.com/santhosh-tekuri/xpathparser", name) and
this = f.getACall().getArgument(0)
@@ -146,8 +146,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/moovweb/gokogiri package. */
- private class MoovwebgokogiriXPathExpressionString extends Range {
- MoovwebgokogiriXPathExpressionString() {
+ private class MoovwebGokogiriXPathExpressionString extends Range {
+ MoovwebGokogiriXPathExpressionString() {
exists(Function f, string name | name.matches("Compile%") |
f.hasQualifiedName("github.com/moovweb/gokogiri/xpath", name) and
this = f.getACall().getArgument(0)
From b24c23389c389c276bcf67099aaf1675861e71d2 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 15:21:00 +0100
Subject: [PATCH 05/20] Don't match unexported functions
---
ql/src/semmle/go/frameworks/XPath.qll | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index 8b548f24ce2..6a12ef0397f 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -47,11 +47,6 @@ module XPath {
f.hasQualifiedName("github.com/antchfx/htmlquery", name) and
this = f.getACall().getArgument(1)
)
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/htmlquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
}
}
@@ -72,11 +67,6 @@ module XPath {
f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
this = f.getACall().getArgument(0)
)
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/xmlquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
}
}
@@ -92,11 +82,6 @@ module XPath {
f.hasQualifiedName("github.com/antchfx/jsonquery", name) and
this = f.getACall().getArgument(1)
)
- or
- exists(Function f |
- f.hasQualifiedName("github.com/antchfx/jsonquery", "getQuery") and
- this = f.getACall().getArgument(0)
- )
}
}
From c5a1185939d24e503af36ab8523931a694a52437 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 15:29:21 +0100
Subject: [PATCH 06/20] Apply style suggestions
---
ql/src/Security/CWE-643/XPathInjection.qhelp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ql/src/Security/CWE-643/XPathInjection.qhelp b/ql/src/Security/CWE-643/XPathInjection.qhelp
index 23d693ac704..4c1d376202e 100644
--- a/ql/src/Security/CWE-643/XPathInjection.qhelp
+++ b/ql/src/Security/CWE-643/XPathInjection.qhelp
@@ -15,16 +15,16 @@ If user input must be included in an XPath expression, pre-compile the query and
references to include the user input.
-In the first example, the code accepts a user name specified by the user, and uses this
+In the first example, the code accepts a username specified by the user, and uses this
unvalidated and unsanitized value in an XPath expression. This is vulnerable to the user providing
special characters or string sequences that change the meaning of the XPath expression to search
for different values.
From d609c0ca43ab04cae15e233ed388a5487833a9db Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 15:31:20 +0100
Subject: [PATCH 07/20] Shorten example code
---
ql/src/Security/CWE-643/XPathInjection.go | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ql/src/Security/CWE-643/XPathInjection.go b/ql/src/Security/CWE-643/XPathInjection.go
index 869c98acb89..2758de5be25 100644
--- a/ql/src/Security/CWE-643/XPathInjection.go
+++ b/ql/src/Security/CWE-643/XPathInjection.go
@@ -13,20 +13,18 @@ func main() {}
func processRequest(r *http.Request, doc tree.Node) {
r.ParseForm()
username := r.Form.Get("username")
- password := r.Form.Get("password")
// BAD: User input used directly in an XPath expression
- xPath := goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+ xPath := goxpath.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()")
unsafeRes, _ := xPath.ExecBool(doc)
fmt.Println(unsafeRes)
// GOOD: Value of parameters is defined here instead of directly in the query
opt := func(o *goxpath.Opts) {
o.Vars["username"] = tree.String(username)
- o.Vars["password"] = tree.String(password)
}
// GOOD: Uses parameters to avoid including user input directly in XPath expression
- xPath = goxpath.MustParse("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()")
+ xPath = goxpath.MustParse("//users/user[login/text()=$username]/home_dir/text()")
safeRes, _ := xPath.ExecBool(doc, opt)
fmt.Println(safeRes)
}
From 21feb9d996ef324f57e57dff00a109459ab752fe Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 15:37:36 +0100
Subject: [PATCH 08/20] Add byte slice type
---
ql/src/semmle/go/Types.qll | 5 +++++
ql/src/semmle/go/security/XPathInjectionCustomizations.qll | 6 ------
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/ql/src/semmle/go/Types.qll b/ql/src/semmle/go/Types.qll
index ad87b688fea..c68df092675 100644
--- a/ql/src/semmle/go/Types.qll
+++ b/ql/src/semmle/go/Types.qll
@@ -328,6 +328,11 @@ class SliceType extends @slicetype, CompositeType {
override string toString() { result = "slice type" }
}
+/** A byte slice type */
+class ByteSliceType extends SliceType {
+ ByteSliceType() { this.getElementType() instanceof Uint8Type }
+}
+
/** A struct type. */
class StructType extends @structtype, CompositeType {
/**
diff --git a/ql/src/semmle/go/security/XPathInjectionCustomizations.qll b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
index 2bd3da1cbf3..2f1324e57a3 100644
--- a/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
+++ b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
@@ -39,12 +39,6 @@ module XPathInjection {
XPathExpressionStringAsSink() { this instanceof XPath::XPathExpressionString::Range }
}
- // TODO: This probably belongs somewhere, but I'm not sure where
- /** The []byte type */
- class ByteSliceType extends SliceType {
- ByteSliceType() { this.getElementType() instanceof Uint8Type }
- }
-
//TODO add runes?
/**
* A call to `filepath.Rel`, considered as a sanitizer for path traversal.
From 8278dd358e6c892d01c162e334a8d80722e1fefb Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 16:13:00 +0100
Subject: [PATCH 09/20] Try to fix test
---
.../Security/CWE-643/XPathInjection.expected | 14 ++++++------
.../Security/CWE-643/XPathInjection.go | 2 ++
ql/test/query-tests/Security/CWE-643/go.mod | 3 +++
.../github.com/ChrisTrenkamp/goxpath/LICENSE | 22 +++++++++++++++++++
.../ChrisTrenkamp/goxpath/README.md | 3 +++
.../ChrisTrenkamp/goxpath/goxpath.go | 22 +++++++++++++++++++
.../ChrisTrenkamp/goxpath/tree/tree.go | 16 ++++++++++++++
.../Security/CWE-643/vendor/modules.txt | 3 +++
8 files changed, 78 insertions(+), 7 deletions(-)
create mode 100644 ql/test/query-tests/Security/CWE-643/go.mod
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/modules.txt
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
index 9a3d8c7805a..75010112dae 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
@@ -1,10 +1,10 @@
edges
-| XPathInjection.go:13:14:13:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... |
-| XPathInjection.go:14:14:14:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... |
+| XPathInjection.go:15:14:15:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... |
+| XPathInjection.go:16:14:16:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... |
nodes
-| XPathInjection.go:13:14:13:19 | selection of Form : Values | semmle.label | selection of Form : Values |
-| XPathInjection.go:14:14:14:19 | selection of Form : Values | semmle.label | selection of Form : Values |
-| XPathInjection.go:17:29:17:132 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:15:14:15:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:16:14:16:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:19:29:19:132 | ...+... | semmle.label | ...+... |
#select
-| XPathInjection.go:17:29:17:132 | ...+... | XPathInjection.go:13:14:13:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:13:14:13:19 | selection of Form | A user-provided value |
-| XPathInjection.go:17:29:17:132 | ...+... | XPathInjection.go:14:14:14:19 | selection of Form : Values | XPathInjection.go:17:29:17:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:14:14:14:19 | selection of Form | A user-provided value |
+| XPathInjection.go:19:29:19:132 | ...+... | XPathInjection.go:15:14:15:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:15:14:15:19 | selection of Form | A user-provided value |
+| XPathInjection.go:19:29:19:132 | ...+... | XPathInjection.go:16:14:16:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:16:14:16:19 | selection of Form | A user-provided value |
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.go b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
index 8d7f57ae16c..869c98acb89 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.go
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
@@ -8,6 +8,8 @@ import (
"github.com/ChrisTrenkamp/goxpath/tree"
)
+func main() {}
+
func processRequest(r *http.Request, doc tree.Node) {
r.ParseForm()
username := r.Form.Get("username")
diff --git a/ql/test/query-tests/Security/CWE-643/go.mod b/ql/test/query-tests/Security/CWE-643/go.mod
new file mode 100644
index 00000000000..c4133132055
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/go.mod
@@ -0,0 +1,3 @@
+module main
+
+go 1.14
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/LICENSE
new file mode 100644
index 00000000000..2afe88a6155
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 ChrisTrenkamp
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/README.md
new file mode 100644
index 00000000000..4812afac396
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/ChrisTrenkamp/goxpath, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
new file mode 100644
index 00000000000..2c2f146b058
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
@@ -0,0 +1,22 @@
+package goxpath
+
+import (
+ "github.com/ChrisTrenkamp/goxpath/tree"
+)
+
+type Opts struct {
+ Vars map[string]tree.Result
+}
+
+type XPathExec struct {
+}
+
+type FuncOpts func(*Opts)
+
+func MustParse(xp string) XPathExec {
+ return XPathExec{}
+}
+
+func (xp XPathExec) ExecBool(t tree.Node, opts ...FuncOpts) (bool, error) {
+ return false, nil
+}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
new file mode 100644
index 00000000000..452d9eea7aa
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
@@ -0,0 +1,16 @@
+package tree
+
+import "fmt"
+
+type Node interface {
+}
+
+type Result interface {
+ fmt.Stringer
+}
+
+type String string
+
+func (s String) String() string {
+ return ""
+}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/modules.txt b/ql/test/query-tests/Security/CWE-643/vendor/modules.txt
new file mode 100644
index 00000000000..cb190dec2cc
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/modules.txt
@@ -0,0 +1,3 @@
+# github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d
+github.com/ChrisTrenkamp/goxpath
+github.com/ChrisTrenkamp/goxpath/tree
\ No newline at end of file
From 26cfa939476570a632eb9b5744b5e97cb1090847 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Fri, 27 Mar 2020 21:32:53 +0100
Subject: [PATCH 10/20] Ignore type incompatible sinks
---
ql/src/Security/CWE-643/XPathInjection.ql | 9 ++++++++-
.../go/security/XPathInjectionCustomizations.qll | 12 ------------
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/ql/src/Security/CWE-643/XPathInjection.ql b/ql/src/Security/CWE-643/XPathInjection.ql
index 141004ee60f..b37efe8a1e5 100644
--- a/ql/src/Security/CWE-643/XPathInjection.ql
+++ b/ql/src/Security/CWE-643/XPathInjection.ql
@@ -13,7 +13,14 @@ import go
import semmle.go.security.XPathInjection::XPathInjection
import DataFlow::PathGraph
+/** Holds if `node` is either a string or a byte slice */
+predicate isStringOrByte(DataFlow::PathNode node) {
+ exists(Type t | t = node.getNode().getType().getUnderlyingType() |
+ t instanceof StringType or t instanceof ByteSliceType
+ )
+}
+
from Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink
-where config.hasFlowPath(source, sink)
+where config.hasFlowPath(source, sink) and isStringOrByte(sink)
select sink.getNode(), source, sink, "$@ flows here and is used in an XPath expression.",
source.getNode(), "A user-provided value"
diff --git a/ql/src/semmle/go/security/XPathInjectionCustomizations.qll b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
index 2f1324e57a3..b3a25fc2857 100644
--- a/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
+++ b/ql/src/semmle/go/security/XPathInjectionCustomizations.qll
@@ -38,16 +38,4 @@ module XPathInjection {
class XPathExpressionStringAsSink extends Sink {
XPathExpressionStringAsSink() { this instanceof XPath::XPathExpressionString::Range }
}
-
- //TODO add runes?
- /**
- * A call to `filepath.Rel`, considered as a sanitizer for path traversal.
- */
- /*class NonStringByteSanitizer extends Sanitizer {
- NonStringByteSanitizer() {
- exists(Type t | t = this.getType().getUnderlyingType() |
- not t instanceof StringType or not t instanceof ByteSliceType
- )
- }
- }*/
}
From 051f17ce6708011315f806e7621a71c29a9f565d Mon Sep 17 00:00:00 2001
From: intrigus
Date: Mon, 30 Mar 2020 23:37:37 +0200
Subject: [PATCH 11/20] Fix class name
---
ql/src/semmle/go/frameworks/XPath.qll | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index 6a12ef0397f..c699991bc3e 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -51,8 +51,8 @@ module XPath {
}
/** An XPath expression string used in an API function of the https://github.com/antchfx/xmlquery package. */
- private class AntchfxxmlqueryXPathExpressionString extends Range {
- AntchfxxmlqueryXPathExpressionString() {
+ private class AntchfxXmlqueryXPathExpressionString extends Range {
+ AntchfxXmlqueryXPathExpressionString() {
exists(Function f, string name | name.matches("Find%") |
f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
this = f.getACall().getArgument(1)
From b097826dd861bea421a4499338aeeb6b128d8316 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Mon, 30 Mar 2020 23:42:13 +0200
Subject: [PATCH 12/20] Add missing class qualifiers
---
ql/src/semmle/go/frameworks/XPath.qll | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index c699991bc3e..69a541ff08a 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -64,7 +64,7 @@ module XPath {
)
or
exists(Function f, string name | name.matches("Select%") |
- f.hasQualifiedName("github.com/antchfx/xmlquery", name) and
+ f.hasQualifiedName("github.com/antchfx/xmlquery.Node", name) and
this = f.getACall().getArgument(0)
)
}
@@ -139,12 +139,12 @@ module XPath {
)
or
exists(Function f, string name | name.matches("Search%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
+ f.hasQualifiedName("github.com/moovweb/gokogiri/xml.Node", name) and
this = f.getACall().getArgument(0)
)
or
exists(Function f, string name | name.matches("EvalXPath%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml", name) and
+ f.hasQualifiedName("github.com/moovweb/gokogiri/xml.Node", name) and
this = f.getACall().getArgument(0)
)
}
From e18d15070ad31a753922476366741e6122fb43c5 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Mon, 30 Mar 2020 23:42:44 +0200
Subject: [PATCH 13/20] Switch to jbowtie/gokogiri
---
ql/src/semmle/go/frameworks/XPath.qll | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index 69a541ff08a..9b8a3aabb00 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -130,21 +130,21 @@ module XPath {
}
}
- /** An XPath expression string used in an API function of the https://github.com/moovweb/gokogiri package. */
- private class MoovwebGokogiriXPathExpressionString extends Range {
- MoovwebGokogiriXPathExpressionString() {
+ /** An XPath expression string used in an API function of the https://github.com/jbowtie/gokogiri package. */
+ private class JbowtieGokogiriXPathExpressionString extends Range {
+ JbowtieGokogiriXPathExpressionString() {
exists(Function f, string name | name.matches("Compile%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xpath", name) and
+ f.hasQualifiedName("github.com/jbowtie/gokogiri/xpath", name) and
this = f.getACall().getArgument(0)
)
or
exists(Function f, string name | name.matches("Search%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml.Node", name) and
+ f.hasQualifiedName("github.com/jbowtie/gokogiri/xml.Node", name) and
this = f.getACall().getArgument(0)
)
or
exists(Function f, string name | name.matches("EvalXPath%") |
- f.hasQualifiedName("github.com/moovweb/gokogiri/xml.Node", name) and
+ f.hasQualifiedName("github.com/jbowtie/gokogiri/xml.Node", name) and
this = f.getACall().getArgument(0)
)
}
From 66451a776d3beb78f6e7470d0cf6c65fea96505c Mon Sep 17 00:00:00 2001
From: intrigus
Date: Mon, 30 Mar 2020 23:44:25 +0200
Subject: [PATCH 14/20] Add test cases for all libraries
Note: This is currently missing appropriate vendoring
so will probably fail for now.
---
.../Security/CWE-643/XPathInjection.expected | 126 ++++++++++++-
.../Security/CWE-643/XPathInjection.go | 172 ++++++++++++++++--
2 files changed, 277 insertions(+), 21 deletions(-)
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
index 75010112dae..7e3a340dfc3 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
@@ -1,10 +1,122 @@
edges
-| XPathInjection.go:15:14:15:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... |
-| XPathInjection.go:16:14:16:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... |
+| XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:24:23:24:85 | ...+... |
+| XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:27:24:27:86 | ...+... |
+| XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:30:24:30:82 | ...+... |
+| XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:38:26:38:84 | ...+... |
+| XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:41:29:41:87 | ...+... |
+| XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:44:33:44:91 | ...+... |
+| XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:47:30:47:88 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:55:25:55:83 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:58:28:58:86 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:61:25:61:83 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:64:34:64:92 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:67:32:67:90 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:70:29:70:87 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:73:23:73:85 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:19:76:81 | ...+... |
+| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:84:26:84:84 | ...+... |
+| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:87:29:87:87 | ...+... |
+| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:90:33:90:91 | ...+... |
+| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:93:30:93:88 | ...+... |
+| XPathInjection.go:98:14:98:19 | selection of Form : Values | XPathInjection.go:101:25:101:87 | ...+... |
+| XPathInjection.go:98:14:98:19 | selection of Form : Values | XPathInjection.go:104:26:104:88 | ...+... |
+| XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:113:23:113:126 | ...+... |
+| XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:116:24:116:127 | ...+... |
+| XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:119:27:119:122 | ...+... |
+| XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:113:23:113:126 | ...+... |
+| XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:116:24:116:127 | ...+... |
+| XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:119:27:119:122 | ...+... |
+| XPathInjection.go:127:14:127:19 | selection of Form : Values | XPathInjection.go:130:27:130:89 | ...+... |
+| XPathInjection.go:127:14:127:19 | selection of Form : Values | XPathInjection.go:133:28:133:90 | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:142:33:142:136 | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:145:18:145:121 | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:151:31:151:126 | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:160:21:160:116 | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:169:27:169:122 | ...+... |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:142:33:142:136 | ...+... |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:145:18:145:121 | ...+... |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:151:31:151:126 | ...+... |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:160:21:160:116 | ...+... |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:169:27:169:122 | ...+... |
nodes
-| XPathInjection.go:15:14:15:19 | selection of Form : Values | semmle.label | selection of Form : Values |
-| XPathInjection.go:16:14:16:19 | selection of Form : Values | semmle.label | selection of Form : Values |
-| XPathInjection.go:19:29:19:132 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:21:14:21:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:24:23:24:85 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:27:24:27:86 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:30:24:30:82 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:35:14:35:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:38:26:38:84 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:41:29:41:87 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:44:33:44:91 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:47:30:47:88 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:55:25:55:83 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:58:28:58:86 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:61:25:61:83 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:64:34:64:92 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:67:32:67:90 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:70:29:70:87 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:73:23:73:85 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:76:19:76:81 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:81:14:81:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:84:26:84:84 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:87:29:87:87 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:90:33:90:91 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:93:30:93:88 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:98:14:98:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:101:25:101:87 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:104:26:104:88 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:109:14:109:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:110:14:110:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:113:23:113:126 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:116:24:116:127 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:119:27:119:122 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:127:14:127:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:130:27:130:89 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:133:28:133:90 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:138:14:138:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:139:14:139:19 | selection of Form : Values | semmle.label | selection of Form : Values |
+| XPathInjection.go:142:33:142:136 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:145:18:145:121 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:151:31:151:126 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:160:21:160:116 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:169:27:169:122 | ...+... | semmle.label | ...+... |
#select
-| XPathInjection.go:19:29:19:132 | ...+... | XPathInjection.go:15:14:15:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:15:14:15:19 | selection of Form | A user-provided value |
-| XPathInjection.go:19:29:19:132 | ...+... | XPathInjection.go:16:14:16:19 | selection of Form : Values | XPathInjection.go:19:29:19:132 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:16:14:16:19 | selection of Form | A user-provided value |
+| XPathInjection.go:24:23:24:85 | ...+... | XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:24:23:24:85 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:21:14:21:19 | selection of Form | A user-provided value |
+| XPathInjection.go:27:24:27:86 | ...+... | XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:27:24:27:86 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:21:14:21:19 | selection of Form | A user-provided value |
+| XPathInjection.go:30:24:30:82 | ...+... | XPathInjection.go:21:14:21:19 | selection of Form : Values | XPathInjection.go:30:24:30:82 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:21:14:21:19 | selection of Form | A user-provided value |
+| XPathInjection.go:38:26:38:84 | ...+... | XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:38:26:38:84 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:35:14:35:19 | selection of Form | A user-provided value |
+| XPathInjection.go:41:29:41:87 | ...+... | XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:41:29:41:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:35:14:35:19 | selection of Form | A user-provided value |
+| XPathInjection.go:44:33:44:91 | ...+... | XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:44:33:44:91 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:35:14:35:19 | selection of Form | A user-provided value |
+| XPathInjection.go:47:30:47:88 | ...+... | XPathInjection.go:35:14:35:19 | selection of Form : Values | XPathInjection.go:47:30:47:88 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:35:14:35:19 | selection of Form | A user-provided value |
+| XPathInjection.go:55:25:55:83 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:55:25:55:83 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:58:28:58:86 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:58:28:58:86 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:61:25:61:83 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:61:25:61:83 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:64:34:64:92 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:64:34:64:92 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:67:32:67:90 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:67:32:67:90 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:70:29:70:87 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:70:29:70:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:73:23:73:85 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:73:23:73:85 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:76:19:76:81 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:19:76:81 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:84:26:84:84 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:84:26:84:84 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
+| XPathInjection.go:87:29:87:87 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:87:29:87:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
+| XPathInjection.go:90:33:90:91 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:90:33:90:91 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
+| XPathInjection.go:93:30:93:88 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:93:30:93:88 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
+| XPathInjection.go:101:25:101:87 | ...+... | XPathInjection.go:98:14:98:19 | selection of Form : Values | XPathInjection.go:101:25:101:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:98:14:98:19 | selection of Form | A user-provided value |
+| XPathInjection.go:104:26:104:88 | ...+... | XPathInjection.go:98:14:98:19 | selection of Form : Values | XPathInjection.go:104:26:104:88 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:98:14:98:19 | selection of Form | A user-provided value |
+| XPathInjection.go:113:23:113:126 | ...+... | XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:113:23:113:126 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:109:14:109:19 | selection of Form | A user-provided value |
+| XPathInjection.go:113:23:113:126 | ...+... | XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:113:23:113:126 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:110:14:110:19 | selection of Form | A user-provided value |
+| XPathInjection.go:116:24:116:127 | ...+... | XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:116:24:116:127 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:109:14:109:19 | selection of Form | A user-provided value |
+| XPathInjection.go:116:24:116:127 | ...+... | XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:116:24:116:127 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:110:14:110:19 | selection of Form | A user-provided value |
+| XPathInjection.go:119:27:119:122 | ...+... | XPathInjection.go:109:14:109:19 | selection of Form : Values | XPathInjection.go:119:27:119:122 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:109:14:109:19 | selection of Form | A user-provided value |
+| XPathInjection.go:119:27:119:122 | ...+... | XPathInjection.go:110:14:110:19 | selection of Form : Values | XPathInjection.go:119:27:119:122 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:110:14:110:19 | selection of Form | A user-provided value |
+| XPathInjection.go:130:27:130:89 | ...+... | XPathInjection.go:127:14:127:19 | selection of Form : Values | XPathInjection.go:130:27:130:89 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:127:14:127:19 | selection of Form | A user-provided value |
+| XPathInjection.go:133:28:133:90 | ...+... | XPathInjection.go:127:14:127:19 | selection of Form : Values | XPathInjection.go:133:28:133:90 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:127:14:127:19 | selection of Form | A user-provided value |
+| XPathInjection.go:142:33:142:136 | ...+... | XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:142:33:142:136 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:138:14:138:19 | selection of Form | A user-provided value |
+| XPathInjection.go:142:33:142:136 | ...+... | XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:142:33:142:136 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:139:14:139:19 | selection of Form | A user-provided value |
+| XPathInjection.go:145:18:145:121 | ...+... | XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:145:18:145:121 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:138:14:138:19 | selection of Form | A user-provided value |
+| XPathInjection.go:145:18:145:121 | ...+... | XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:145:18:145:121 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:139:14:139:19 | selection of Form | A user-provided value |
+| XPathInjection.go:151:31:151:126 | ...+... | XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:151:31:151:126 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:138:14:138:19 | selection of Form | A user-provided value |
+| XPathInjection.go:151:31:151:126 | ...+... | XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:151:31:151:126 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:139:14:139:19 | selection of Form | A user-provided value |
+| XPathInjection.go:160:21:160:116 | ...+... | XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:160:21:160:116 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:138:14:138:19 | selection of Form | A user-provided value |
+| XPathInjection.go:160:21:160:116 | ...+... | XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:160:21:160:116 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:139:14:139:19 | selection of Form | A user-provided value |
+| XPathInjection.go:169:27:169:122 | ...+... | XPathInjection.go:138:14:138:19 | selection of Form : Values | XPathInjection.go:169:27:169:122 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:138:14:138:19 | selection of Form | A user-provided value |
+| XPathInjection.go:169:27:169:122 | ...+... | XPathInjection.go:139:14:139:19 | selection of Form : Values | XPathInjection.go:169:27:169:122 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:139:14:139:19 | selection of Form | A user-provided value |
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.go b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
index 869c98acb89..6fe589ac4a9 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.go
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
@@ -1,32 +1,176 @@
package main
import (
- "fmt"
"net/http"
"github.com/ChrisTrenkamp/goxpath"
- "github.com/ChrisTrenkamp/goxpath/tree"
+ "github.com/antchfx/htmlquery"
+ "github.com/antchfx/jsonquery"
+ "github.com/antchfx/xmlquery"
+ "github.com/antchfx/xpath"
+ "github.com/go-xmlpath/xmlpath"
+ gokogiriXml "github.com/jbowtie/gokogiri/xml"
+ gokogiriXpath "github.com/jbowtie/gokogiri/xpath"
+ "github.com/santhosh-tekuri/xpathparser"
)
func main() {}
-func processRequest(r *http.Request, doc tree.Node) {
+func testAntchfxXpath(r *http.Request) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = xpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xpath.Select(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+}
+
+func testAntchfxHtmlquery(r *http.Request) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _ = htmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = htmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = htmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = htmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+}
+
+func testAntchfxXmlquery(r *http.Request, n *xmlquery.Node) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xmlquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xmlquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ xmlquery.FindEach(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil)
+
+ // BAD: User input used directly in an XPath expression
+ xmlquery.FindEachWithBreak(nil, "//users/user[login/text()='"+username+"']/home_dir/text()", nil)
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = xmlquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = xmlquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = n.SelectElements("//users/user[login/text()='" + username + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = n.SelectAttr("//users/user[login/text()='" + username + "']/home_dir/text()")
+}
+
+func testAntchfxJsonquery(r *http.Request) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _ = jsonquery.Find(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = jsonquery.FindOne(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = jsonquery.QueryAll(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = jsonquery.Query(nil, "//users/user[login/text()='"+username+"']/home_dir/text()")
+}
+
+func testGoXmlpathXmlpath(r *http.Request) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = xmlpath.Compile("//users/user[login/text()='" + username + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xmlpath.MustCompile("//users/user[login/text()='" + username + "']/home_dir/text()")
+}
+
+func testChrisTrenkampGoxpath(r *http.Request) {
r.ParseForm()
username := r.Form.Get("username")
password := r.Form.Get("password")
// BAD: User input used directly in an XPath expression
- xPath := goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
- unsafeRes, _ := xPath.ExecBool(doc)
- fmt.Println(unsafeRes)
+ _, _ = goxpath.Parse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = goxpath.MustParse("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = goxpath.ParseExec("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil)
- // GOOD: Value of parameters is defined here instead of directly in the query
- opt := func(o *goxpath.Opts) {
- o.Vars["username"] = tree.String(username)
- o.Vars["password"] = tree.String(password)
- }
// GOOD: Uses parameters to avoid including user input directly in XPath expression
- xPath = goxpath.MustParse("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()")
- safeRes, _ := xPath.ExecBool(doc, opt)
- fmt.Println(safeRes)
+ _ = goxpath.MustParse("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()")
+}
+
+func testSanthoshTekuriXpathparser(r *http.Request) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = xpathparser.Parse("//users/user[login/text()='" + username + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _ = xpathparser.MustParse("//users/user[login/text()='" + username + "']/home_dir/text()")
+}
+
+func testJbowtieGokogiri(r *http.Request, n gokogiriXml.Node) {
+ r.ParseForm()
+ username := r.Form.Get("username")
+ password := r.Form.Get("password")
+
+ // BAD: User input used directly in an XPath expression
+ xpath := gokogiriXpath.Compile("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = n.Search("//users/user[login/text()='" + username + "' and password/text() = '" + password + "']/home_dir/text()")
+
+ // OK: This is not flagged, since the creation of `xpath` is already flagged.
+ _, _ = n.Search(xpath)
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = n.SearchWithVariables("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil)
+
+ // GOOD: Uses parameters to avoid including user input directly in XPath expression
+ _, _ = n.SearchWithVariables("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()", nil)
+
+ // OK: This is not flagged, since the creation of `xpath` is already flagged.
+ _, _ = n.SearchWithVariables(xpath, nil)
+
+ // BAD: User input used directly in an XPath expression
+ _, _ = n.EvalXPath("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil)
+
+ // GOOD: Uses parameters to avoid including user input directly in XPath expression
+ _, _ = n.EvalXPath("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()", nil)
+
+ // OK: This is not flagged, since the creation of `xpath` is already flagged.
+ _, _ = n.EvalXPath(xpath, nil)
+
+ // BAD: User input used directly in an XPath expression
+ _ = n.EvalXPathAsBoolean("//users/user[login/text()='"+username+"' and password/text() = '"+password+"']/home_dir/text()", nil)
+
+ // GOOD: Uses parameters to avoid including user input directly in XPath expression
+ _ = n.EvalXPathAsBoolean("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()", nil)
+
+ // OK: This is not flagged, since the creation of `xpath` is already flagged.
+ _ = n.EvalXPathAsBoolean(xpath, nil)
}
From 0586fe92353486abfdcec6db279d6ced4bdbb31c Mon Sep 17 00:00:00 2001
From: intrigus
Date: Tue, 31 Mar 2020 16:46:08 +0200
Subject: [PATCH 15/20] Add missing stubs in vendor/
---
ql/test/query-tests/Security/CWE-643/go.mod | 15 +-
.../ChrisTrenkamp/goxpath/goxpath.go | 23 +--
.../ChrisTrenkamp/goxpath/tree/tree.go | 16 --
.../github.com/antchfx/htmlquery/LICENSE | 17 ++
.../github.com/antchfx/htmlquery/README.md | 3 +
.../github.com/antchfx/htmlquery/query.go | 7 +
.../github.com/antchfx/jsonquery/LICENSE | 17 ++
.../github.com/antchfx/jsonquery/README.md | 3 +
.../github.com/antchfx/jsonquery/node.go | 3 +
.../github.com/antchfx/jsonquery/query.go | 6 +
.../github.com/antchfx/xmlquery/LICENSE | 17 ++
.../github.com/antchfx/xmlquery/README.md | 3 +
.../github.com/antchfx/xmlquery/node.go | 4 +
.../github.com/antchfx/xmlquery/query.go | 10 +
.../vendor/github.com/antchfx/xpath/LICENSE | 17 ++
.../vendor/github.com/antchfx/xpath/README.md | 3 +
.../vendor/github.com/antchfx/xpath/xpath.go | 16 ++
.../github.com/go-xmlpath/xmlpath/LICENSE | 187 ++++++++++++++++++
.../github.com/go-xmlpath/xmlpath/README.md | 3 +
.../github.com/go-xmlpath/xmlpath/path.go | 7 +
.../github.com/jbowtie/gokogiri/LICENSE | 7 +
.../github.com/jbowtie/gokogiri/README.md | 3 +
.../github.com/jbowtie/gokogiri/xml/node.go | 8 +
.../jbowtie/gokogiri/xpath/expression.go | 6 +
.../jbowtie/gokogiri/xpath/xpath.go | 3 +
.../santhosh-tekuri/xpathparser/LICENSE | 27 +++
.../santhosh-tekuri/xpathparser/README.md | 3 +
.../santhosh-tekuri/xpathparser/xpath.go | 6 +
.../CWE-643/vendor/golang.org/x/net/AUTHORS | 3 +
.../vendor/golang.org/x/net/CONTRIBUTORS | 3 +
.../CWE-643/vendor/golang.org/x/net/LICENSE | 27 +++
.../CWE-643/vendor/golang.org/x/net/PATENTS | 22 +++
.../CWE-643/vendor/golang.org/x/net/README.md | 3 +
.../vendor/golang.org/x/net/html/node.go | 4 +
.../Security/CWE-643/vendor/modules.txt | 27 ++-
35 files changed, 493 insertions(+), 36 deletions(-)
delete mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/node.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/query.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/node.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/query.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/xpath.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/path.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/expression.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/xpath.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/xpath.go
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/AUTHORS
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/CONTRIBUTORS
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/LICENSE
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/PATENTS
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/README.md
create mode 100644 ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/html/node.go
diff --git a/ql/test/query-tests/Security/CWE-643/go.mod b/ql/test/query-tests/Security/CWE-643/go.mod
index c4133132055..f274ed45000 100644
--- a/ql/test/query-tests/Security/CWE-643/go.mod
+++ b/ql/test/query-tests/Security/CWE-643/go.mod
@@ -1,3 +1,16 @@
module main
-go 1.14
+go 1.13
+
+require (
+ github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d
+ github.com/antchfx/htmlquery v1.2.2
+ github.com/antchfx/jsonquery v1.1.2
+ github.com/antchfx/xmlquery v1.2.3
+ github.com/antchfx/xpath v1.1.4
+ github.com/go-xmlpath/xmlpath v0.0.0-20150820204837-860cbeca3ebc
+ github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
+ github.com/jbowtie/gokogiri v0.0.0-20190301021639-37f655d3078f
+ github.com/santhosh-tekuri/xpathparser v1.0.0
+ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
+)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
index 2c2f146b058..c7b872ccd84 100644
--- a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
@@ -1,22 +1,9 @@
package goxpath
-import (
- "github.com/ChrisTrenkamp/goxpath/tree"
-)
-
-type Opts struct {
- Vars map[string]tree.Result
-}
-
-type XPathExec struct {
-}
-
+type Opts struct {}
type FuncOpts func(*Opts)
-func MustParse(xp string) XPathExec {
- return XPathExec{}
-}
-
-func (xp XPathExec) ExecBool(t tree.Node, opts ...FuncOpts) (bool, error) {
- return false, nil
-}
+type XPathExec struct {}
+func Parse(xp string) (XPathExec, error)
+func MustParse(xp string) XPathExec
+func ParseExec(xpstr string, t tree.Node, opts ...FuncOpts) (tree.Result, error)
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
deleted file mode 100644
index 452d9eea7aa..00000000000
--- a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/tree/tree.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package tree
-
-import "fmt"
-
-type Node interface {
-}
-
-type Result interface {
- fmt.Stringer
-}
-
-type String string
-
-func (s String) String() string {
- return ""
-}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/LICENSE
new file mode 100644
index 00000000000..e14c37141c5
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/LICENSE
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/README.md
new file mode 100644
index 00000000000..34024e519bf
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/antchfx/htmlquery, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
new file mode 100644
index 00000000000..d6a7fc4292f
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
@@ -0,0 +1,7 @@
+package htmlquery
+
+
+func Find(top *html.Node, expr string) []*html.Node
+func FindOne(top *html.Node, expr string) *html.Node
+func QueryAll(top *html.Node, expr string) ([]*html.Node, error)
+func Query(top *html.Node, expr string) (*html.Node, error)
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/LICENSE
new file mode 100644
index 00000000000..e14c37141c5
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/LICENSE
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/README.md
new file mode 100644
index 00000000000..533b3887b0a
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/antchfx/jsonquery, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/node.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/node.go
new file mode 100644
index 00000000000..b09fb54a83f
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/node.go
@@ -0,0 +1,3 @@
+package jsonquery
+
+type Node struct{}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/query.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/query.go
new file mode 100644
index 00000000000..d3a43a46f77
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/jsonquery/query.go
@@ -0,0 +1,6 @@
+package jsonquery
+
+func Find(top *Node, expr string) []*Node
+func FindOne(top *Node, expr string) *Node
+func QueryAll(top *Node, expr string) ([]*Node, error)
+func Query(top *Node, expr string) (*Node, error)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/LICENSE
new file mode 100644
index 00000000000..e14c37141c5
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/LICENSE
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/README.md
new file mode 100644
index 00000000000..da531d361a9
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/antchfx/xmlquery, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/node.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/node.go
new file mode 100644
index 00000000000..8bb284f174e
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/node.go
@@ -0,0 +1,4 @@
+package xmlquery
+
+type Node struct {
+}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/query.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/query.go
new file mode 100644
index 00000000000..28e85185ed9
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xmlquery/query.go
@@ -0,0 +1,10 @@
+package xmlquery
+
+func (n *Node) SelectElements(name string) []*Node
+func (n *Node) SelectElement(name string) *Node
+func Find(top *Node, expr string) []*Node
+func FindOne(top *Node, expr string) *Node
+func QueryAll(top *Node, expr string) ([]*Node, error)
+func Query(top *Node, expr string) (*Node, error)
+func FindEach(top *Node, expr string, cb func(int, *Node))
+func FindEachWithBreak(top *Node, expr string, cb func(int, *Node) bool)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/LICENSE
new file mode 100644
index 00000000000..e14c37141c5
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/LICENSE
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/README.md
new file mode 100644
index 00000000000..4d741a91818
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/antchfx/xpath, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/xpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/xpath.go
new file mode 100644
index 00000000000..538a3abb871
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/xpath/xpath.go
@@ -0,0 +1,16 @@
+package xpath
+
+type NodeNavigator interface {
+}
+
+type NodeIterator struct {
+}
+
+func Select(root NodeNavigator, expr string) *NodeIterator
+
+type Expr struct {
+}
+
+func Compile(expr string) (*Expr, error)
+
+func MustCompile(expr string) *Expr
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/LICENSE
new file mode 100644
index 00000000000..4ccd784ba7b
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/LICENSE
@@ -0,0 +1,187 @@
+Copyright (c) 2013-2014 Canonical Inc.
+
+This software is licensed under the LGPLv3, included below.
+
+As a special exception to the GNU Lesser General Public License version 3
+("LGPL3"), the copyright holders of this Library give you permission to
+convey to a third party a Combined Work that links statically or dynamically
+to this Library without providing any Minimal Corresponding Source or
+Minimal Application Code as set out in 4d or providing the installation
+information set out in section 4e, provided that you comply with the other
+provisions of LGPL3 and provided that you meet, for the Application the
+terms and conditions of the license(s) which apply to the Application.
+
+Except as stated in this special exception, the provisions of LGPL3 will
+continue to comply in full to this Library. If you modify this Library, you
+may apply this exception to your version of this Library, but you are not
+obliged to do so. If you do not wish to do so, delete this exception
+statement from your version. This exception does not (and cannot) modify any
+license terms which apply to the Application, with which you must still
+comply.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/README.md
new file mode 100644
index 00000000000..3584c6f7343
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/go-xmlpath/xmlpath, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/path.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/path.go
new file mode 100644
index 00000000000..ffa658413a7
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/go-xmlpath/xmlpath/path.go
@@ -0,0 +1,7 @@
+package xmlpath
+
+type Path struct {
+}
+
+func MustCompile(path string) *Path
+func Compile(path string) (*Path, error)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/LICENSE
new file mode 100644
index 00000000000..eb094e44412
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2011-2012 Zhigang Chen and Hampton Catlin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/README.md
new file mode 100644
index 00000000000..0feacaef87b
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/jbowtie/gokogiri, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
new file mode 100644
index 00000000000..6eebd74cbb6
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
@@ -0,0 +1,8 @@
+package xml
+
+type Node interface {
+ Search(interface{}) ([]Node, error)
+ SearchWithVariables(interface{}, xpath.VariableScope) ([]Node, error)
+ EvalXPath(interface{}, xpath.VariableScope) (interface{}, error)
+ EvalXPathAsBoolean(interface{}, xpath.VariableScope) bool
+}
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/expression.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/expression.go
new file mode 100644
index 00000000000..9166459815b
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/expression.go
@@ -0,0 +1,6 @@
+package xpath
+
+type Expression struct {
+}
+
+func Compile(path string) (expr *Expression)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/xpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/xpath.go
new file mode 100644
index 00000000000..0de126bee56
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xpath/xpath.go
@@ -0,0 +1,3 @@
+package xpath
+
+type VariableScope interface{}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/LICENSE
new file mode 100644
index 00000000000..65cd403ab0e
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2017 Santhosh Kumar Tekuri. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/README.md b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/README.md
new file mode 100644
index 00000000000..a806adde588
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://github.com/santhosh-tekuri/xpathparser, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/xpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/xpath.go
new file mode 100644
index 00000000000..099d1e84d80
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/santhosh-tekuri/xpathparser/xpath.go
@@ -0,0 +1,6 @@
+package xpathparser
+
+type Expr interface{}
+
+func MustParse(xpath string) Expr
+func Parse(xpath string) (expr Expr, err error)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/AUTHORS b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/AUTHORS
new file mode 100644
index 00000000000..15167cd746c
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/AUTHORS
@@ -0,0 +1,3 @@
+# This source code refers to The Go Authors for copyright purposes.
+# The master list of authors is in the main Go distribution,
+# visible at http://tip.golang.org/AUTHORS.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/CONTRIBUTORS b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/CONTRIBUTORS
new file mode 100644
index 00000000000..1c4577e9680
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/CONTRIBUTORS
@@ -0,0 +1,3 @@
+# This source code was written by the Go contributors.
+# The master list of contributors is in the main Go distribution,
+# visible at http://tip.golang.org/CONTRIBUTORS.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/LICENSE b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/LICENSE
new file mode 100644
index 00000000000..6a66aea5eaf
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/PATENTS b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/PATENTS
new file mode 100644
index 00000000000..733099041f8
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Go project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Go, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Go. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Go or any code incorporated within this
+implementation of Go constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Go
+shall terminate as of the date such litigation is filed.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/README.md b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/README.md
new file mode 100644
index 00000000000..dcae7bfe502
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/README.md
@@ -0,0 +1,3 @@
+This is a simple stub for https://golang.org/x/net, strictly for use in query testing.
+
+See the LICENSE file in this folder for information about the licensing of the original library.
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/html/node.go b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/html/node.go
new file mode 100644
index 00000000000..04e99a9cd49
--- /dev/null
+++ b/ql/test/query-tests/Security/CWE-643/vendor/golang.org/x/net/html/node.go
@@ -0,0 +1,4 @@
+package html
+
+type Node struct {
+}
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/modules.txt b/ql/test/query-tests/Security/CWE-643/vendor/modules.txt
index cb190dec2cc..7e9be09392f 100644
--- a/ql/test/query-tests/Security/CWE-643/vendor/modules.txt
+++ b/ql/test/query-tests/Security/CWE-643/vendor/modules.txt
@@ -1,3 +1,28 @@
# github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d
+## explicit
github.com/ChrisTrenkamp/goxpath
-github.com/ChrisTrenkamp/goxpath/tree
\ No newline at end of file
+# github.com/antchfx/htmlquery v1.2.2
+## explicit
+github.com/antchfx/htmlquery
+# github.com/antchfx/jsonquery v1.1.2
+## explicit
+github.com/antchfx/jsonquery
+# github.com/antchfx/xmlquery v1.2.3
+## explicit
+github.com/antchfx/xmlquery
+# github.com/antchfx/xpath v1.1.4
+## explicit
+github.com/antchfx/xpath
+# github.com/go-xmlpath/xmlpath v0.0.0-20150820204837-860cbeca3ebc
+## explicit
+github.com/go-xmlpath/xmlpath
+# github.com/jbowtie/gokogiri v0.0.0-20190301021639-37f655d3078f
+## explicit
+github.com/jbowtie/gokogiri/xml
+github.com/jbowtie/gokogiri/xpath
+# github.com/santhosh-tekuri/xpathparser v1.0.0
+## explicit
+github.com/santhosh-tekuri/xpathparser
+# golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
+## explicit
+golang.org/x/net/html
\ No newline at end of file
From 4924be54a7dfd26267965f988c42710f64a2192b Mon Sep 17 00:00:00 2001
From: intrigus
Date: Tue, 31 Mar 2020 16:46:29 +0200
Subject: [PATCH 16/20] Fix one test method
---
.../query-tests/Security/CWE-643/XPathInjection.expected | 6 +++---
ql/test/query-tests/Security/CWE-643/XPathInjection.go | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
index 7e3a340dfc3..c9ca557e59e 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.expected
@@ -13,7 +13,7 @@ edges
| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:67:32:67:90 | ...+... |
| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:70:29:70:87 | ...+... |
| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:73:23:73:85 | ...+... |
-| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:19:76:81 | ...+... |
+| XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:22:76:84 | ...+... |
| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:84:26:84:84 | ...+... |
| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:87:29:87:87 | ...+... |
| XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:90:33:90:91 | ...+... |
@@ -56,7 +56,7 @@ nodes
| XPathInjection.go:67:32:67:90 | ...+... | semmle.label | ...+... |
| XPathInjection.go:70:29:70:87 | ...+... | semmle.label | ...+... |
| XPathInjection.go:73:23:73:85 | ...+... | semmle.label | ...+... |
-| XPathInjection.go:76:19:76:81 | ...+... | semmle.label | ...+... |
+| XPathInjection.go:76:22:76:84 | ...+... | semmle.label | ...+... |
| XPathInjection.go:81:14:81:19 | selection of Form : Values | semmle.label | selection of Form : Values |
| XPathInjection.go:84:26:84:84 | ...+... | semmle.label | ...+... |
| XPathInjection.go:87:29:87:87 | ...+... | semmle.label | ...+... |
@@ -95,7 +95,7 @@ nodes
| XPathInjection.go:67:32:67:90 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:67:32:67:90 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
| XPathInjection.go:70:29:70:87 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:70:29:70:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
| XPathInjection.go:73:23:73:85 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:73:23:73:85 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
-| XPathInjection.go:76:19:76:81 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:19:76:81 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
+| XPathInjection.go:76:22:76:84 | ...+... | XPathInjection.go:52:14:52:19 | selection of Form : Values | XPathInjection.go:76:22:76:84 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:52:14:52:19 | selection of Form | A user-provided value |
| XPathInjection.go:84:26:84:84 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:84:26:84:84 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
| XPathInjection.go:87:29:87:87 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:87:29:87:87 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
| XPathInjection.go:90:33:90:91 | ...+... | XPathInjection.go:81:14:81:19 | selection of Form : Values | XPathInjection.go:90:33:90:91 | ...+... | $@ flows here and is used in an XPath expression. | XPathInjection.go:81:14:81:19 | selection of Form | A user-provided value |
diff --git a/ql/test/query-tests/Security/CWE-643/XPathInjection.go b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
index 6fe589ac4a9..75ca454bd5d 100644
--- a/ql/test/query-tests/Security/CWE-643/XPathInjection.go
+++ b/ql/test/query-tests/Security/CWE-643/XPathInjection.go
@@ -73,7 +73,7 @@ func testAntchfxXmlquery(r *http.Request, n *xmlquery.Node) {
_ = n.SelectElements("//users/user[login/text()='" + username + "']/home_dir/text()")
// BAD: User input used directly in an XPath expression
- _ = n.SelectAttr("//users/user[login/text()='" + username + "']/home_dir/text()")
+ _ = n.SelectElement("//users/user[login/text()='" + username + "']/home_dir/text()")
}
func testAntchfxJsonquery(r *http.Request) {
From 615fe09ed71a9039ee887df536cc70ab80aea1f1 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Wed, 1 Apr 2020 15:52:55 +0200
Subject: [PATCH 17/20] Format go test stubs
---
.../vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go | 7 ++++---
.../CWE-643/vendor/github.com/antchfx/htmlquery/query.go | 3 +--
.../CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
index c7b872ccd84..1867a462121 100644
--- a/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/ChrisTrenkamp/goxpath/goxpath.go
@@ -1,9 +1,10 @@
package goxpath
-type Opts struct {}
+type Opts struct{}
type FuncOpts func(*Opts)
-type XPathExec struct {}
+type XPathExec struct{}
+
func Parse(xp string) (XPathExec, error)
func MustParse(xp string) XPathExec
-func ParseExec(xpstr string, t tree.Node, opts ...FuncOpts) (tree.Result, error)
\ No newline at end of file
+func ParseExec(xpstr string, t tree.Node, opts ...FuncOpts) (tree.Result, error)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
index d6a7fc4292f..f3f88db24c5 100644
--- a/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/antchfx/htmlquery/query.go
@@ -1,7 +1,6 @@
package htmlquery
-
func Find(top *html.Node, expr string) []*html.Node
func FindOne(top *html.Node, expr string) *html.Node
func QueryAll(top *html.Node, expr string) ([]*html.Node, error)
-func Query(top *html.Node, expr string) (*html.Node, error)
\ No newline at end of file
+func Query(top *html.Node, expr string) (*html.Node, error)
diff --git a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
index 6eebd74cbb6..6ae0dc780b6 100644
--- a/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
+++ b/ql/test/query-tests/Security/CWE-643/vendor/github.com/jbowtie/gokogiri/xml/node.go
@@ -5,4 +5,4 @@ type Node interface {
SearchWithVariables(interface{}, xpath.VariableScope) ([]Node, error)
EvalXPath(interface{}, xpath.VariableScope) (interface{}, error)
EvalXPathAsBoolean(interface{}, xpath.VariableScope) bool
-}
\ No newline at end of file
+}
From a524cc47163a77692f563936b5e2a0bc2a5d6048 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Wed, 1 Apr 2020 16:04:24 +0200
Subject: [PATCH 18/20] Properly match methods defined in classes
---
ql/src/semmle/go/frameworks/XPath.qll | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ql/src/semmle/go/frameworks/XPath.qll b/ql/src/semmle/go/frameworks/XPath.qll
index 9b8a3aabb00..932d0b04cd5 100644
--- a/ql/src/semmle/go/frameworks/XPath.qll
+++ b/ql/src/semmle/go/frameworks/XPath.qll
@@ -63,9 +63,9 @@ module XPath {
this = f.getACall().getArgument(1)
)
or
- exists(Function f, string name | name.matches("Select%") |
- f.hasQualifiedName("github.com/antchfx/xmlquery.Node", name) and
- this = f.getACall().getArgument(0)
+ exists(Method m, string name | name.matches("Select%") |
+ m.hasQualifiedName("github.com/antchfx/xmlquery", "Node", name) and
+ this = m.getACall().getArgument(0)
)
}
}
@@ -138,14 +138,14 @@ module XPath {
this = f.getACall().getArgument(0)
)
or
- exists(Function f, string name | name.matches("Search%") |
- f.hasQualifiedName("github.com/jbowtie/gokogiri/xml.Node", name) and
- this = f.getACall().getArgument(0)
+ exists(Method m, string name | name.matches("Search%") |
+ m.hasQualifiedName("github.com/jbowtie/gokogiri/xml", "Node", name) and
+ this = m.getACall().getArgument(0)
)
or
- exists(Function f, string name | name.matches("EvalXPath%") |
- f.hasQualifiedName("github.com/jbowtie/gokogiri/xml.Node", name) and
- this = f.getACall().getArgument(0)
+ exists(Method m, string name | name.matches("EvalXPath%") |
+ m.hasQualifiedName("github.com/jbowtie/gokogiri/xml", "Node", name) and
+ this = m.getACall().getArgument(0)
)
}
}
From 3a381b2fbff6a059fe8729f17565c2bf2275bcf8 Mon Sep 17 00:00:00 2001
From: intrigus
Date: Wed, 1 Apr 2020 16:15:09 +0200
Subject: [PATCH 19/20] Add change note
---
change-notes/1.24/analysis-go.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/change-notes/1.24/analysis-go.md b/change-notes/1.24/analysis-go.md
index 1a9dc1caeb8..dba6fb514e2 100644
--- a/change-notes/1.24/analysis-go.md
+++ b/change-notes/1.24/analysis-go.md
@@ -18,6 +18,7 @@ The CodeQL library for Go now contains a folder of simple "cookbook" queries tha
| Incomplete URL scheme check (`go/incomplete-url-scheme-check`) | correctness, security, external/cwe/cwe-020 | Highlights checks for `javascript` URLs that do not take `data` or `vbscript` URLs into account. Results are shown on LGTM by default. |
| Potentially unsafe quoting (`go/unsafe-quoting`) | correctness, security, external/cwe/cwe-078, external/cwe/cwe-089, external/cwe/cwe-094 | Highlights code that constructs a quoted string literal containing data that may itself contain quotes. Results are shown on LGTM by default. |
| Size computation for allocation may overflow (`go/allocation-size-overflow`) | correctness, security, external/cwe/cwe-190 | Highlights code that computes the size of an allocation based on the size of a potentially large object. Results are shown on LGTM by default. |
+| XPath injection (`go/xml/xpath-injection`) | security, external/cwe/cwe-643 | Highlights code that uses remote input in an XPath expression. Results are shown on LGTM by default. |
## Changes to existing queries
From be21d49cf25f6a0ffa1625a89001973b6f11be8a Mon Sep 17 00:00:00 2001
From: intrigus
Date: Wed, 1 Apr 2020 16:15:24 +0200
Subject: [PATCH 20/20] Add precision to query
---
ql/src/Security/CWE-643/XPathInjection.ql | 1 +
1 file changed, 1 insertion(+)
diff --git a/ql/src/Security/CWE-643/XPathInjection.ql b/ql/src/Security/CWE-643/XPathInjection.ql
index b37efe8a1e5..ca6df0ff004 100644
--- a/ql/src/Security/CWE-643/XPathInjection.ql
+++ b/ql/src/Security/CWE-643/XPathInjection.ql
@@ -4,6 +4,7 @@
* malicious code by the user.
* @kind path-problem
* @problem.severity error
+ * @precision high
* @id go/xml/xpath-injection
* @tags security
* external/cwe/cwe-643