Definition - What does XPath Injection mean?
XPath injection is an attack technique used in exploiting applications used for constructing XPath queries based on the user-provided inputs. It can be used directly by an application for querying an XML document, even as part of a larger process such as XSLT transformation to an XML document. Compared to SQL injections, XPath injections are more destructive, as XPath lacks access control and provides querying of complete databases. The complete querying of a SQL database is difficult, as metatables cannot be queried using regular queries.
Techopedia explains XPath Injection
XPath, being a standard language, has syntax independent of implementation. This makes the attack more automated in nature. An XPath injection attack works in a similar fashion as to SQL injection, with the website making use of user-provided information to construct the XPath query for the XML data. Malformed information is intentionally injected into the website, allowing the attacker to figure out the method in which the XML data is structured to get data access which otherwise would remain unauthorized. Attackers can then proceed to elevate the privileges they have on the website by manipulating the XML data authentication process. In other words, like SQL injection, the technique is to specify certain attributes and obtain the patterns that can be matched which then allow the attacker to bypass authentication or access information in an unauthorized manner. The biggest difference between XPath injection and SQL injection is that XPath injection makes use of XML files for data storage, while SQL makes use of a database.
XPath injection can be prevented with the help of defence techniques such as sanitizing user inputs or treating all user inputs as untrusted and performing necessary sanitization techniques or extensively testing applications that supply or make use of the user inputs.