imjdl (3)

Last Login: May 07, 2024
Assessments
1
Score
3

imjdl's Latest (2) Contributions

Sort by:
Filter by:
1

Or use the default administrator email admin@example.com

2
Ratings
  • Attacker Value
    Very High
  • Exploitability
    Very High
Technical Analysis

Overview

XWiki is a Java-based, highly customizable and extensible enterprise-level Wiki platform, offering cross-database support, a powerful plugin system, a flexible template engine, and comprehensive security management, suitable for knowledge management and collaboration across various business needs.

This vulnerability, identified as XWIKI-21173, is a critical remote code execution (RCE) vulnerability present in the user registration process of XWiki. Specifically, it allows attackers to insert malicious scripts in the “name” field during user registration, which are subsequently executed on the server, potentially leading to unauthorized data access or system control. This vulnerability exposes a security flaw in XWiki’s handling of user input and script execution, posing a serious threat to the overall system security and necessitates immediate remediation to protect user data and system integrity.

Technical Analysis

In RegistrationConfig.xml, user inputs such as register_first_name and register_last_name were directly embedded into the registration success message, without appropriate sanitization or escaping. Attackers could inject malicious Groovy scripts through the registration form. When these scripts were executed on the server, they could trigger arbitrary commands, resulting in a remote code execution (RCE) vulnerability.

<registrationSuccessMessage>#set($fullName = "$request.get('register_first_name') $request.get('register_last_name')")
{{info}}$services.localization.render('core.register.successful', ["[[$fullName&gt;&gt;$userSpace$userName]]", $userName]){{/info}}</registrationSuccessMessage>

For this, we can generate the following payload based on the original configuration.

  • ]]{{/html}}{{async}}{{groovy}}"touch /tmp/success".execute().waitFor(){{/groovy}}{{/async}}
  • ]]{{/html}}{{async}}{{groovy}}throw new Exception("cat /etc/passwd".execute().text){{/groovy}}{{/async}}

Firstly, ]]{{/html}} is used to end any previously started HTML rendering. Following this, the {{async}} tag begins an asynchronous code block, meaning the subsequent code will run asynchronously, not blocking the rest of the page. The {{groovy}} tag indicates that the following code is written in the Groovy language. Finally, the {{/groovy}}{{/async}} tags conclude the Groovy script block and the asynchronous block.

The modifications made to the RegistrationConfig.xml file in the GitHub commit for XWIKI-21173 significantly enhance the security and accuracy of the registration success message within XWiki. By shifting to a more secure method of constructing user links using $xwiki.getUserName and employing $services.localization.render for message templating, these changes mitigate potential vulnerabilities such as code injection. This approach not only ensures the safe embedding of user-generated content but also supports multilingual environments, demonstrating a commitment to improving both the security and versatility of the XWiki platform.

git show b290bfd573c
...omitted...

diff --git a/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/RegistrationConfig.xml b/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/RegistrationConfig.xml
index ae1e3b1d9a3..640c8d1bd36 100644
--- a/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/RegistrationConfig.xml
+++ b/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/RegistrationConfig.xml
@@ -555,8 +555,9 @@
<passwordRuleOneUpperCaseEnabled>0</passwordRuleOneUpperCaseEnabled>
</property>
<property>
  -      <registrationSuccessMessage>#set($fullName = "$request.get('register_first_name') $request.get('register_last_name')")
  -{{info}}$services.localization.render('core.register.successful', ["[[$fullName&gt;&gt;$userSpace$userName]]", $userName]){{/info}}</registrationSuccessMessage>
  +      <registrationSuccessMessage>#set($message = $services.localization.render('core.register.successful', 'xwiki/2.1', ['USERLINK', $userName]))
  +#set($userLink = $xwiki.getUserName("$userSpace$userName"))
  +{{info}}$message.replace('USERLINK', "{{html clean=false}}$userLink{{/html}}"){{/info}}</registrationSuccessMessage>

Reference

  1. https://jira.xwiki.org/browse/XWIKI-21173
  2. https://github.com/xwiki/xwiki-platform/security/advisories/GHSA-rj7p-xjv7-7229
  3. https://github.com/xwiki/xwiki-platform/commit/b290bfd573c6f7db6cc15a88dd4111d9fcad0d31
  4. https://attackerkb.com/topics/Hn4W1casCs/cve-2024-21650
  5. https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiSyntax/?syntax=2.1&section=Macros
  6. https://extensions.xwiki.org/xwiki/bin/view/Extension/Localization/Scripting/