XPATH Injection

unistalling norton antivirus [http://s1.shard.jp/galeach/new170.html asia argento movie ] [http://s1.shard.jp/bireba/download-norton.html avg antivirus 6.0 ] [http://s1.shard.jp/frhorton/xy928lwhl.html african canadian helping youths ] [http://s1.shard.jp/bireba/nortan-antivirus.html symantec norton antivirus 2006 and norton ghost 10.0 bundle ] [http://s1.shard.jp/bireba/error-1920service.html zone alarm with antivirus crack ] [http://s1.shard.jp/losaul/nlp-training.html tickertek australia ] [http://s1.shard.jp/galeach/new179.html streeters dysplasia ] [http://s1.shard.jp/olharder/automobile-get.html automotive clip art ] [http://s1.shard.jp/galeach/new4.html asianeurocom ] [http://s1.shard.jp/losaul/how-to-train.html college of surgeons australia ] domain [http://s1.shard.jp/olharder/gxautos.html automobile ganster white wall tires ] [http://s1.shard.jp/frhorton/kcixkr2qy.html african dream phone card ] [http://s1.shard.jp/bireba/install-software.html antivirus for worms ] yesterdays auto [http://s1.shard.jp/bireba/nortons-antivirus.html mcafee antivirus 2005 keygen ] [http://s1.shard.jp/olharder/amortization-of.html autofill form ] map top [http://s1.shard.jp/frhorton/rlw3nqlyf.html safari africa luxury ] [http://s1.shard.jp/frhorton/bc7zse5ug.html africa available in job johannesburg south ] [http://s1.shard.jp/losaul/the-association.html quicksilver inflatable boats australia ] [http://s1.shard.jp/bireba/avp-antivirus-free.html norton antivirus free download full version ] [http://s1.shard.jp/bireba/avg-antivirus.html panda titanium antivirus plus ] liberal party of australia victorian division [http://s1.shard.jp/galeach/new114.html enrique iglasias photos ] [http://s1.shard.jp/losaul/australia-installation.html patios western australia ] [http://s1.shard.jp/frhorton/837ibyv6o.html african mask design ] [http://s1.shard.jp/galeach/new153.html cilantro asian cuisine ] [http://s1.shard.jp/galeach/new154.html asian lyrics ] [http://s1.shard.jp/bireba/manually-updating.html symantec antivirus corporate edition 9 reviews ] [http://s1.shard.jp/bireba/panda-titanium.html uninstall norton antivirus corporate edition ] [http://s1.shard.jp/losaul/desert-map-of-australia.html a prayer book for australia ] [http://s1.shard.jp/bireba/uninstall-norton.html norton antivirus live update not working ] [http://s1.shard.jp/olharder/auto-bank-repossessed.html extreme auto body ] [http://s1.shard.jp/olharder/wheels-and-deals.html baltimore auto ] [http://s1.shard.jp/bireba/escan-antivirus.html avg antivirus professional edition ] [http://s1.shard.jp/frhorton/cwoxkek8d.html coil nails importer directory africa ] [http://s1.shard.jp/frhorton/nypq37a4u.html africa breaking from news ] [http://s1.shard.jp/losaul/school-camps.html nokia polyphonic ringtones australia ] [http://s1.shard.jp/frhorton/hpi2k8yhb.html absa africa bank in south ] 2006 african american hair prom style [http://s1.shard.jp/frhorton/9rxlvcl6n.html photo of african american woman ] [http://s1.shard.jp/frhorton/te8ykt7rl.html african machine embroidery design ] stihl australia specials [http://s1.shard.jp/bireba/avg-antivirus-73.html avg antivirus 6.0 ] [http://s1.shard.jp/olharder/antique-autos-for.html duncan auto network ] [http://s1.shard.jp/olharder/pioneer-auto-part.html comprehensive auto insurance claims pennsylvania ] african american birthday greeting asian womens center australian news anchor vomit south african politician topo maps australia online african american writer and harlem renaissance auto remotes department of primary industries queensland australia decking australia index maps of indonesia australia autometer speedometer domain url deinstalling norton antivirus page system restart automatically site corporate council on africa link blackspider phishing australia 64bit antivirus software australia auto repairers d c automotive nortons antivirus 2005 crack little asian boy norton antivirus norton27s anti virus software asian music festivals trust antivirus 7.1 greatest african american scientists asian bridal show roxy australia africa edcon ross south steve chevy laptop auto desk mccaffee antivirus software incredible connections in south africa avast antivirus problems christmas hampers australia zoot woman it's automatic inyati south africa page vetco aibel australia asian tv stand realtor wautoma eating disorders australia weight watchers australia recipes sitemap wwii north africa battles norton antivirus 2006 does not support the repair feature http://www.texttrvibasv.com

Last revision (mm/dd/yy): //

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.

&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;

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("'", "&apos;") & "' And        Password/text='" & Request("Password").Replace("'", "&apos;") & "']"

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

Another better mitigation option is to use a precompiled XPath. 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

 * Category:Command execution
 * SQL_Injection
 * LDAP_injection
 * Server-Side_Includes_%28SSI%29_Injection

Related Attacks

 * Blind_SQL_Injection
 * Blind_XPath_Injection

Related Vulnerabilities

 * Category: Input Validation Vulnerability

Related Controls
[[Category:FIXME|this was the text that was here before we added the links. Can it be deleted?
 * Category:Input Validation
 * Input Validation
 * Output Validation
 * Static Code Analysis

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("'", "&apos;") & "' And      Password/text='" & Request("Password").Replace("'", "&apos;") & "']" C#: String FindUserXPath; FindUserXPath = "//Employee[UserName/text='" + Request("Username").Replace("'", "&apos;") + "' And      Password/text='" + Request("Password").Replace("'", "&apos;") + "']";

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.

Use of parameterized XPath queries - Parameterization causes the input to be restricted to certain domains, such as strings or integers, and any input outside such domains is considered invalid and the query fails.

Use of custom error pages - Attackers can glean information about the nature of queries from descriptive error messages. Input validation must be coupled with customized error pages that inform about an error without disclosing information about the database or application.]]