cwe-643-xpath-injection

Remediate CWE-643 XPath Injection vulnerabilities in Java code using secure XPath variable resolution.

3|1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-643-xpath-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cwe-643-xpath-injection
Source: https://github.com/DevelopersCoffee/java-cwe-security-skills/tree/main/cwe-643-xpath-injection
Command: npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-643-xpath-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses and remediates XPath Injection vulnerabilities in Java applications, ensuring that user input cannot manipulate XPath queries to access or modify unintended data.

Core Features & Use Cases

  • Vulnerability Remediation: Provides deterministic fixes for CWE-643.
  • Secure Coding Practices: Guides developers on using parameterized queries with XPath variables.
  • Use Case: When a SAST tool flags a potential XPath Injection vulnerability in a Java web application's user authentication module, this skill can be applied to automatically refactor the vulnerable code into a secure implementation.

Quick Start

Use the cwe-643-xpath-injection skill to remediate the XPath Injection vulnerability in the provided Java code snippet.

Frequently Asked Questions about cwe-643-xpath-injection

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

FAQPage Schema
How do I prevent XPath injection vulnerabilities in Java applications processing XML data?

You prevent XPath injection in Java by implementing secure XPath variable resolution and using parameterized queries instead of concatenating user input directly into XPath expressions. This ensures user input cannot manipulate queries to access unintended data.

What is the best way to remediate CWE-643 XPath injection flagged by a SAST tool in Java code?

The best way to remediate CWE-643 XPath injection is to automatically refactor the vulnerable Java code to use secure XPath variables and parameterized queries, replacing unsafe string concatenation with deterministic, secure XML processing practices.

How does XPath variable resolution protect against XPath injection in Java?

XPath variable resolution protects against XPath injection by separating user input from the XPath query structure. By binding user input as variables rather than inserting it directly into the query string, the input is treated strictly as data, preventing query manipulation.

Can I use secure XPath parameterized queries for user authentication modules in Java web applications?

Yes, you can use secure XPath parameterized queries in Java web application authentication modules. This approach refactors vulnerable code that incorporates user input into XPath queries, ensuring user credentials cannot manipulate the authentication query logic.

What are the limitations of automatic XPath injection remediation in Java XML processing?

Automatic XPath injection remediation requires adherence to secure coding practices for XML processing and input validation. It applies specifically to Java applications processing XML data where user input is incorporated into XPath queries, limiting its scope to this environment.