As in #2942401: CKEditor is broken without 'unsafe-inlne', some libraries may require 'unsafe-inline'.
If the dependency can't be removed, its impact could at least be mitigated by only applying the rule on the pages where the affected libraries are actually in use, instead of applying the value globally.

Comments

gapple created an issue. See original summary.

gapple’s picture

Title: API for modules to alter policy per-request » Only apply 'unsafe' flags when dependent libraries are included on page
Category: Task » Feature request

I would like to avoid encouraging per-request alterations, but if CSP requires this functionality internally, it's not difficult to open up the ability to other modules as well.

gapple’s picture

At least for ckeditor, the need for this is mitigated a bit by the new script-src-attr and script-src-elem directives, which will allow limiting inline scripts to element event handling attributes (e.g. onclick, as needed by ckeditor), and block inline script blocks.

e.g.

  script-src: 'self' 'unsafe-inline';
  script-src-attr: 'unsafe-inline';
  script-src-elem: 'self'

See
#3015921: Implement *-src-elem and *-src-attr directives
#3016001: Use script-src-attr to limit effect of 'unsafe-inline' for CKEditor support

gapple’s picture

It looks like #2952390: Off-canvas styles override CKEditor's reset and theme also introduced the need for style-src 'unsafe-inline'; style-src-elem 'unsafe-inline'

gapple’s picture

Status: Active » Fixed

This was handled for CKEditor and Umami in #2895245: API for modules to alter policy

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.