Problem/Motivation
When loading a node edit page with a paragraph field, which includes am editor enabled text area using the Paragraphs Classic widget, it does not seem to detect that CKEditor is being used, and fails to take the measures add the unsafe-inline CSP option.
This can be mitigated by allowing "unsafe-inline" globally for the "script-src-attr" setting. Which is not ideal.
I'm not sure what this module's policy is for supporting other modules, but Paragraphs is pretty common.
Steps to reproduce
* Install Paragraphs.
* Add a Paragraph field to a node, use the "Classic widget" and set the edit mode to closed.
* Create a node. with a paragraph that includes a CKEditor enabled text field.
Proposed resolution
...
Remaining tasks
...
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3164287-9-paragraphs-1.13.patch | 3.75 KB | nixou |
| #8 | csp_paragraphs.patch | 604 bytes | rfmarcelino |
| #7 | paragraphs-1.12-csp.patch | 3.65 KB | nixou |
| #7 | interdiff-6-7.txt | 699 bytes | nixou |
| #7 | paragraphs-dev-csp.patch | 3.63 KB | nixou |
Comments
Comment #2
gappleIt sounds like this should be covered as part of supporting core modules - I'll have to look into why it's not properly detecting the ckeditor library on the page.
If it's a unique solution for paragraphs, then it will be up to paragraphs to implement the csp API.
Comment #3
gappleThis is an issue with things that load through AJAX - the original page needs a policy that allows any markup & libraries that will be returned in an AJAX request, but can't generically know what will be loaded later by the page.
In core this occurs with quickedit, which may load CKEditor on the page after an AJAX request, so CSP adds
script-src-attr 'unsafe-inline'without knowing for sure if it will be needed or not.Paragraphs could do similar, enabling
'unsafe-inline'when a form includes a paragraphs field, or more selectively only when the paragraph type includes a formatted text field.Comment #4
bburgSounds like this should be a Paragraphs issue then. Shall we re-assign the issue to that project?
Comment #5
caco_d25 commentedThis patch changes the CSP policy for paragraph libraries
Comment #6
gappleThose libraries potentially make it a lot easier than having to alter based on form fields.
Here's a patch that moves the logic to an event listener in the paragraphs module. I'd appreciate some feedback, and if this works sufficiently I'll open an issue on the paragraphs module with this patch.
Comment #7
nixou commentedThe paragraphs patch is working only if script-src-elem is set to [Csp::POLICY_UNSAFE_INLINE] as well.
I attach two patch with this fix :
Comment #8
rfmarcelino commentedRe-roll #7
Comment #9
nixou commentedComment #10
gappleSince Drupal 9 / CKEditor 4 are no longer supported, I'm closing this as outdated.
Please reopen with any relevant Drupal 10 / CKE5 info if this is still an issue.