Executing XPATH expressions is security-sensitive. It has led in the past to the following vulnerabilities: * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6272[CVE-2016-6272] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-9149[CVE-2016-9149] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-4837[CVE-2012-4837] User-provided data such as URL parameters should always be considered as untrusted and tainted. Constructing XPath expressions directly from tainted data enables attackers to inject specially crafted values that changes the initial meaning of the expression itself. Successful XPath injections attacks can read sensitive information from the XML document. This rule will create issues when the following methods are called: * ``++System.Xml.XmlNode.SelectNodes(string)++`` * ``++System.Xml.XmlNode.SelectNodes(string, System.Xml.XmlNamespaceManager)++`` * ``++System.Xml.XmlNode.SelectSingleNode(string)++`` * ``++System.Xml.XmlNode.SelectSingleNode(string, System.Xml.XmlNamespaceManager)++`` * ``++System.Xml.XPath.XPathNavigator.Compile(string)++`` * ``++System.Xml.XPath.XPathNavigator.Evaluate(string)++`` * ``++System.Xml.XPath.XPathNavigator.Evaluate(string, System.Xml.IXmlNamespaceResolver)++`` * ``++System.Xml.XPath.XPathNavigator.Matches(string)++`` * ``++System.Xml.XPath.XPathNavigator.Select(string)++`` * ``++System.Xml.XPath.XPathNavigator.Select(string, System.Xml.IXmlNamespaceResolver)++`` * ``++System.Xml.XPath.XPathNavigator.SelectSingleNode(string)++`` * ``++System.Xml.XPath.XPathNavigator.SelectSingleNode(string, System.Xml.IXmlNamespaceResolver)++`` * ``++System.Xml.XPath.XPathExpression.Compile(string)++`` * ``++System.Xml.XPath.XPathExpression.Compile(string, System.Xml.IXmlNamespaceResolver)++`` include::../ask-yourself.adoc[] include::../recommended.adoc[] == Sensitive Code Example ---- Dim expression As String = "/users/user[@name='" + user + "' and @pass='" + pass + "']" xpathNavigator.Evaluate(expression); ' Sensitive. Check if the XPATH expression is safe. ---- include::../see.adoc[] ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] ''' == Comments And Links (visible only on this page) include::../comments-and-links.adoc[] endif::env-github,rspecator-view[]