Headline
CVE-2023-22457: Remote code execution via CSRF using the HTMLConverter
CKEditor Integration UI adds support for editing wiki pages using CKEditor. Prior to versions 1.64.3,t he CKEditor.HTMLConverter
document lacked a protection against Cross-Site Request Forgery (CSRF), allowing to execute macros with the rights of the current user. If a privileged user with programming rights was tricked into executing a GET request to this document with certain parameters (e.g., via an image with a corresponding URL embedded in a comment or via a redirect), this would allow arbitrary remote code execution and the attacker could gain rights, access private information or impact the availability of the wiki. The issue has been patched in the CKEditor Integration version 1.64.3. This has also been patched in the version of the CKEditor integration that is bundled starting with XWiki 14.6 RC1. There are no known workarounds for this other than upgrading the CKEditor integration to a fixed version.
Steps to reproduce:
Open <server>/xwiki/bin/view/Main?sheet=CKEditor.HTMLConverter&language=en&sourceSyntax=xwiki%2F2.1&stripHTMLEnvelope=true&fromHTML=false&toHTML=true&text=%7B%7Bgroovy%7D%7Dprintln%28%22Hello+from+Groovy%21%22%29%7B%7B%2Fgroovy%7D%7D where <server> is the URL of your XWiki installation as a user with programming rights.
Expected result:
An error is displayed because no CSRF token was supplied.
Actual result:
The text “Hello from Groovy!” is displayed.
This demonstrates that a simple get request without CSRF token can trigger remote code execution. This means if an attacker manages to get a user with programming rights to do one of the following he/she can execute arbitrary Groovy/Python/… code:
- Trick the victim to click on a link with the attack code.
- Trick the victim to visit a website that includes the URL as the source of an image. In modern browsers, this needs to be on the same domain as otherwise cookies aren’t sent, it could be in the wiki (e.g., in a comment).
The affects version is the version I’ve reproduced this with, I think this should be reproducible in all versions of the CKEditor integration as I couldn’t see anything that would prevent the attack.
Related news
### Impact The `CKEditor.HTMLConverter` document lacked a protection against Cross-Site Request Forgery (CSRF), allowing to execute macros with the rights of the current user. If a privileged user with programming rights was tricked into executing a GET request to this document with certain parameters (e.g., via an image with a corresponding URL embedded in a comment or via a redirect), this would allow arbitrary remote code execution and the attacker could gain rights, access private information or impact the availability of the wiki. The attack can be demonstrated by accessing the URL `<server>/xwiki/bin/view/Main?sheet=CKEditor.HTMLConverter&language=en&sourceSyntax=xwiki%2F2.1&stripHTMLEnvelope=true&fromHTML=false&toHTML=true&text=%7B%7Bgroovy%7D%7Dprintln%28%22Hello+from+Groovy%21%22%29%7B%7B%2Fgroovy%7D%7D` where `<server>` is the URL of the XWiki installation as a user with programming rights. If this displays the text "Hello from Groovy!", the installation is vulnerable. ### ...