Skip to content

Conversation

@neSpecc
Copy link
Member

@neSpecc neSpecc commented Oct 22, 2023

Problem

If user enables Content Security Policy style-src, editor's styles are not working

image image

Cause

If CSP "style-src" enabled, browser will execute style only if:

  • Content-Security-Policy: style-src 'unsafe-inline' — bad solution
  • Content-Security-Policy: style-src 'sha256-ozBpjL6dxO8fsS4u6fwG1dFDACYvpNxYeBA6tzR+FY8=' — user have to manually update hash on every editor style change
  • Content-Security-Policy: style-src 'nonce-2726c7f26c' — nonce is random number re-generated on each request

Solution

If user enabled CSP, he should generate random nonce on each request, set it in CSP header Content-Security-Policy: style-src 'nonce-2726c7f26c' and pass it to the Editor, so we will add that nonce to the style tag.

image

Resolves #1334

@neSpecc neSpecc merged commit ee188bf into next Oct 22, 2023
@neSpecc neSpecc deleted the feat/nonce branch October 22, 2023 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question] Content Security Policy inline style

4 participants