question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AuthenticationProtocolMessage.BuildFormPost script tag CSP nonce

See original GitHub issue

Is your feature request related to a problem? Please describe.

It is not recommended to enable unsafe-inline in content security policy (CSP), as it would allow JavaScript to run without any additional validation. In the event of cross site scripting, CSP would no longer be able to protect the user. It is recommended to instead use CSP nonce and remove unsafe-inline.

In AuthenticationProtocolMessage.BuildFormPost, there is no way to customize the JavaScript script tag to emit the CSP nonce.

Describe the solution you’d like

Provide an overload in AuthenticationProtocolMessage.BuildFormPost that accepts CSP nonce.

Additional context

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mafurmancommented, May 31, 2019

Since it seems like using a hash in the CSP provides the same functionality as using a nonce, we’ve decided to add a property that returns the string value of the script so that it is easier for users to calculate the hash (for our 5.5.0 release). We plan on adding an overloaded method that allows users to specify a nonce in our 6.x release (tracked in this issue: #1199).

0reactions
huan086commented, May 18, 2019

User should pass “12345”. The nonce attribute name won’t change

I just realize using hash in the csp is an alternative way to solve the problem without changes in the source code

https://www.troyhunt.com/locking-down-your-website-scripts-with-csp-hashes-nonces-and-report-uri/

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSP Nonce ⟶ Script & Style Attribute
Learn how to use a CSP nonce to allow the loading and execution of a script or style tag when a Content-Security-Policy is...
Read more >
Content Security Policy multiple nonce - javascript
Your initial CSP, loaded with the page, provides a nonce. What you're trying to do is add another nonce, via Ajax, after the...
Read more >
CSP: script-src - HTTP - MDN Web Docs
The HTTP Content-Security-Policy (CSP) script-src directive specifies valid sources for JavaScript. This includes not only URLs loaded ...
Read more >
how to add Script tag nonce in ScriptResource.axd which ...
now we are trying add nonce tag for each of Script when page load to support CSP. but for those page with ScriptManager....
Read more >
Mitigate cross-site scripting (XSS) with a strict Content Security ...
Learn how to deploy a CSP based on script nonces or hashes as a defense-in-depth against cross-site scripting.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found