CSP security headers does not work in Microsoft Edge Browser
Hi,
I was testing IdentityServer4 RC3 and noticed the redirect after login does not work anymore in the Edge Browser. In the developer console of Edge it complains about the Content Security Policy in the header. At Stack Overflow someone else had the same kind of issue: http://stackoverflow.com/questions/31720023/microsoft-edge-not-accepting-hashes-for-content-security-policy
I saw that this enhancement was made under issue #242 Add CSP/XFO security headers.
Is it possible to make the Content Security Policy in the header backwards compatible for browsers that don't support it?
Best Regards, Jan
Are you using an external IdP, such as google? We found a strange behavior/bug in chrome that causes CSP issues.
Nope, I use only identity server 4 1.0.0 and mvc6 client. This issue didn't happen on RC3. It happen only after updating to RC4 and newer versions.
Well, look into comparing the sames to your solution that is not working. I bet there's some URL mismatch somewhere.
@BobBoba I just committed code that removes the form-action from CSP on the authorize response. Can you test against the MyGet feed build to see if it fixes your problem. Thanks.
BTW @BobBoba we're tracking your issue here: https://github.com/IdentityServer/IdentityServer4/issues/659
Is it correct to leave unsafe-inline for older browsers from security site and possible XSS attacks? @brockallen are You consider move script to js file, in this way server will be more secure on browser with only CSP 1.0 supporting
@brockallen Let me just quote CSP specification:
In either case, developers SHOULD NOT include either 'unsafe-inline', or data: as valid sources in their policies. Both enable XSS attacks by allowing code to be included directly in the document itself; they are best avoided completely.
Why IdentityServer can't just use simple and secure policy like default-src 'self'? It would be more secure solution and is compatible with older browsers (CSP1 is widely supported). Chrome uses pretty similar policy for its extensions, and I see no reason why IdentityServer should be any different. It needs XSS protection as much as any other web application. And it should work properly on every popular browser.
PS CSP article on Chrome Developers portal has some useful hints related to getting rid of inline JS.
@MichalStaruch do you know if we add 'self' for the CSP2 browsers do they then allow any JS, or do they also see the 'sha256' directives and only honor those? IOW, the reason we went with 'unsafe-inline' was that CSP2 browsers ignored it when they say 'sha256' directives.
We have to weigh which is worse -- 'unsafe-inline' for older browser, or 'self' for all browsers.
@brockallen:
do you know if we add 'self' for the CSP2 browsers do they then allow any JS, or do they also see the 'sha256' directives and only honor those?
I ended up via search engine here and just dropping some info regarding this:
Inline scripts won't work on IE Edge (04/2017) even when 'self' is present; you'll need the 'unsafe-inline''. I suppose sha256 directive is supported by Edge tho.
@simison did you mean "unsafe-inline" or "unsecure-inline"?
@brockallen Good catch! :beers: I meant 'unsafe-inline. Updated my comment.
We have hit this issue with one our web vulnerability scanner. Because of this the login process is uncomplete, the form_post (hybrid grant) is not executing on authorizationresult to signinoidc.
This is using latest identityserver4 as on today.
console message - Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'sha256-VuNUSJ59bpCpw62HM2JG/hCyGiqoPN3NqGvNXQPU+rY='"
Thats using quickstart samples
We faced this issue for a customer that where running an old version of Edge (v38). After reading this issue and looking at the source I see that there is now an option to support CSP 1.0 browsers (documented here). As this was not mentioned in this issue I want to point it out to anyone else facing this problem:
services.AddIdentityServer(options =>
{
options.Csp.Level = CspLevel.One; // For old Edge
});
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.