tinymce-react icon indicating copy to clipboard operation
tinymce-react copied to clipboard

feat: add nonce attribute for loading scripts with csp policy

Open felixmosh opened this issue 1 year ago • 5 comments

closes #553

felixmosh avatar Oct 07 '24 18:10 felixmosh

?

felixmosh avatar Oct 08 '25 04:10 felixmosh

@felixmosh Looking back at #553, it sounds like you're hoping to load TinyMCE with a nonce and have that nonce automatically applied to every script TinyMCE creates. If that's the case, unfortunately this PR won’t achieve that.

Even if that’s not the goal, this change still won’t allow you to enforce a strict CSP reliably, since TinyMCE dynamically injects additional scripts at init time (for plugins, skins, and other resources).

You may want to forward this as a feature request to the TinyMCE issue tracker , as this would need to be addressed within the core editor.

For reference, Tiny has a useful guide on CSP considerations here: TinyMCE CSP Guide

tiny-ben-tran avatar Dec 05 '25 04:12 tiny-ben-tran

Usage of nonce for csp, is standard thing. The spec says, if a script is loaded with nonce, every loaded script from it will be trusted. So, there is no need to apply it to all loaded scripts... Currently, I'm forced to allow entire cdn url... Which is wrong.

felixmosh avatar Dec 05 '25 05:12 felixmosh

Don't you also need to add strict-dynamic for trust to be propagated according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/script-src#strict-dynamic?

tiny-ben-tran avatar Dec 05 '25 05:12 tiny-ben-tran

Yeap...

felixmosh avatar Dec 05 '25 05:12 felixmosh