Headline
CVE-2023-41046: Velocity execution without script right through VelocityWiki property
XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. It is possible in XWiki to execute Velocity code without having script right by creating an XClass with a property of type “TextArea” and content type “VelocityCode” or "VelocityWiki". For the former, the syntax of the document needs to be set the xwiki/1.0
(this syntax doesn’t need to be installed). In both cases, when adding the property to an object, the Velocity code is executed regardless of the rights of the author of the property (edit right is still required, though). In both cases, the code is executed with the correct context author so no privileged APIs can be accessed. However, Velocity still grants access to otherwise inaccessible data and APIs that could allow further privilege escalation. At least for "VelocityCode", this behavior is most likely very old but only since XWiki 7.2, script right is a separate right, before that version all users were allowed to execute Velocity and thus this was expected and not a security issue. This has been patched in XWiki 14.10.10 and 15.4 RC1. Users are advised to upgrade. There are no known workarounds.
Steps to reproduce:
- Log in as a user without script right
- Edit your user profile (or any other document) with the class editor and add a new field of type "TextArea", named “Test” and set “Content Type” to "VelocityWiki".
- Edit the same document with the object editor and add an object of the just created class. Set its content to $request.cookies.
- Open <xwiki-host>/xwiki/bin/get/XWiki/username?xpage=display&property=XWiki.username.Test&type=object where <xwiki-host> is the URL of your XWiki installation and username is your user’s name.
Expected result:
$request.cookies is displayed.
Actual result:
Content similar to [javax.servlet.http.Cookie@2f0535e1, javax.servlet.http.Cookie@3ed6f4f6, javax.servlet.http.Cookie@6eb94904, javax.servlet.http.Cookie@4e4fbe60, javax.servlet.http.Cookie@48632075] is displayed, showing that the Velocity code has been executed. Note that while the Velocity code is executed, it is executed with the correct context author. Therefore, no privileged APIs can be accessed. However, still dangerous data might be accessed and security issues that are only exploitable with script right can be exploited.
This is caused by XWIKI-18222 which introduced the “VelocityWiki” type.
Related news
### Impact It is possible in XWiki to execute Velocity code without having script right by creating an XClass with a property of type "TextArea" and content type "VelocityCode" or "VelocityWiki". For the former, the syntax of the document needs to be set the `xwiki/1.0` (this syntax doesn't need to be installed). In both cases, when adding the property to an object, the Velocity code is executed regardless of the rights of the author of the property (edit right is still required, though). In both cases, the code is executed with the correct context author so no privileged APIs can be accessed. However, Velocity still grants access to otherwise inaccessible data and APIs that could allow further privilege escalation. At least for "VelocityCode", this behavior is most likely very old but only since XWiki 7.2, script right is a separate right, before that version all users were allowed to execute Velocity and thus this was expected and not a security issue. ### Patches This has been pat...