xpath-injection-anti-pattern

Detect XPath injection vulnerabilities in XML query construction.

8|1|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/igbuend/grimbard --skill xpath-injection-anti-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xpath-injection-anti-pattern
Source: https://github.com/igbuend/grimbard/tree/main/skills/xpath-injection-anti-pattern
Command: npx skills add https://github.com/igbuend/grimbard --skill xpath-injection-anti-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill protects against XPath injection, a critical vulnerability that arises when user input is improperly handled within XPath queries, potentially leading to unauthorized data access or system compromise.

Core Features & Use Cases

  • Vulnerability Detection: Identifies insecure construction of XPath queries using string concatenation or interpolation.
  • Secure Coding Guidance: Provides clear examples of how to use parameterized queries or proper input escaping to prevent injection.
  • Use Case: When reviewing code that processes XML data and constructs XPath queries based on user-provided values, this Skill will flag potential injection risks and offer secure alternatives.

Quick Start

Review the current folder for XPath injection vulnerabilities.

Frequently Asked Questions about xpath-injection-anti-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent XPath injection vulnerabilities when processing XML user input?

Prevent XPath injection by applying secure coding practices like parameterized queries or strict input escaping when constructing XPath queries against XML documents. This ensures secure data handling and prevents unauthorized access from malicious user-supplied values.

What is XPath injection and how does string concatenation cause it?

XPath injection is a vulnerability arising when user input is improperly handled via string concatenation or interpolation within XPath queries. This flawed construction allows attackers to manipulate query logic, potentially leading to unauthorized data access or system compromise.

How do I detect insecure XPath query construction during code review?

Detect insecure XPath query construction by reviewing code for string concatenation or interpolation that incorporates user-supplied input into XML query logic. Flagging these patterns identifies potential injection risks for subsequent remediation.

Does this XPath injection detection work for codebases using parameterized queries?

Yes, it analyzes codebases that process XML and incorporate user input into query logic. It validates adherence to secure coding practices, ensuring parameterized queries or proper input escaping are correctly implemented to prevent injection.

What is the best way to secure XML queries against user-supplied input?

The best way to secure XML queries is replacing string concatenation with parameterized queries or strict input escaping. This blocks malicious input from altering XPath query logic and prevents unauthorized data access.

Why should I use parameterization instead of input escaping for XPath queries?

Parameterization is preferred because it structurally separates query logic from user-supplied input, whereas escaping relies on correctly formatting every special character. Both prevent XPath injection, but parameterization offers stronger protection against unauthorized data access.