This question seems to be related to https://stackoverflow.com/questions/15913200/facebook-js-sdk-not-executed-in-my-chrome-extension , but I am not developing a chrome extension. I am developing a normal web application.
I am trying to integrate Facebook login on my website, which has a tight CSP policy. I am following the recommendations of https://developer.chrome.com/extensions/contentSecurityPolicy , where it is mentioned that 'unsafe-eval' should not be used. However, if I put the following CSP-policy:
<add name="Content-Security-Policy" value="default-src 'self'; connect-src 'self'; script-src 'self' https://connect.facebook.net; img-src 'self' https://www.facebook.com; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'self' https://s-static.ak.facebook.com https://www.facebook.com https://www.youtube.com; "/> then the facebook login does not appear, as the CSP policy restricts unsafe eval code. If I change it to the following:
<add name="Content-Security-Policy" value="default-src 'self'; connect-src 'self'; script-src 'self' 'unsafe-eval' https://connect.facebook.net; img-src 'self' https://www.facebook.com; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'self' https://s-static.ak.facebook.com https://www.facebook.com https://www.youtube.com; "/> then it works. Notice the extra 'unsafe-eval' in the script-src part of the CSP. Anyway, I don't want to use the 'unsafe-eval' condition, as this would greatly reduce the security of my website.
Is there a way that I can use the Facebook login (SDK), without having to use 'unsafe-eval' in my CSP policy?
unsafe-evaldoesn't render CSP completely useless.unsafe-inlineis the really bad one that undoes most of the benefit of CSP against XSS.