harden: move the 39 static style attributes onto classes and drop 'unsafe-inline' from style-src #328
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #307, from its review (#327 (comment)). The
default-src 'self'policy that landed carries one loosening that is removable, unlike the other two.style-src 'unsafe-inline'is required today only because 39 staticstyle="..."attributes remain insrc/popup/index.htmland the view helpers. No narrower spelling works cross-engine: Firefox implements neitherstyle-src-attrnor'unsafe-hashes', so the choice is'unsafe-inline'or no inline style attributes at all.Worth recording because it is easy to get wrong: the 57
.style.foo =assignments are CSSOM and CSP-exempt. They do not force the loosening and do not need changing. Only the 39 markup attributes do.Residual risk today is small — with escaping now in place nothing can inject a
styleattribute, andimg-src 'self' data:plusfont-srcfalling back todefault-src 'self'shut the usual CSS exfiltration channels. This is defence in depth, not an open hole, which is why it is not in the 1.0.0 milestone.The other two loosenings are not removable and should not be attempted here:
connect-src https: http:cannot be narrowed because a static manifest cannot know a user-configured RPC endpoint, andimg-src data:is required by blockies.Definition of done
style="..."attributes are expressed as Tailwind classes or equivalent, consistent with the repo's no-custom-CSS-classes rule inREADME.md.style-src 'self'in both manifests, pinned intests/manifest.test.js.make test-e2eandmake test-e2e-firefox— with real counts reported. A CSP tightening that passes unit tests and breaks a screen in a browser is the failure mode here.console.error, so aRefused to apply inline stylereddens the suite. Confirm Firefox logs no manifest-CSP parse error, i.e. the policy was accepted rather than silently discarded.make checkgreen.