Skip to content

Conversation

nicwortel
Copy link
Contributor

AssetMapper will include special importmap entries for CSS files, which get resolved to data:application/javascript.
See https://symfony.com/doc/current/frontend/asset_mapper.html#handling-css.

Browsers will report those as CSP violations, as data: scripts can also be used for XSS attacks. For the same reason, allowing data: in the CSP is not a safe solution.

symfony/symfony#58416 (comment) provides a solution: using strict-dynamic in the script-src directive will allow the importmap to include other resources.

This PR adds that solution to the documentation.

@carsonbot
Copy link
Collaborator

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

AssetMapper will include special importmap entries for CSS files, which
get resolved to `data:application/javascript`.
See https://symfony.com/doc/current/frontend/asset_mapper.html#handling-css.

Browsers will report those as CSP violations, as `data:` scripts can
also be used for XSS attacks. For the same reason, allowing `data:` in
the CSP is not a safe solution.

symfony/symfony#58416 (comment)
provides a solution: using `strict-dynamic` in the `script-src` directive
will allow the importmap to include other resources.

This commit adds that solution to the documentation.
@nicwortel nicwortel force-pushed the asset-mapper-csp-strict-dynamic branch from 58d6a7c to 358ece7 Compare October 30, 2024 15:33
@javiereguiluz javiereguiluz merged commit f26f286 into symfony:6.4 Oct 31, 2024
3 checks passed
@javiereguiluz
Copy link
Member

Nicely explained 👏 Thanks Nic!

@nicwortel nicwortel deleted the asset-mapper-csp-strict-dynamic branch October 31, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants