Client side security isn't the issue, but CSP is kind of a shit show. The configuration apparatus is godawful. I think the best way to think of it is if someone turned CSS (yes, the styling language) into a security configuration protocol. It uses the same style of cascading overrides that CSS employs.
If it's available, pull the third party JS in at build time via package manager rather than at runtime via a CDN you don't control.
NPM isn't perfect but there's typically a substantial delay between the release of a malicious package and that code getting onto your production environment. Unless you're automatically updating every day, there's a good chance someone will discover the problem before it affects you. And you can always scan your upstream dependencies.
This doesn't work if you're using someone else's CDN. Any change to their content is distributed to all your users immediately.
Vet everything, cut down to 2-3 services tops. Selfhost analytics whenever possible. Point to the OP article when asked why we can’t blindly put 30 tags using GTM.
A certificate-based approach for scripts residing on different domains, for example, so you can be sure it hasn't been tampered with.
A javascript file served from example-a.com should be able to run on example-b.org only if it has been signed with the same TLS key used for example-a.com .
CSP allows you to configure your loaded JS with a complementary hash check. If you're the one who puts the script on your page, in theory, it should be safe for as long as remains the same.
That is not any more secure if you are just blindly proxying the third party scripts and in fact is worse since it runs in the context of your own domain.
CSP is there to protect your user’s browser, not your servers. It’s ultimately their credentials that are going to get compromised with an XSS attack.
All things considered I think CSP is a good thing, a bit of a nuance for website operators, but it probably helps protect against lot of attack types.
Client side security isn't the issue, but CSP is kind of a shit show. The configuration apparatus is godawful. I think the best way to think of it is if someone turned CSS (yes, the styling language) into a security configuration protocol. It uses the same style of cascading overrides that CSS employs.
What is the alternative when you need to embed third-party JavaScript on your pages? Other than just "not doing that"?
If it's available, pull the third party JS in at build time via package manager rather than at runtime via a CDN you don't control.
NPM isn't perfect but there's typically a substantial delay between the release of a malicious package and that code getting onto your production environment. Unless you're automatically updating every day, there's a good chance someone will discover the problem before it affects you. And you can always scan your upstream dependencies.
This doesn't work if you're using someone else's CDN. Any change to their content is distributed to all your users immediately.
Vet everything, cut down to 2-3 services tops. Selfhost analytics whenever possible. Point to the OP article when asked why we can’t blindly put 30 tags using GTM.
Response to your pointing out: "so what?"
6 replies →
A certificate-based approach for scripts residing on different domains, for example, so you can be sure it hasn't been tampered with.
A javascript file served from example-a.com should be able to run on example-b.org only if it has been signed with the same TLS key used for example-a.com .
CSP allows you to configure your loaded JS with a complementary hash check. If you're the one who puts the script on your page, in theory, it should be safe for as long as remains the same.
Isn't this already true if the script is served over HTTPS?
1 reply →
How would that actually look in reality?
1 reply →
Other than tracking, what situations are there where "not doing that" is not an option?
Not doing that. It is just not a secure thing to do.
Proxy through your own domain? Has its own issues though
That is not any more secure if you are just blindly proxying the third party scripts and in fact is worse since it runs in the context of your own domain.
Since the third party tag can request anything, this doesn't stop anything and now your domain has an open redirect.
Most of it is server to server now with server side tagging. 3rd party cookies are now 1st party and beacon call is server to server.