This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

Difference between revisions of "XPATH Injection"

From OWASP
Jump to: navigation, search
(Description)
(Examples)
Line 7: Line 7:
  
 
==Examples ==
 
==Examples ==
 +
 +
We'll use this xml snippet for the examples.
 +
 +
<pre>
 +
&lt;?xml version="1.0" encoding="utf-8"?&gt;
 +
&lt;Employees&gt;
 +
  &lt;Employee ID="1"&gt;
 +
      &lt;FirstName&gt;Arnold&lt;/FirstName&gt;
 +
      &lt;LastName&gt;Baker&lt;/LastName&gt;
 +
      &lt;UserName&gt;ABaker&lt;/UserName&gt;
 +
      &lt;Password&gt;SoSecret&lt;/Password&gt;
 +
      &lt;Type&gt;Admin&lt;/Type&gt;
 +
  &lt;/Employee&gt;
 +
  &lt;Employee ID="2"&gt;
 +
      &lt;FirstName&gt;Peter&lt;/FirstName&gt;
 +
      &lt;LastName&gt;Pan&lt;/LastName&gt;
 +
      &lt;UserName&gt;PPan&lt;/UserName&gt;
 +
      &lt;Password&gt;NotTelling&lt;/Password&gt;
 +
      &lt;Type&gt;User&lt;/Type&gt;
 +
  &lt;/Employee&gt;
 +
&lt;/Employees&gt;
 +
</pre>
  
 
==Related Threats==
 
==Related Threats==

Revision as of 01:39, 2 September 2006

This is an Attack. To view all attacks, please see the Attack Category page.


Description

Similar to SQL Injection, XML Injection attacks occur when a web site uses user supplied information to query XML data. By sending intentionally malformed information into the web site, an attacker can find out how the XML data is structured or access data that they may not normally have access to. They may even be able to elevate their privileges on the web site if the xml data is being used for authentication (such as an xml based user file).

Querying XML is done with XPath, a type of simple descriptive statement that allows the xml query to locate a piece of information. Like SQL you can specify certain attributes to find and patterns to match. When using XML for a web site it is common to accept some form of input on the query string to identify the content to locate and display on the page. This input must be sanitized to verify that it doesn't mess up the XPath query and return the wrong data.

Examples

We'll use this xml snippet for the examples.

<?xml version="1.0" encoding="utf-8"?>
<Employees>
   <Employee ID="1">
      <FirstName>Arnold</FirstName>
      <LastName>Baker</LastName>
      <UserName>ABaker</UserName>
      <Password>SoSecret</Password>
      <Type>Admin</Type>
   </Employee>
   <Employee ID="2">
      <FirstName>Peter</FirstName>
      <LastName>Pan</LastName>
      <UserName>PPan</UserName>
      <Password>NotTelling</Password>
      <Type>User</Type>
   </Employee>
</Employees>

Related Threats

Related Attacks

Related Vulnerabilities

Related Countermeasures

Categories

This article is a stub. You can help OWASP by expanding it or discussing it on its Talk page.