CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2025-32969
9.826.18%

XWiki REST API Unauthenticated SQL Injection via HQL Bypass

Amit Schendel
Amit Schendel
Senior Security Researcher

Mar 1, 2026·6 min read·30 visits

PoC Available

Executive Summary (TL;DR)

Unauthenticated attackers can execute arbitrary SQL on XWiki instances by sending crafted HQL queries to the REST API. This bypasses security filters, allowing full database access.

A critical SQL injection vulnerability exists in the XWiki Platform REST API, specifically within the query endpoint handling. The flaw allows unauthenticated remote attackers to bypass Hibernate Query Language (HQL) safety checks using crafted 'short-form' queries. By manipulating input verification logic, attackers can escape the HQL context and execute arbitrary SQL commands against the underlying database, leading to potential data exfiltration, modification, or denial of service.

Vulnerability Overview

CVE-2025-32969 is a critical SQL injection vulnerability affecting the XWiki Platform, a generic wiki platform written in Java. The vulnerability resides in the REST API component, specifically at the /rest/wikis/{wiki}/query endpoint. This endpoint allows users to perform searches using languages like Hibernate Query Language (HQL) or XWiki Query Language (XWQL). Ideally, these languages are abstractions that prevent direct SQL manipulation. However, the implementation failed to correctly sanitize specific 'short-form' HQL queries—queries that omit the SELECT clause and start directly with WHERE or ORDER BY.

Due to improper validation logic in the HqlQueryExecutor, an unauthenticated attacker can supply a malicious payload that the system interprets as a safe HQL fragment. In reality, the payload contains escape sequences that break out of the HQL parser's intended context. Once the query is translated to native SQL by the Hibernate engine, the injected SQL commands are executed by the database. This effectively grants the attacker direct interaction with the database management system (DBMS) with the privileges of the XWiki database user.

The vulnerability is rated Critical (CVSS 9.8) because it requires no authentication, can be exploited remotely over the network, and requires no user interaction. It affects a wide range of XWiki versions, from 1.8 up to recent releases in the 15.x and 16.x branches.

Root Cause Analysis

The root cause of this vulnerability is twofold: a logic error in query sanitization and the usage of an insecure query manager in the REST API context.

