Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 1256

XPath Injection

What is XPath Injection?

XPath InjectionAn injection flaw in which untrusted input alters an XPath query against an XML document, allowing data exfiltration or authentication bypass.


XPath injection occurs when an application builds XPath queries against an XML document by string-concatenating user input, similarly to classic SQL injection. An attacker can break out of the intended expression with quotes, boolean tautologies like ' or '1'='1, or comments to extract arbitrary nodes, bypass login forms backed by XML user stores, or perform blind exfiltration through boolean and timing oracles. The flaw is most common in legacy SOAP services, configuration backends, and applications that store credentials in XML files. Defenses include parameterized XPath APIs (where available), strict input validation against an allow-list, and migrating sensitive lookups to safer data stores.

Examples

  1. 01

    Login query: //user[name/text()='admin' or '1'='1' and password/text()='x'] bypasses authentication.

  2. 02

    Blind XPath exfiltration via boolean conditions like substring(//secret,1,1)='a'.

Frequently asked questions

What is XPath Injection?

An injection flaw in which untrusted input alters an XPath query against an XML document, allowing data exfiltration or authentication bypass. It belongs to the Attacks & Threats category of cybersecurity.

What does XPath Injection mean?

An injection flaw in which untrusted input alters an XPath query against an XML document, allowing data exfiltration or authentication bypass.

How does XPath Injection work?

XPath injection occurs when an application builds XPath queries against an XML document by string-concatenating user input, similarly to classic SQL injection. An attacker can break out of the intended expression with quotes, boolean tautologies like ' or '1'='1, or comments to extract arbitrary nodes, bypass login forms backed by XML user stores, or perform blind exfiltration through boolean and timing oracles. The flaw is most common in legacy SOAP services, configuration backends, and applications that store credentials in XML files. Defenses include parameterized XPath APIs (where available), strict input validation against an allow-list, and migrating sensitive lookups to safer data stores.

How do you defend against XPath Injection?

Defences for XPath Injection typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for XPath Injection?

Common alternative names include: XPath query injection.

Related terms