CWE-643 · Słabość
Improper Neutralization of Data within XPath Expressions ('XPath Injection')
- Abstrakcja
- Bazowa
- Status
- Niekompletny
- Ryzyko wykorzystania
- wysokie
- Dodano
- 30 stycznia 2008
- Ostatnia zmiana
- 11 grudnia 2025
Opis
The product uses external input to dynamically construct an XPath expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input. This allows an attacker to control the structure of the query.
The net effect is that the attacker will have control over the information selected from the XML database and may use that ability to control application flow, modify logic, retrieve unauthorized data, or bypass important checks (e.g. authentication).
Skutki
Access Control
Bypass Protection Mechanism
Controlling application flow (e.g. bypassing authentication).
Confidentiality
Read Application Data
The attacker could read restricted XML content.
Zapobieganie
Implementation
Use parameterized XPath queries (e.g. using XQuery). This will help ensure separation between data plane and control plane.
Implementation
Properly validate user input. Reject data where appropriate, filter where appropriate and escape where appropriate. Make sure input that will be used in XPath queries is safe in that context.
Słabość nadrzędna
Kiedy powstaje
- Implementation — REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Dotyczy
Not Language-Specific
Uwagi
This weakness is similar to other weaknesses that enable injection style attacks, such as SQL injection, command injection and LDAP injection. The main difference is that the target of attack here is the XML database.
Źródła
- XPath Injection — Web Application Security Consortium
- The Art of Software Security Assessment — Mark Dowd, John McDonald, Justin Schuh, Chapter 17, "XPath Injection", Page 1070, Addison Wesley, 2006
Wpis z katalogu CWE 4.20.