CVE-2025-52472: XWiki Platform is vulnerable to HQL injection via wiki and space search REST API
N/A
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| org.xwiki.platform:xwiki-platform-rest-server | maven | >= 17.0.0-rc-1, < 17.4.2 | 17.4.2 |
| org.xwiki.platform:xwiki-platform-rest-server | maven | >= 4.3-milestone-1, < 16.10.9 | 16.10.9 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability is an HQL injection flaw within the XWiki Platform's REST API, specifically in functions that handle searching and historical data retrieval. The root cause is the improper construction of HQL queries where user-controlled parameters, orderField and order, were concatenated directly into the query string for sorting purposes without adequate sanitization.
The analysis of the provided patches shows two main areas of weakness:
orderFieldInjection: In search-related functions likeDatabaseKeywordSearchSource.searchPagesandDatabaseKeywordSearchSource.searchObjects, theorderFieldparameter was used to specify a field for sorting. The patch introduced a check to ensure this field name is alphanumeric. Before this, an attacker could supply a malicious HQL snippet inorderField, which would be embedded into the query, leading to arbitrary HQL execution.orderInjection: In several resource implementation classes (ModificationsResourceImpl,PageHistoryResourceImpl,PageTranslationHistoryResourceImpl), theorderparameter (meant for 'asc' or 'desc') was used directly in the query. The patch replaces the direct usage with a call to a new utility function,HqlQueryUtils.getValidQueryOrder, which strictly validates the input.
By identifying the functions where these parameters were used insecurely, we can pinpoint the exact locations in the code that are vulnerable. During an exploit, these functions would be present in the runtime profile as they are responsible for processing the malicious request and constructing the injected HQL query.
Vulnerable functions
org.xwiki.rest.internal.resources.DatabaseKeywordSearchSource.searchPagesxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/DatabaseKeywordSearchSource.java
org.xwiki.rest.internal.resources.DatabaseKeywordSearchSource.searchObjectsxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/DatabaseKeywordSearchSource.java
org.xwiki.rest.internal.resources.BaseSearchResult.searchPagesxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/BaseSearchResult.java
org.xwiki.rest.internal.resources.ModificationsResourceImpl.getModificationsxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/ModificationsResourceImpl.java
org.xwiki.rest.internal.resources.pages.PageHistoryResourceImpl.getPageHistoryxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/pages/PageHistoryResourceImpl.java
org.xwiki.rest.internal.resources.pages.PageTranslationHistoryResourceImpl.getPageTranslationHistoryxwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/internal/resources/pages/PageTranslationHistoryResourceImpl.java