Learn how to manipulate XML queries to extract data, bypass authentication, and access restricted information.
XPath is a query language for selecting nodes in XML documents. It's used by many applications to query configuration files, user databases stored as XML, and structured data. XPath Injection occurs when user input is directly concatenated into XPath queries without sanitization.
Common in: Legacy systems, configuration parsing, educational platforms, some APIs.
XPath queries select nodes from an XML document:
This selects all <user> nodes where both conditions are true. Parts:
When apps build XPath queries with user input:
An attacker can inject XPath syntax by providing: ' or '1'='1
The condition '1'='1' is always true, returning the first matching node (usually admin).
Demo: Examine XML structure and understand XPath query format with hints
Lab 1 - Login Bypass: Use boolean injection to authenticate without password
Lab 2 - Secret Extraction: Extract hidden admin secrets without using 'admin' account
Lab 3 - Restricted Predicate Bypass: Bypass additional security restrictions via predicate manipulation