Hacker News new | ask | show | jobs
by stickfigure 17 days ago
The whole concept of Google Tag Manager was that you could give marketing departments the ability to add "tags" to the website without having to involve engineering. That's how we got 10MB of javascript with every news article.

I hope folks are re-evaluating that now.

19 comments

Client side A/B testing through services like Optimizely and VWO and Adobe Target is a massive security nightmare in of itself. You're giving anyone with access to a third party service the ability to run any code they like on your website, and change any and all interface elements as they see fit.

Even one of these accounts being compromised would be a massive security incident that would potentially put millions of people's data at risk.

Just pointing out that these testing solutions can also be deployed server-side instead of via client-side tags. I suspect that is the route a lot of their customers will take now.
And even at the edge via things like edge side includes or their modern worker versions.
Ehh. This has been going on for decades, I don't see engineers changing such time-honoured traditions.

In my experience the vulnerabilities are coming from tools brought in by less technical teams, which then get misused by engineers.

These tools are oddly "safe" in the hands of Marketing and the like, because nobody trusts Marketing, so they stick a bunch of guardrails in place to stop anything stupid from doing serious damage.

The same tools are dangerous in the hands of engineers - many engineers trust themselves to do risky things, and will bludgeon you with debate if you tell them they have to follow the same rules as those _simpletons_ in Marketing.

They're usually client-side because engineers don't want to waste time implementing things for Marketing (or more accurately, struggle to support a domain that is radically multidisciplinary and just-in-time and revolves around conforming to non-engineering industry norms, to such a degree that everyone prefers siloing themselves), and the safe space given to Marketing is usually a client-side tag manager so that's where they do it when they have to do it themselves, and then once the tool is implemented client-side, engineers piggybacking off it aren't going to bother with doing a new server-side implementation.

Cue engineers loading Optimizely in their secure product areas, getting exceptions added to CSPs, and the like. Then a major incident. Then a post-mortem highlighting the risks of letting Marketing manage SaaS, then a project to make a secure in-house experimentation solution which the engineers will abandon shortly afterwards... and then finally, a couple years later, someone will discover Marketing has procured Optimizely 2.0 and the cycle repeats.

I agree. I implemented A/B testing as a feature in my self-hosted analytics app[0] and I have decided to vastly limit what can be automatically changes through the A/B editor. It only allows to change text or CSS/styles on page, nothing else (no DOM elements, no JS, etc.). This is quite limiting, but I simply couldn't convince myself that letting an analytics dashboard insert arbitrary JS/code on a website is ever a good idea.

That being said, self-hosting still makes a HUGE difference, even if those sort of breaches happen, the impact is a lot more limited, and easier to detect and fix.

[0]: https://www.uxwizz.com

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.
> 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.

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.
> I hope folks are re-evaluating that now.

Not going to happen. Most decisions in tech do not factor in risk, only cost. Risk mitigation usually requires considerable spend, and very few people/companies are willing to spend on low-probability events.

Risk is always reducible to cost though. Even for human life, the cost of safety equipment is weighted against the statistical value/cost of a life, instead of spend on for instance maritime equipment being engineered to be infinite. One could argue that the cost is harder to define for squishier subjects, for instance like the privacy of pictures from my vacation or that I send to my physician. But I’d argue that is even simpler, the value is just what one is willing to spend to not risk it, plus any cost of cleanup/being made whole.
I know you're sort of speaking abstractly, and I think you're correct that this is how companies interpret risk, but it's interesting to give a moment's thought to -- Murphy's Law tells us all events have a 100% probability of occurring given a certain amount of time. And we tend to see that proven out time and again.
This might change as AI-assisted hacks and outages become more frequent. A materialized risk with associated costs is very different from an abstract risk that's hard to quantify.
What is that saying? A person will not understand something that their paycheck requires them to not understand.

That’s why it needs to become criminal for a website to serve malware, including through third party channels like ad networks and analytics services. Serving shit websites is no different than knowingly, or negligently, dumping toxic waste and should be treated the same.

If it's criminal for sites to accidentally serve malware, what does it mean for open source projects to accidentally get hit by supply chain attacks, or for them to get compromised by a rogue contributor (eg. xz)?
Those website operators include third-party code willingly and explicitly. There was never an accident. There is no supply-chain attack here: you cannot seriously claim that unaudited, unauthenticated terminal with root security principal getting used is an attack.