First, the HqlQueryExecutor.isSafeSelect method is responsible for ensuring that user-provided HQL does not contain dangerous constructs before execution. XWiki supports 'short-form' queries (e.g., where doc.name like 'A%'), which the system automatically expands into a full select statement. The vulnerability arose because the validation logic did not fully normalize these short-form queries before checking them. Attackers discovered that by using specific character sequences—such as combining backslashes with single quotes (1<>'1\')—they could confuse the HQL parser. The parser would interpret the input as a safe string literal, while the underlying SQL driver would interpret the escape characters differently, allowing the attacker to close the string and append raw SQL commands (e.g., UNION SELECT).

Second, the AbstractDatabaseSearchSource component, which handles REST API search requests, was injecting a generic QueryManager rather than the explicitly secured variant. The standard QueryManager does not automatically apply the rigorous authorization filters and context-aware checks required for public-facing endpoints. This architectural oversight meant that even if the HQL injection was difficult, the authorization boundaries were weaker than intended, facilitating the bypass of wiki-specific security policies.

Code Analysis

The remediation for CVE-2025-32969 involved hardening the query executor and enforcing the use of secure components. The fix was applied in commit 5c11a874bd24a581f534d283186e209bbccd8113.

1. Enforcing Secure Query Manager In AbstractDatabaseSearchSource.java, the dependency injection was updated to explicitly request the secure QueryManager. This ensures that all queries processed through this source are subject to stricter security constraints by default.

// Vulnerable Code
@Inject
private QueryManager queryManager;
 
// Fixed Code
@Inject
@Named("secure") // Explicitly use the secure implementation
private QueryManager queryManager;

2. Normalizing Short-Form Queries The most critical fix occurred in HqlQueryExecutor.java. The updated code ensures that any query identified as a short-form statement is fully normalized (expanded into a complete SELECT statement) before it is passed to the safety validator. This prevents the validator from analyzing a partial fragment that looks safe but becomes dangerous upon expansion.

// Logic pseudo-code for the fix in HqlQueryExecutor
public void checkAllowed(Query query) {
    String statement = query.getStatement();
    
    // Fix: Normalize short queries (starting with 'where', 'order by')
    // to full 'select doc.fullName from XWikiDocument doc ...' form
    // BEFORE performing safety checks.
    if (isShortForm(statement)) {
        statement = normalizeToFullQuery(statement);
    }
    
    // Perform validation on the fully expanded statement
    if (!isSafeSelect(statement)) {
        throw new SecurityException("Query is not allowed");
    }
}

This change eliminates the ambiguity that allowed the parser bypass. By validating the exact string that will be processed by Hibernate, the system ensures that no hidden SQL context escapes remain.

Exploitation Mechanics

Exploitation relies on sending a crafted GET request to the REST API. The attacker utilizes the q parameter to inject the malicious HQL/SQL payload and sets the type parameter to hql. A typical attack uses a Time-Based Blind SQL Injection vector, where the attacker asks the database to sleep for a specific duration to confirm the injection.

Proof of Concept Payload:

GET /rest/wikis/xwiki/query?q=where%20doc.name=length(%27a%27)*org.apache.logging.log4j.util.Chars.SPACE%20or%201%3C%3E%271%5C%27%27%20union%20select%201,2,3,sleep(7)%20%23%27&type=hql&distinct=0 HTTP/1.1
Host: target-xwiki.example.com

Payload Decomposition:

  1. Prefix (where doc.name=...): This satisfies the parser's requirement for a "short-form" query, engaging the vulnerable code path.
  2. HQL Escape (1<>'1\'): The sequence 1<>'1\'' is the core of the bypass. It leverages a discrepancy between how the HQL parser and the SQL driver handle escaped quotes. To HQL, this appears to be a comparison involving a string. To the SQL engine, the backslash escapes the quote, closing the string literal early.
  3. Injection (union select ... sleep(7)): Once the string literal is closed in the generated SQL, the attacker appends a UNION SELECT statement invoking sleep(7). If the server takes 7+ seconds to respond, the vulnerability is confirmed.
  4. Comment (#): The trailing hash character comments out the rest of the legitimate query generated by Hibernate, preventing syntax errors.

Impact Assessment

The impact of this vulnerability is severe due to the level of access obtained and the lack of authentication required.

Confidentiality (High): Attackers can extract the entire database contents. This includes wiki pages, configuration data, and critically, the xwikiusers table which contains user credentials (password hashes). Access to this table often allows for offline cracking or pass-the-hash attacks to gain administrative access to the application.

Integrity (High): While the PoC demonstrates a SELECT injection, the underlying flaw allows arbitrary SQL execution. Depending on the database user's privileges (often high in default configurations), an attacker could execute UPDATE or DELETE statements. This allows for defacement of the wiki, insertion of malicious JavaScript (XSS) into pages, or the creation of new administrative users.

Availability (High): Attackers can execute resource-intensive queries (e.g., BENCHMARK or long SLEEP commands) that exhaust database connection pools or CPU resources, rendering the XWiki instance unresponsive to legitimate users.

Official Patches

XWikiGitHub Commit fixing the vulnerability

Fix Analysis (1)

Technical Appendix

CVSS Score
9.8/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
EPSS Probability
26.18%
Top 4% most exploited

Affected Systems

XWiki Platform

Affected Versions Detail

Product
Affected Versions
Fixed Version
xwiki-platform
XWiki
>= 1.8, < 15.10.1615.10.16
xwiki-platform
XWiki
>= 16.0.0-rc-1, < 16.4.616.4.6
xwiki-platform
XWiki
>= 16.5.0-rc-1, < 16.10.116.10.1
AttributeDetail
CWECWE-89 (SQL Injection)
CVSS v3.19.8 (Critical)
Attack VectorNetwork (REST API)
Privileges RequiredNone
EPSS Score0.26184 (96.18%)
Exploit StatusPoC Available

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1059.006Command and Scripting Interpreter: Python
Execution
T1505Server Software Component
Persistence
CWE-89
SQL Injection

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Known Exploits & Detection

GitHub Security AdvisoryOfficial advisory containing the PoC and analysis

Vulnerability Timeline

Fix commit pushed to GitHub
2024-12-06
Public disclosure and GHSA publication
2025-04-23
CVE Published to NVD
2025-04-23

References & Sources

  • [1]GHSA-f69v-xrj8-rhxf
  • [2]NVD - CVE-2025-32969

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.