I have some issues trying to clean up CSP errors when using the iFrame payment widget.
NOTE: I do not want to use unsafe-inline.
My current CSP
default-src ‘self’;
script-src ‘self’ https://sandbox.web.squarecdn.com;
frame-src ‘self’ https://sandbox.web.squarecdn.com ;
style-src ‘self’ https://sandbox.web.squarecdn.com https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net;
style-src-elem ‘self’ ‘sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=’ https://fonts.googleapis.com https://sandbox.web.squarecdn.com https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net;
font-src ‘self’ https://cash-f.squarecdn.com https://fonts.googleapis.com https://fonts.gstatic.com https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net;
connect-src ‘self’ https://pci-connect.squareupsandbox.com https://o160250.ingest.sentry.io;
img-src ‘self’ https://sandbox.web.squarecdn.com;
On the square.js line document.head.appendChild(r)),
I get a
Applying inline style violates the following Content Security Policy directive 'style-src-elem 'self'``https://sandbox.web.squarecdn.com``https://square-fonts-production-f.squarecdn.com`` ``https://d1g145x70srn7h.cloudfront.net``'. Either the 'unsafe-inline' keyword, a hash ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='),
When I add the hash (ending in SuFu=) to my style-src-elem that error disappears.
However trying that approach doesn’t work for r.innerHTML = Rh(e, Jh(t))
That produces
Applying inline style violates the following Content Security Policy directive 'style-src-elem 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' https://sandbox.web.squarecdn.com https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net'. Either the 'unsafe-inline' keyword, a hash ('sha256-5AjWgndEpRbacB86f2mPOgtBWjcgjFl/hosxZZUABgE='),
I tried with the hash ending with ABgE=, but it seems to change on each page load? I added about 8 hashes which showed up on page load but that never seem to help. The hashes are different on each load. I can’t use ‘unsafe-inline’ because I have a hash for the first error in the source list and it’s ignored.
I can make both go away with unsafe-inline but there has to be a better way.
It’s a payment app. I shouldn’t be asked to reduce the security on my payment page.
The second error I get is
Loading the font ‘https://cash-f.squarecdn.com/static/fonts/cashsans/woff2/CashSans-Regular.woff2’ violates the following Content Security Policy directive: “font-src https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net/fonts/sqmarket/ ‘report-sample’”. The action has been blocked.
There are 8 occurrences of this error despite having the following in my policy.
https://square-fonts-production-f.squarecdn.com
I have also tried to clear those by adding data: to font-src
font-src ‘self’ data: ``https://cash-f.squarecdn.com`` etc
But that doesn’t work.
What I really don’t understand here is that the error message is saying
violates the following Content Security Policy directive: “font-src https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net/fonts/sqmarket/ ‘report-sample’”
But my policy for font-src is
font-src 'self' https://cash-f.squarecdn.com https://fonts.googleapis.com https://fonts.gstatic.com data: https://square-fonts-production-f.squarecdn.com https://d1g145x70srn7h.cloudfront.net/fonts/sqmarket/;
The csp policy in the error -isn’t- mine? It’s erroring on the <!doctype html> line in single-card-element-iframe.html
So does that file have some CSP set on the square end? If that’s the case, I’d guess this is why adding data: had no effect.
I can’t get the font issue to go away at all
So how do I fix these issues.