If your website is making any requests outside of the original domain, there's no "accidental" in anything the website does.

Someone _could_ argue that a vibecoded website is doing "accidental" things (like serving malware).
Someone could argue that the sky is green.
A business in the US has legal liability if they fail to do their due diligence in their supply chain and it turns out their suppliers are involved in human trafficking, child labor, forced labor, etc. or is using hazardous materials in the product.

There should be standards that people have to live up to if they are going to provide a product, even for free, to others.

Do they? Without signing up?
Any cases of that being enforced with any significant business ever? What about aiding genocide? (FB, and weapon makers for example)
Malware is malware. People shouldn’t be offering software that they can’t stand behind.

I see no way to distinguish between huge megacorps and individuals.

One could distinguish between criminal negligence and forgivable negligence in court. Unfortunately for GP that probably means you can't actually stick charges on anybody who serves malware via an ad network like this.
> One could distinguish between criminal negligence and forgivable negligence in court.

Open source is already expensive from a time standpoint, you wanna make it expensive from a monetary standpoint too?

Yes. Why should you be allowed to be negligent just because your product is open source?
The question is more "why should it cost $50k in legal fees to prove I wasn't negligent in my unpaid hobby".
Software is already hard from functionality standpoint, you wanna make it hard from security standpoint too?
It is already hard from a security standpoint, only that we ignore security.
Easy solution: Don't use ad networks. That'll likely free your site from illegal tracking, as well as ad trash, and will even improve your lIgHtHoUsE score!
Yes. It means the legitimate maintainer of xz would be in prison right now.
Liability should aggregate up to the largest platform involved. Optimizely in this case, I guess. Google for Google Tags.

We should also enforce antitrust laws.

> A person will not understand something that their paycheck requires them to not understand.

I never really understood this idiom, because how can a PHB engineering manager (for example) be required to not understand their team's technology in order to retain their job? Surely if that manager knows their team's work inside out then they would be a more effective manager - which is good for everyone?

If I squint-my-brain, I can see how (for example) that anyone who works full-time as an SEO "consultant" in the year 2026 would only be if they actually believed that SEO tricks actually worked, which requires them to not understand how modern search-engines' spiders actually work (because it's my belief that "SEO" has been either nonsense bollocks - or a complete grift - since the mid-2010s). Am I close?

It's not the team's technology that's being referred to. It's about hazards. People whose job it is to do X have a hard time understanding that X shouldn't be done.

In this case, it's the dangers of the tracking and advertising frameworks being used for hostile purposes.

Because it is not the PHB that starts the problem. It is someone from some other department (usually marketing) who wants tracking, wants it now and wants it done with GTM and will whine to th C-levels until the engineers add Google Tag Manager.
> because it's my belief that "SEO" has been either nonsense bollocks - or a complete grift - since the mid-2010s

It's a continuous case of whack-a-mole. SEO consultants think <thing> would be a good way to improve the search ranking of their customers, it works, it spreads throughout the industry, Google catches on, rinse and repeat.

As soon as something is a KPI, there is incentive to game the system - with the top end of "gaming the system" toeing or crossing the line into fraudulent, anti-competitive or otherwise illegal territory.

If you're only still there because your boss believes SEO works, you better keep acting like your SEO tricks work.
It's not about actual understanding, but about pretending not to understand — because if one does, they might be out of a job. ;)
"It is difficult to get a man to understand something, when his salary depends on his not understanding it."

--Upton Sinclair

"There are none so blind as those who will not see" - John Heywood (et al.)

The follow on line from that one is even better: "The most deluded people are those who choose to ignore what they already know". I would probably want to add on things like "because it's not convenient" or similar for particular relevance to some of the stuff I've been dealing with recently at work. Folks know it's dangerous to do something a certain way, and know how to do it a safe way, but it's not as convenient so they delude themselves it'll be fine just this once. And just this once too. And just this once, once more. Slowly but surely normalising the deviance.

In the context of the Optimizely case, people know they're giving it dangerous levels of capabilities, but it's just too darn inconvenient to do it in a safe way so sure, why not. It'll be fine (and it will be, right up until it isn't and you realise your choice has compromised your users)

> it needs to become criminal

I know we really like mass incarceration in America. But maybe start with civil liability and a private right to enforcement?

