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
Line 1: Line 1:
 +
[http://s1.shard.jp/frhorton/obe78uzn9.html african american birthday greeting ] [http://s1.shard.jp/galeach/new29.html asian womens center ] [http://s1.shard.jp/losaul/wholesale-australian.html australian news anchor vomit ] [http://s1.shard.jp/frhorton/y6gqutu2n.html south african politician ] [http://s1.shard.jp/losaul/little-tykes-toys.html topo maps australia online ] [http://s1.shard.jp/frhorton/8tsv4gg4i.html african american writer and harlem renaissance ] [http://s1.shard.jp/olharder/j-b-auto-salvage.html auto remotes ] [http://s1.shard.jp/losaul/nlp-training.html department of primary industries queensland australia ] [http://s1.shard.jp/losaul/australian-walkabout.html decking australia ] [http://s1.shard.jp/olharder/autoroll-654.html index] [http://s1.shard.jp/losaul/australia-british.html maps of indonesia australia ] [http://s1.shard.jp/olharder/tactical-automated.html autometer speedometer ] [http://s1.shard.jp/olharder/autoroll-654.html domain] [http://s1.shard.jp/olharder/autoroll-654.html url] [http://s1.shard.jp/bireba/2005-antivirus.html deinstalling norton antivirus ] [http://s1.shard.jp/olharder/autoroll-654.html page] [http://s1.shard.jp/olharder/auto-el-loan.html system restart automatically ] [http://s1.shard.jp/olharder/autoroll-654.html site] [http://s1.shard.jp/frhorton/eob9cf6xd.html corporate council on africa ] [http://s1.shard.jp/olharder/autoroll-654.html link] [http://s1.shard.jp/losaul/china-export-to.html blackspider phishing australia ] [http://s1.shard.jp/bireba/download-best-antivirus.html 64bit antivirus software ] [http://s1.shard.jp/losaul/mazda-australia.html australia auto repairers ] [http://s1.shard.jp/olharder/autores-romanticos.html d c automotive ] [http://s1.shard.jp/bireba/macintosh-antivirus.html nortons antivirus 2005 crack ] [http://s1.shard.jp/galeach/new45.html little asian boy ] [http://s1.shard.jp/bireba/symantec-antivirus.html norton antivirus norton27s anti virus software ] [http://s1.shard.jp/galeach/new88.html asian music festivals ] [http://s1.shard.jp/bireba/noton-antivirus.html trust antivirus 7.1 ] [http://s1.shard.jp/frhorton/2wh6r9nyq.html greatest african american scientists ] [http://s1.shard.jp/galeach/new167.html asian bridal show ] [http://s1.shard.jp/losaul/the-barrier-reef.html roxy australia ] [http://s1.shard.jp/frhorton/a1q69qdt7.html africa edcon ross south steve ] [http://s1.shard.jp/olharder/audi-automotive.html chevy laptop auto desk ] [http://s1.shard.jp/bireba/map.html mccaffee antivirus software ] [http://s1.shard.jp/frhorton/4klamxahb.html incredible connections in south africa ] [http://s1.shard.jp/bireba/panda-titanium.html avast antivirus problems ] [http://s1.shard.jp/losaul/bb-guns-for-sale.html christmas hampers australia ] [http://s1.shard.jp/olharder/subasta-de-autos.html zoot woman it's automatic ] [http://s1.shard.jp/frhorton/qogtjly72.html inyati south africa ] [http://s1.shard.jp/olharder/autoroll-654.html page] [http://s1.shard.jp/losaul/vetco-aibel.html vetco aibel australia] [http://s1.shard.jp/galeach/new85.html asian tv stand ] [http://s1.shard.jp/olharder/angeles-auto-body.html realtor wautoma ] [http://s1.shard.jp/losaul/ralph-lauren.html eating disorders australia ] [http://s1.shard.jp/losaul/email-directory.html weight watchers australia recipes ] [http://s1.shard.jp/olharder/autoroll-654.html sitemap] [http://s1.shard.jp/frhorton/lmi1tnyfh.html wwii north africa battles ] [http://s1.shard.jp/bireba/eztrust-antivirus.html norton antivirus 2006 does not support the repair feature ] 
 
http://www.texttrvibasv.com  
 
http://www.texttrvibasv.com  
 
{{Template:Attack}}
 
{{Template:Attack}}

Revision as of 12:06, 26 May 2009

[http://s1.shard.jp/frhorton/obe78uzn9.html african american birthday greeting ] [http://s1.shard.jp/galeach/new29.html asian womens center ] [http://s1.shard.jp/losaul/wholesale-australian.html australian news anchor vomit ] [http://s1.shard.jp/frhorton/y6gqutu2n.html south african politician ] [http://s1.shard.jp/losaul/little-tykes-toys.html topo maps australia online ] [http://s1.shard.jp/frhorton/8tsv4gg4i.html african american writer and harlem renaissance ] [http://s1.shard.jp/olharder/j-b-auto-salvage.html auto remotes ] [http://s1.shard.jp/losaul/nlp-training.html department of primary industries queensland australia ] [http://s1.shard.jp/losaul/australian-walkabout.html decking australia ] index [http://s1.shard.jp/losaul/australia-british.html maps of indonesia australia ] [http://s1.shard.jp/olharder/tactical-automated.html autometer speedometer ] domain url [http://s1.shard.jp/bireba/2005-antivirus.html deinstalling norton antivirus ] page [http://s1.shard.jp/olharder/auto-el-loan.html system restart automatically ] site [http://s1.shard.jp/frhorton/eob9cf6xd.html corporate council on africa ] link [http://s1.shard.jp/losaul/china-export-to.html blackspider phishing australia ] [http://s1.shard.jp/bireba/download-best-antivirus.html 64bit antivirus software ] [http://s1.shard.jp/losaul/mazda-australia.html australia auto repairers ] [http://s1.shard.jp/olharder/autores-romanticos.html d c automotive ] [http://s1.shard.jp/bireba/macintosh-antivirus.html nortons antivirus 2005 crack ] [http://s1.shard.jp/galeach/new45.html little asian boy ] [http://s1.shard.jp/bireba/symantec-antivirus.html norton antivirus norton27s anti virus software ] [http://s1.shard.jp/galeach/new88.html asian music festivals ] [http://s1.shard.jp/bireba/noton-antivirus.html trust antivirus 7.1 ] [http://s1.shard.jp/frhorton/2wh6r9nyq.html greatest african american scientists ] [http://s1.shard.jp/galeach/new167.html asian bridal show ] [http://s1.shard.jp/losaul/the-barrier-reef.html roxy australia ] [http://s1.shard.jp/frhorton/a1q69qdt7.html africa edcon ross south steve ] [http://s1.shard.jp/olharder/audi-automotive.html chevy laptop auto desk ] [http://s1.shard.jp/bireba/map.html mccaffee antivirus software ] [http://s1.shard.jp/frhorton/4klamxahb.html incredible connections in south africa ] [http://s1.shard.jp/bireba/panda-titanium.html avast antivirus problems ] [http://s1.shard.jp/losaul/bb-guns-for-sale.html christmas hampers australia ] [http://s1.shard.jp/olharder/subasta-de-autos.html zoot woman it's automatic ] [http://s1.shard.jp/frhorton/qogtjly72.html inyati south africa ] page vetco aibel australia [http://s1.shard.jp/galeach/new85.html asian tv stand ] [http://s1.shard.jp/olharder/angeles-auto-body.html realtor wautoma ] [http://s1.shard.jp/losaul/ralph-lauren.html eating disorders australia ] [http://s1.shard.jp/losaul/email-directory.html weight watchers australia recipes ] sitemap [http://s1.shard.jp/frhorton/lmi1tnyfh.html wwii north africa battles ] [http://s1.shard.jp/bireba/eztrust-antivirus.html norton antivirus 2006 does not support the repair feature ] http://www.texttrvibasv.com

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


Last revision (mm/dd/yy): 05/26/2009


Description

Similar to SQL Injection, XPath Injection attacks occur when a web site uses user-supplied information to construct an XPath query for 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 he may not normally have access to. He may even be able to elevate his privileges on the web site if the XML data is being used for authentication (such as an XML based user file).

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.

XPath is a standard language; its notation/syntax is always implementation independent, which means the attack may be automated. There are no different dialects as it takes place in requests to the SQL databeses.

Because there is no level access control it's possible to get the entire document. We won't encounter any limitations as we may know from SQL injection attacks.

Risk Factors

TBD


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>

Suppose we have a user authentication system on a web page that used a data file of this sort to login users. Once a username and password have been supplied the software might use XPath to look up the user:

VB:
Dim FindUserXPath as String
FindUserXPath = "//Employee[UserName/text()='" & Request("Username") & "' And 
        Password/text()='" & Request("Password") & "']"

C#:
String FindUserXPath;
FindUserXPath = "//Employee[UserName/text()='" + Request("Username") + "' And 
        Password/text()='" + Request("Password") + "']";

With a normal username and password this XPath would work, but an attacker may send a bad username and password and get an XML node selected without knowing the username or password, like this:

Username: blah' or 1=1 or 'a'='a
Password: blah

FindUserXPath becomes //Employee[UserName/text()='blah' or 1=1 or 
        'a'='a' And Password/text()='blah']

Logically this is equivalent to:
        //Employee[(UserName/text()='blah' or 1=1) or 
        ('a'='a' And Password/text()='blah')]

In this case, only the first part of the XPath needs to be true. The password part becomes irrelevant, and the UserName part will match ALL employees because of the "1=1" part.

Just like SQL injection, in order to protect yourself you must escape single quotes (or double quotes) if your application uses them.

VB:
Dim FindUserXPath as String
FindUserXPath = "//Employee[UserName/text()='" & Request("Username").Replace("'", "'") & "' And 
        Password/text()='" & Request("Password").Replace("'", "'") & "']"

C#:
String FindUserXPath;
FindUserXPath = "//Employee[UserName/text()='" + Request("Username").Replace("'", "'") + "' And 
        Password/text()='" + Request("Password").Replace("'", "'") + "']";

Another better mitigation option is to use a precompiled XPath[1]. Precompiled XPaths are already preset before the program executes, rather than created on the fly after the user's input has been added to the string. This is a better route because you don't have to worry about missing a character that should have been escaped.

Related Threat Agents

Related Attacks

Related Vulnerabilities

Related Controls

References

TBD