LiveActive security incident?Get immediate response
CWE Reference

CWE-652: Improper Neutralization of Data within XQuery… | Glexia

CWE-652 (Improper Neutralization of Data within XQuery Expressions) weakness overview with consequences, detection methods, mitigations, related CVEs and MITRE…

Release 4.21weaknessIncomplete

Glexia's Take · Automated analysis

CWE-652: XQuery Injection

Improper Neutralization of Data within XQuery Expressions represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.

Executive Impact

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

Developer Pattern

CWE-652 is the kind of defect developers can usually prevent with explicit validation, safer framework defaults, and tests that exercise hostile input or unsafe state transitions.

Automation confidence

high confidence from CWE-652, 4.21.

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Official CWE Definition

CWE-652: Improper Neutralization of Data within XQuery Expressions

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. (Roles: Common-Name, Attack-Focused)

Type
weakness
Abstraction
Base
Status
Incomplete
Source
MITRE CWE definition

Developer And Remediation Guidance

How teams prevent and detect this weakness

Causes

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

Remediation

  • 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

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

Mappings

Related CVEs, CWEs, and ATT&CK context

Related CWEs

Related CVEs

Related CVE mappings appear after CVE records are cross-indexed.

Open CWE CVE mapping

ATT&CK Relevance

ATT&CK relevance is shown only when reviewed or responsibly inferred.