Reputation: 11781
I have a server helper.com
that serves responses to GET
requests with custom CSP, e.g.:
Content-Security-Policy: default-src 'self'; frame-ancestors https://my.com;
The idea is that only my.com
can include the widget from helper.com
.
This works fine in modern browsers (Chrome, Safari, Firefox).
The question is, how can I reliably exclude browsers that don't support CSP?
That is all the IE family (?), very old versions of good browsers, legacy browsers, even NN if someone happens to use it?
The technical reason is that if the user has a session cookie on helper.com
, I plan to serve user's confidential information and I'm worried about cases where someone uses e.g. IE, is logged in, and some hackers will create hacker.com
that tries to fetch stuff from helper.com
via ajax or script tag or font resource or image to canvas and steal user's confidential data.
In sort, if I serve CSP, I want to be sure it will be applied by the browser.
Upvotes: 1
Views: 718
Reputation: 5163
What I would have done is the set of following steps:
user-agent
on the request headers. And There is no way to change the user-agent
header sent by the browser from client side code. So, I would have used that value on web server side in order to decide which browser I am dealing with. ref: understanding user-agentbrowser-not-supported.html
to say or for others I would have proceeded further.index.html
or other html pages in order to not make requests if this browser is not supporting the exact CSP headers, which I need for my site.X-Frame-Options "SAMEORIGIN"
which will serve our specific purpose in case the browser does not honor/understand the CSP headers.Upvotes: 1
Reputation: 3907
This isn’t really what CSP does. CSP doesn’t protect the site from malicious users; it protects users from compromised web sites. Your best bet is some form of server authentication to determine whether you serve up the data or not. But that isn’t a matter of CSP
Upvotes: 0