Skip to content

Commit b210e90

Browse files
Mati365pomek
authored andcommitted
Use separate implementation of document to render raw elements.
1 parent faeeab4 commit b210e90

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.changelog/20250829072109_ck_33.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
type: Fix
3+
scope:
4+
- ckeditor5-clipboard
5+
---
6+
7+
A Cross-Site Scripting (XSS) vulnerability has been discovered in the CKEditor 5 clipboard package (`CVE-2025-58064`). This vulnerability could be triggered by a specific user action, leading to unauthorized JavaScript code execution, if the attacker managed to insert malicious content into the editor, which might happen with a very specific editor configuration.
8+
9+
This vulnerability affects **only** installations where the editor configuration meets one of the following criteria:
10+
11+
- [HTML embed plugin](https://ckeditor.com/docs/ckeditor5/latest/features/html/html-embed.html) is enabled
12+
- Custom plugin introducing an editable element which implements view [RawElement](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_rawelement-ViewRawElement.html) is enabled
13+
14+
You can read more details in the relevant [security advisory](https://github.com/ckeditor/ckeditor5/security/advisories/GHSA-x9gp-vjh6-3wv6) and [contact us](https://ckeditor.com/contact/) if you have more questions.

packages/ckeditor5-clipboard/src/utils/viewtoplaintext.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export function viewToPlainText(
5454

5555
// If item is a raw element, the only way to get its content is to render it and read the text directly from DOM.
5656
if ( viewItem.is( 'rawElement' ) ) {
57-
const tempElement = document.createElement( 'div' );
57+
const doc = document.implementation.createHTMLDocument( '' );
58+
const tempElement = doc.createElement( 'div' );
5859

5960
viewItem.render( tempElement, converter );
6061

packages/ckeditor5-clipboard/tests/utils/viewtoplaintext.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,23 @@ describe( 'viewToPlainText()', () => {
148148

149149
expect( text ).to.equal( 'Foo\nBar' );
150150
} );
151+
152+
it( 'should not execute img#onerror js handler while conversion a view RawElement', async () => {
153+
const writer = new ViewDowncastWriter( viewDocument );
154+
const rawElement = writer.createRawElement( 'div', { 'data-foo': 'bar' }, function( domElement ) {
155+
domElement.innerHTML = '<img src=x onerror=window.__testOnErrorExecuted=true>';
156+
} );
157+
158+
window.__testOnErrorExecuted = false;
159+
viewToPlainText( converter, rawElement );
160+
161+
await timeout( 50 );
162+
163+
expect( window.__testOnErrorExecuted ).to.be.false;
164+
delete window.__testOnErrorExecuted;
165+
} );
151166
} );
167+
168+
function timeout( ms ) {
169+
return new Promise( resolve => setTimeout( resolve, ms ) );
170+
}

0 commit comments

Comments
 (0)