---
title: "CWE-652: Improper Neutralization of Data within XQuery Expressions"
url: https://radicalnotion.ai/cwe/cwe-652
type: cwe
description: "The product uses external input to dynamically construct an XQuery expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-652: Improper Neutralization of Data within XQuery Expressions

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 2
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The product uses external input to dynamically construct an XQuery expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input.

## Alternate terms

- XQuery Injection

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality | Read Application Data | An attacker could modify the structure of the query to control what information is selected by the XML database, then use that ability to control application flow, modify logic, retrieve unauthorized data, or bypass important checks (e.g. authentication). |

## Potential mitigations

### Implementation

Use parameterized queries. 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 XQL queries is safe in that context.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

An attacker may pass XQuery expressions embedded in an otherwise standard XML document. 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.

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-28676 | Jenkins Convert To Pipeline Plugin vulnerable to cross-site request forgery | high | 8.8 | - | No | 2023-03-23 |
| CVE-2023-25015 | Clockwork Web contains a Cross-Site Request Forgery Vulnerability with Rails \< 5.2 | medium | 6.5 | - | No | 2023-02-02 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-91](https://radicalnotion.ai/cwe/cwe-91) | XML Injection |
| Parent | [CWE-943](https://radicalnotion.ai/cwe/cwe-943) | Improper Neutralization of Special Elements in Data Query Logic |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| WASC | XQuery Injection | 46 | - |
| Software Fault Patterns | Tainted input to command | SFP24 | - |

## Frequently asked questions

### What is CWE-652?

The product uses external input to dynamically construct an XQuery expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input.

### What CVEs are caused by CWE-652?

2 recorded CVEs are attributed to CWE-652, including CVE-2023-28676 and CVE-2023-25015.

### How do you prevent CWE-652?

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

### How is CWE-652 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-652?

Exploiting CWE-652 can lead to: Read Application Data.

### Is CWE-652 actively exploited?

2 recorded CVEs are caused by CWE-652; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/652.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-652). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