Even just the process of going to court usually scares people straight even if they don't end up with any liabilities or costs.
We also get wasted Engineering time tracking down bugs caused by crap being added.
There were a couple of years before the concept of tag manager where publishers would just blindly call a JS file on their trafficker's server. This file was maintained by engineering, and you would still end up with MB of junk on every page (especially since this was before any kind of tracking regulation, wild things would happen behind the scenes). So this is more on the advertising industry itself than on wannabe devs PMs.
Beyond all the issues with third party JavaScript inclusion on sites blowing up their security perimeter, there are also significant issues with the link tracking for these as they nest and re-encode their values so much in the URLs any reasonable firewall concludes that they're some kind of obfuscation attack.
Usually they don't, they just need to fire an event with the analytics properties from the link and whatever persistent identities are available on the client side (device ID, fingerprint etc.), and then keep firing new events with at least one of those identities. The link URL or query string will have the user's canonical identities in it already.

When IDs don't persist across domains or subdomains there are also plenty of methods that don't involve passing via URL or tripping reasonable network security, and that work for >99% of user clients.

Malware ads are common even when nothing is compromised. They even happened on YouTube. I doubt anyone is reevaluating this because a lot of money is riding on getting paid to run sketchy third-party JS to monetize everything.

We get sanctimonious about this, but geeks build all that monetization infrastructure, not people from marketing.

I get beat up for six months about TTFB and then in the 11th hour, management adds half a second to FMP like none of the conversations from the last six month have mattered in the slightest. Every goddamned time.
We are indeed re-evaluating it now
this. amen
GTM is incredible, really.

I'm programming for over 30 years now and GTM is my personal #1 most hated software.

Really? Worse than IE6? I'd say it's a close call, but IE6 "wins".
Well, GTM is my #1 in living software. MSIE6 is dead. But yeah if this filter is being removed then MSIE6 takes the cake obviously.
I am sure. Marketing folks are famous about being reasonable and showing restraint, even if their revenues would suffer.
Marketing folks they were the driving force behind Adobe Flash, but the issues with that were so great that the industry did eventually get rid of it. It just takes time for the costs to become sufficiently apparent to everyone.

AI-assisted hacks and outages are accelerating the process of making the costs of weak security apparent.

The funniest part is adding GTM generally means you score low on google's pagespeed metrics through lighthouse
Just had marketing try to add all OTHER previous page events to a new event, because they didn't want to to go through the trouble of creating a dashboard using the user funnel to this feature.

They knew they could do it, and how, they just didn't want to spend 10 minutes doing it themselves. To them, asking an engineer to do it in code is easier because it only takes a minute to ask.

But the engineer doing it is doing it once rather than the marketeer doing it manually every time..
The marketer just needs to hit "Save" once.
The “insights” get product managers promoted, so it’s here to stay.

Unless we get rid of product managers, which isn’t a terrible idea.

Good luck with that.
The owners of the ad platforms end up dictating what data is used, they have the leverage and also marketing departments with power end up forcing engineering to use the audience tools Google and Meta provide. At least GTM gets blocked by ad-blockers.

We got 10MB of javascript (maybe 10 years ago...) because engineering needs to build one frontend with multi browser and multi screen support so they picked an off-the-shelf do-everything framework like Amber or Angular, or a react/redux build with 300 nested dependencies.

No, the 10MB (sometimes way more) of JavaScript for a damn news article has nothing to do with SPA frameworks (Angular) or libraries like React. It is tracking malware put there by marketing/advertising idiots.
I remember when this first became a thing when page size was important. I fought tooth and nail with marketing to try and block tag manager. I've had third party URLs block production apps in Chrome before because some marketing url was hosting malicious code.

The most infuriating thing, when you do remove these tags, marketing forgets they exist and are like "Oh we don't use that anymore".

About the "Oh we don't use that anymore.": That shows you the professionalism of the profession.

Often also true for software development, unfortunately.

Do you have an alternative to tracking malware that wouldn't involve the majority of profitable tech companies to flipping to lossmaking overnight?

I can imagine the big corporations spending millions on econometrics teams or commissioning mix modelling like the olden days, but it's pretty shit by comparison, and beyond the MNCs there's hundreds of thousands of SMEs without the money/scale and with business models that hinge on digital advertising.

Porqué no los dos? Both are true. Heavy JS frameworks, ads, trackers, etc., but also heavy web fonts, of which maybe 5 icons are used for the site, but the font weighs a megabyte. Just in case you need it.
Those were decisions at a time engineering was time constrained. All those ancillary things are returning to engineering since its just one more prompt now to manage it.