Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline scripts and styles in the solution blocks adding CSP with full restrictions #7295

Open
darekjk opened this issue Aug 10, 2024 · 2 comments

Comments

@darekjk
Copy link

darekjk commented Aug 10, 2024

nopCommerce version:
up to 4.80.x

The solution uses inline scripts and styles. According to new best security practicies, inline scripts should be moved to external JS/CSS files to allow using Content Security Policy header with maximum protection to the application.
Do You plan to move them in some future version?

@darekjk darekjk changed the title Inline scripts in the solution blocks adding CSP with full restrictions Inline scripts and styles in the solution blocks adding CSP with full restrictions Aug 10, 2024
@RomanovM
Copy link
Contributor

See also #2682

@darekjk
Copy link
Author

darekjk commented Aug 13, 2024

Issue #2682 is more about performance not security.
I was meant about: Content Security Policy

The best (for me) is moving every inline script and style section into individual files,
so it will be still easy to maintain.
For example, inline script from AddProductToOrder.cshtml could be moved to file ~/js/Areas/Admin/Views/Order/AddProductToOrder.js
and replaced in cshtml file with:
<script src="~/js/Areas/Admin/Views/Order/AddProductToOrder.js"></script>
It's simplest even than implementing nonce attribute indetifier for every request and adding to every script section.

Secondly, every script section which uses external JS code, should have integrity attribute, for example:
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
<script src="https://example.com/example-framework.js" integrity_no="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="anonymous"></script>
Some useful info: About CSP by Google

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants