Hacker News new | ask | show | jobs
by goalieca 14 days ago
It also makes adding csp a nightmare. Your marketing department is putting in 30 trackers, changing monthly. And then there’s different countries for end clients with different TLDs for connect-src. You can’t possibly get anything locked down enough. That’s bad for security when you rely on csp for mitigating other factors.
3 comments

> And then there’s different countries for end clients with different TLDs for connect-src.

Oh how I hate that one. I wish Facebook, Instagram, Google and others would figure out serving the public scripts from .com only.

I'm sure they know how to serve from a single domain - but it is in their interest if you are forced to give them the nonce pass. So yeah, it's (again) all about incentives.
I don't think that's the case. Csp doesn't restrict them from doing what they want with tracking tech.
relying on any client-side "security" is probably a bad idea
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?"
> Response to your pointing out: "so what?"

Then you've done your job and move on. Just make sure that there's enough public record of your warning that - when the next cdn supply chain attack happens - you can say "I warned you about this and you decided not to take action".

No organization is perfect. I don't think this is something to quit over. Just make sure to CYA.

Response: "Here's my two weeks notice for leaving, let me know if you want to start caring about users again".

Life's too short to work for people who don't care about others.

You go ahead and find me another job then.

Life’s too short to care about random strangers on the internet sometimes.

Their response: "ok"

and things continue being insecure

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?
Wouldn't this protect you only against mitm attacks?
How would that actually look in reality?
Same approach as a domain cert - scripts served through CORS should sport their own public signature specific to the origin domain to be checked against by the browser before the execution. If the file has been tampered it should be immediately apparent.
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.
I mean, really that situation is CSP finally earning its keep. Put whatever you want in tag manager but at the end of the day it's not going to work unless I review it.
Google’s suggested workaround for CSP enabled sites for GTM is to use a nonce, which GTM then propagates to all further scripts that it injects.

https://developers.google.com/tag-platform/security/guides/c...

Nonce would kill this idea, but fortunately it is the webadmin that needs to install it.

In the end this is a tradeoff between security and convenience.

Perhaps I’m not really following, but it seems like in this case they were executing blind anyhow? If they implemented a nonce where would they have derived the trust for it? If they’re just running what they’re given this attack came from the trusted vector so i would assume a nonce wouldn’t add much other than rubber stamping what was already corrupted…
I think that works for script-src but not connect-src.