CWE
Home > CWE List > CWE- Individual Dictionary Definition (1.1)  
Search by ID:

CWE-652: Failure to Sanitize Data within XQuery Expressions (aka 'XQuery Injection')

Individual Definition in a New Window
Failure to Sanitize Data within XQuery Expressions (aka 'XQuery Injection')
Status: Incomplete
Weakness ID: 652 (Weakness Base)
Description
Summary

The software uses external input to dynamically construct an XQuery expression used to retrieve data from an XML database, but it does not sufficiently sanitize that input. This allows an attacker to control the structure of the query.

Extended Description

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).

Likelihood of Exploit

High

Common Consequences

Controlling application flow (e.g. bypassing authentication)

Information Disclosure

Elevation of Privilege

Enabling Factors for Exploitation

XQL queries are constructed dynamically using user supplied input that has not been sufficiently validated.

Potential Mitigations

Use parameterized queries. This will help ensure separation between data plane and control plane.

Properly validate user input. Reject data where appropriate, filter where appropriate and escape where appropriate. Make sure input that will be used in XQL queries is safe in that context.

Observed Examples
Description
From CAPEC 84: An attacker can pass XQuery expressions embedded in otherwise standard XML documents. Like SQL injection attacks, the attacker tunnels through the application entry point to target the resource access layer. The string below is an example of an attacker accessing the accounts.xml to request the service provider send all user names back. doc(accounts.xml)//user[name='*'] The attacks that are possible through XQuery are difficult to predict, if the data is not validated prior to executing the XQL.
Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfWeakness BaseWeakness BaseWeakness Base91XML Injection (aka Blind XPath Injection)
Development Concepts (primary)699
Research Concepts (primary)1000
Relationship Notes

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.

Applicable Platforms
Languages
All
Time of Introduction
* Implementation
Content History
Modifications
CWE Content Team. MITRE. 2008-09-08. (Internal)
updated Common_Consequences, Relationships
CWE Content Team. MITRE. 2008-10-14. (Internal)
updated Description, Name, Relationship_Notes
Previous Entry Names
* Unsafe Treatment of XQuery Input (changed 2008-10-14)
Page Last Updated: November 24, 2008