-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
frustration with inline script #34425
Comments
🍂🎁 Happy Holidays! ❄️⛄This issue has been marked for triage on the Blazor Docs GitHub project, and I'll respond as soon as I return from the holiday vacation after New Year's. We only work on documentation on this repo. If you need product support, close this issue and seek assistance through one or more of the following support channels: If you think that you found a potential bug in the framework or have product feedback, close this issue and open a new issue for the ASP.NET Core product unit at dotnet/aspnetcore issues. Bug reports require a clear explanation of the problem, usually including a minimal repro project placed on GitHub for the product unit engineers to download and run. If you determine with the product unit that it isn't a bug but merely requires documentation, please re-open this docs issue and place a cross-link to your engineering issue discussion. For problems or feedback on Visual Studio, close this issue and use the Report a Problem or Suggest a Feature processes from within VS, which open internal issues for the VS product unit. For more information, see Visual Studio Feedback. For problems with Visual Studio Code, close this issue and ask for support on community support forums. For bug reports and product feedback, open an issue on the microsoft/vscode GitHub repo. 💃🕺🥳 Happy New Year! 🎈🎆🍾🥂🎉 See you in 2025! |
Hello @jbaumflek ...
No, it's just not the intended best case scenario to make liberal use of inline scripts in Blazor. If you want to do that, I think you'd probably use the hash-source approach. Could you look into that approach and see if it would aid you? Scroll down in this section ... Also, consider not using a lot of inline scripts if you can. See if you can leverage JS collocation instead. Leave this issue open until I get back to work after New Year's. I'd like to take a closer look at it for possible coverage. Happy New Year! 🎉 ... I'll get back to you probably next week or the week after. BTW ... I originally wondered if nonce-source would work and wrote that. I switched my above comment to hash-source because nonce-source requires the nonce to be dynamically generated. Still tho, one might be able to pull that off by adding the CSP via controlling |
Took a closer look.
Now, might a hash-source approach work with controlling I'm going to note that inline JavaScript requires the inline script's hash to appear in the most restrictive policy, which is typically the policy set in the WRT your asking about Blazor having some kind of feature to better manage CSPs for inline scripts, you can open an issue for the product unit to ask them about it at ... https://github.com/dotnet/aspnetcore/issues Please add ...
... to the bottom of your opening comment so that I can follow along and possibly take some of their response into my PR on this. I'll ping u on the PR when it goes up. I think that they're going to tell you not to rely on a lot of inline scripting with Blazor with a CSP. |
@guardrex What do you mean here: thanks, |
Just as the article shows, the CSP
Nevermind! ... I see it now ... I'll confirm that this is cross-linked or included in the CSP article. Confirmed! It is cross-linked in two places. I'll add one more cross-link to the CSP article's server-side section. |
Description
Perhaps this is not a documentation issue, or rather, this document in particular.
As we discovered in pen testing of our Blazor server-side app, we were missing CSP headers. As I put them in, I am running into a BIG problem because, as much of the Blazor sample documentation indicates, I used inline script all over the place. If I have to hash every single place in the app where there is code, I can't imagine the size of the csp header for all the hashes I'll need.
I must be missing something...or there is a fundamental flaw in Blazor/razor re: security and XSS.
[Enter feedback here]
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/content-security-policy?view=aspnetcore-8.0#server-side-blazor-apps
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/security/content-security-policy.md
Document ID
6e0b5c52-90a1-5ca6-bfad-df33a8beae6c
Article author
@guardrex
Related Issues
The text was updated successfully, but these errors were encountered: