Professional skills and methodology for XPath injection vulnerability testing
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Professional skills and methodology for XPath injection vulnerability testing
XPath Injection Vulnerability Testing
AI LOAD INSTRUCTION: XPath injection testing for applications that construct XPath queries from user input. Covers error-based extraction, authentication bypass (tautology, union via ]//*), blind boolean extraction via substring(), and XQuery-specific techniques. XPath injection differs from SQL injection: no sleep/time-based blind (use boolean only), different syntax, and XML document structure matters. Targets include login forms, search fields, and XML-based API endpoints.
Overview
XPath injection is a vulnerability similar to SQL injection that exploits flaws in XPath query construction, potentially leading to information disclosure and authentication bypass. This skill provides detection, exploitation, and remediation methods for XPath injection.
Vulnerability Mechanism
Applications concatenate user input directly into XPath query strings without sufficient validation or filtering, allowing attackers to modify query logic.
// Use XPath variablesStringxpath="//user[username=$username and password=$password]";
XPathExpressionexpr= xpath.compile(xpath);
XPathVariableResolverresolver=newMapVariableResolver(
Map.of("username", escapedUsername, "password", escapedPassword));
expr.setXPathVariableResolver(resolver);
Whitelist validation
// Only allow specific charactersif (!input.matches("^[a-zA-Z0-9@._-]+$")) {
thrownewIllegalArgumentException("Invalid input");
}
Pre-compiled queries
// Predefined query templatesprivatestaticfinalStringLOGIN_QUERY="//user[username=$1 and password=$2]";
// Use parameter binding
Least privilege
Limit XPath query scope
Use access controls
Restrict queryable nodes
Notes
Only test in authorized environments
Be aware of syntax differences between XPath versions
Avoid modifying XML data during testing
Understand the target application's XPath implementation
DECISION TREE
XPath query found in application (login, search, XML API)?
├── Single-quote (') causes error or behavior change?
│ ├── Error message reveals XPath/XML structure?
│ │ └── Error-based extraction: use malformed XPath to extract data
│ ├── No error but response differs from baseline?
│ │ └── Boolean-based blind: use substring() to extract character by character
│ └── Auth bypass possible (login form)?
│ ├── Logical bypass works: ' or '1'='1?
│ │ └── Confirm authentication is bypassed
│ └── Comment-based bypass: admin')] | //* | //*[('?
│ └── Confirm data extraction via union
├── No error or behavior change with single-quote?
│ └── Try encoding bypass: URL-encode, HTML-entity encode
│ └── Any response difference now?
│ └── Proceed with blind boolean extraction
├── Backend may use XQuery instead of XPath 1.0?
│ └── Test XQuery-specific syntax and functions
└── No injection found?
└── Report not reproduced; verify XPath sink and input flow
TESTING CHECKLIST
Identify all user-controlled inputs that feed into XPath queries (login forms, search fields, XML API endpoints)
Test basic XPath injection with single-quote (') and observe error responses or behavior changes
Test error-based extraction: inject malformed XPath (' or 1=1 or ', ') or ('1'='1) and check for XML/XPath error messages
Test authentication bypass: admin' or '1'='1, admin') or ('1'='1 in login fields
Test boolean-based blind extraction: ' or substring(//user[1]/username,1,1)='a' or ' — compare positive vs negative responses
Test node enumeration: ' or count(//user)>0 or ', ' or 1=1 or '
Test character-by-character data extraction via substring() across username, password, and other sensitive nodes
Test XQuery-specific syntax if the backend may use XQuery instead of XPath 1.0
Test encoding bypasses: URL-encode payloads (%27%20or%20%271%27%3D%271), HTML-entity encode special characters
Verify with parameterized queries or input escaping to confirm the fix
MCP TOOLS
Tool
Use Case
http_framework_test
Send crafted HTTP requests with XPath injection payloads (' or '1'='1, `admin')]
http_repeater
Replay and modify XPath injection payloads to test authentication bypass, boolean-based blind extraction, and node enumeration across different input points
nuclei_scan
Run XPath-injection-specific Nuclei templates to automate detection of XPath injection vulnerabilities in XML-based API endpoints
api_fuzzer
Fuzz API parameters with XPath injection strings to discover XML query sinks where user input reaches XPath expressions
RELATED ROUTING
ldap-injection — LDAP injection shares the same query-manipulation patterns as XPath injection
sqli — SQL injection is the relational analogue; boolean-blind and auth-bypass techniques transfer
xxe — both target XML-processing pipelines in the application
authentication-bypass — XPath tautology bypass (' or '1'='1) is a core auth bypass method