Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WebProfiler CSP handler breaks on 'none' #36645

Copy link
Copy link
Closed
@cs278

Description

@cs278
Issue body actions

Symfony version(s) affected: 3.4.40

Description
The use of the 'none' token in a CSP policy causes ContentSecurityPolicyHandler to generate invalid CSP headers.

How to reproduce

Set a CSP policy of default-src 'none'; and ensure the web profiler is enabled.

$response->headers->set('Content-Security-Policy', "default-src 'none'")

The following header will be sent to the client:

default-src 'none'; script-src 'none' 'unsafe-inline' 'nonce-123'; script-src-elem 'none' 'unsafe-inline' 'nonce-123'; style-src 'none' 'unsafe-inline' 'nonce-456'; style-src-elem 'none' 'unsafe-inline' 'nonce-456'

Chrome reports the following problems:

The source list for Content Security Policy directive 'script-src' contains an invalid source: ''none''. It will be ignored. Note that 'none' has no effect unless it is the only expression in the source list.
The source list for Content Security Policy directive 'script-src-elem' contains an invalid source: ''none''. It will be ignored. Note that 'none' has no effect unless it is the only expression in the source list.
The source list for Content Security Policy directive 'style-src' contains an invalid source: ''none''. It will be ignored. Note that 'none' has no effect unless it is the only expression in the source list.
The source list for Content Security Policy directive 'style-src-elem' contains an invalid source: ''none''. It will be ignored. Note that 'none' has no effect unless it is the only expression in the source list.

This problem also exists if you have a policy of style-src 'none' you end up with a policy like style-src 'none' 'unsafe-inline' 'nonce-789'.

Possible Solution
Remove the 'none' token when appending additional tokens.

Additional context

Found this while investigating a regression #36643

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.