eikek / eikek/sharry

Site breaks in Chrome/Edge when `require-trusted-types-for` is enabled in CSP header

Open
#1,345 3 comments 0 reactions 0 assignees View on GitHub
webui
Dominant language
Elm
Stars
1.3k
Forks
72
Avg merge
21h 30m
Merged PRs (30d)
1

Description

When `require-trusted-types-for: 'script'` is enabled in the Content Security Policy (CSP), the site fails to render in Edge and Chrome.

![screenshot of Chrome errors loading a Sharry site with `require-trusted-types-for` enabled](https://github.com/eikek/sharry/assets/71903191/0b2b2241-7afe-4394-ae4f-7c5b26ee45ea)

Presumably this happens because the scripts inject raw strings into the DOM rather than appending typed values to the DOM. See [the MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/require-trusted-types-for).

The site renders in Safari and Firefox because those browsers do not yet support the `require-trusted-types-for` directive. Presumably they will support in the future, however.

Contributor guide

Open the contributing guide

Research direction

Reproduce the rendering failure in Chrome or Edge with require-trusted-types-for: 'script' enabled, then trace the scripts that inject raw strings into the DOM. Confirm the fix by loading the site under that CSP in both browsers while preserving the existing rendering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm, javascript
Domain
frontend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.