GHSL-2022-009: HTML content sanitization bypass allowing to execute JavaScript code in CKEditor 4 - CVE-2022-24728
CKEditor 4's HTML sanitisation could be bypassed by a crafted HTML snippet, allowing JavaScript execution in the browser. An attacker could inject and run arbitrary JavaScript when a user toggles from source to WYSIWYG mode.
Originally disclosed on GitHub Security Lab
The HTML content sanitization in ckeditor4 can be bypassed, enabling Javascript code to be executed (in the browser). Note: this vulnerability is very similar to CVE-2021-41165, and uses the same attack vector.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the sanitiser's protection logic can be tricked: a special string prevents a script from being wrapped in a protected comment, and a data attribute disables filtering for that element and its children.
Impact
This issue could enable an attacker to bypass the sanitization logic and inject Javascript code.
What the attacker needed
Victim uses CKEditor 4.17.1 or similar; attacker can supply HTML content to the editor
The fix
The issue was fixed in CKEditor 4.18.0.
How it was found
- Clone the CKEditor 4 repository and check out version 4.17.1.
- Open the sample index.html in a browser.
- Click the Source button to switch to raw HTML editing.
- Replace the raw HTML with the crafted snippet.
- Click the Source button again to switch back to WYSIWYG mode.
- Observe the alert popup, confirming script execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
CKEditor is a text editor used on websites. It tries to clean up HTML so that users cannot insert harmful code. This report shows a way to sneak JavaScript past that cleaning, so the script runs when the editor switches back to normal view.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.