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

Support for Security Headers for resources other than HTML #434

Open
kryopix opened this issue Apr 25, 2024 · 5 comments · Fixed by #441
Open

Support for Security Headers for resources other than HTML #434

kryopix opened this issue Apr 25, 2024 · 5 comments · Fixed by #441
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@kryopix
Copy link

kryopix commented Apr 25, 2024

Hello,

I've noticed that all web security headers only appear in the HTML responses, but not in the Nuxt resources such as CSS, JS, etc. Public resources are also not considered by Nuxt-Security.

Security scanners are raising alarms because the necessary headers, such as X-Content-Type-Options: nosniff, are not set on the resources.

Currently, I've solved this issue with an additional proxy that sets these headers on all resources. However, I suspect this might be a bug in Nuxt-Security, but I'm not sure as I'm not very familiar with this area.

Is it intended that the security headers are only set in the HTML responses? Or is this a bug?

Thank you in advance for your help.

Best regards

@kryopix kryopix added the bug Something isn't working label Apr 25, 2024
@vejja
Copy link
Collaborator

vejja commented Apr 25, 2024

We only apply Security Headers to HTML resources but I think you are right and it might be incorrect in this case.

@Baroshem what's your opinion there?
Shall we apply some headers only to HTML resources (e.g. contentSecurityPolicy, crossOriginEmbedderPolicy, permissionsPolicy), and others to all resources (e.g. xContentTypeOptions, strictTransportSecurity) ?

@Baroshem
Copy link
Owner

Hey guys,

I think we could also apply it to other resources to satisfy security scanners. But at this moment I dont have an idea how to implement it so would need more time for that.

Also, I think we could convert it to feature request because NuxtSecurity works for HTML by design right now but we can extend it to support more cases :)

@Baroshem Baroshem added enhancement New feature or request and removed bug Something isn't working labels Apr 25, 2024
@Baroshem Baroshem changed the title Web security headers only appear in HTML responses, not in Nuxt resources Support for Security Headers for resources other than HTML Apr 25, 2024
@vejja
Copy link
Collaborator

vejja commented Apr 25, 2024

I think we could do it. We would need different hooks into render:response and beforeResponse.
Let's start by finding out which headers would need to be applied to all resources, WDYT ?

@kryopix could you please send us the detailed output from your security scanner so that we understand better what we can improve ?

@vejja
Copy link
Collaborator

vejja commented May 5, 2024

@Baroshem this one was more difficult than I anticipated, but now available through #441
Only a subset of headers are concerned:

  • referrerPolicy
  • strictTransportSecurity
  • xContentTypeOptions
  • xDownloadOptions
  • xFrameOptions
  • xPermittedCrossDomainPolicies
  • xXSSProtection

Makes no sense on CSP, Permissions and COEP/COOP I believe
Comments welcome as always
Cheers

@Baroshem Baroshem added this to the 2.0.0 milestone May 6, 2024
@vejja vejja self-assigned this May 6, 2024
@Baroshem
Copy link
Owner

Sounds good to me! Thanks for the research and work on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants