Closed (fixed)
Project:
Content-Security-Policy
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
23 Dec 2023 at 05:07 UTC
Updated:
5 Jun 2024 at 09:09 UTC
Jump to comment: Most recent
Comments
Comment #2
gappleComment #3
gappleComment #5
gappleNow also included is
PolicyHelper::requireUnsafeInline(), which will apply to the necessary subdirective and fallback, but ensure the other subdirective doesn't fall back (if it does not yet have a value).It will remove any nonce or hash so that
'unsafe-inline'applies - this could cause problems if called after another module adds a nonce or hash that would require a non-'unsafe-inline'fallback, so it should be called in an alter subscriber that's prioritized to execute earlier than others.Comment #6
gappleComment #7
gappleComment #8
gappleComment #9
gappleComment #10
gappleI altered the parameter order so that a fallback value is always required, and added a note on the method docblock about properly calling
requireUnsafeInline()early.Comment #11
gappleComment #12
gappleNoticed some extra cases to test:
- if appending a new nonce or hash and the directive already includes a nonce, hash, or strict-dynamic (which disable 'unsafe-inline'), then the value should be appended (and not the fallback).
- if requiring 'unsafe-inline' and the directive includes 'unsafe-hashes'
Some cleanup is possible with 'unsafe-hashes':
- if 'unsafe-hashes' isn't present on an attribute directive (e.g. it was copied from the base directive), any hashes can be removed since they're not effective (assume they correspond to permitted hashes of elements).
- remove 'unsafe-hashes' from an element directive.
Comment #15
gapple