A dependency graph visualisation showing a compromised package deep in the transitive dependency tree, with an attack path traced in orange back up to the root application.

The dependency you didn't write

Modern web architectures routinely execute code written by strangers, served from infrastructure no development team controls. The conservative alternative is not a regression — it is a structural choice about where trust is placed.

On 25 June 2024, the domain polyfill.io changed hands. The original maintainer had sold the domain and GitHub organisation to Funnull, a Chinese CDN operator. Within hours, the CDN began serving malicious JavaScript to visitors of the 100,000-plus websites that had included a polyfill.io script tag in their HTML. The payload redirected mobile users to unrelated third-party sites. Some of the affected sites were major global brands. None of them had changed a line of their own code.

No CVE was filed in advance. No version was bumped. No lockfile changed. The attack vector was not a vulnerability in anyone's application — it was the architecture itself: the practice of pointing a script tag at a third-party CDN and trusting that whatever the CDN served would be benign.

This was not an isolated incident. It was the clearest example yet of a pattern that had been building for years.

How the dependency graph became unauditable

event-stream · November 2018
A package with 1.8 million weekly downloads changed ownership. The new maintainer added flatmap-stream as a dependency — a package containing encrypted malicious code targeting the Copay cryptocurrency wallet. The exploit was invisible to security scanners and was discovered by accident, six weeks after publication.
ua-parser-js · October 2021
The npm account was compromised and three malicious versions published in rapid succession, each containing a cryptominer and a credential stealer. Automated CI pipelines across the ecosystem had already installed and executed them before the packages were taken down.
colors.js · January 2022
The sole maintainer deliberately corrupted the package in protest at unpaid open-source labour. Thousands of applications broke in production with no warning and no upstream patch available.
xz-utils · March 2024
A persona known as Jia Tan spent two years building maintainer trust through small legitimate contributions, then inserted a backdoor into versions 5.6.0 and 5.6.1 targeting SSH authentication on systemd-linked Linux systems. Caught only because a Microsoft engineer noticed anomalous login latency during routine performance testing.

These are not edge cases or freak events. They are the repeating pattern of an ecosystem where trust is implicit, ownership transfers freely, and the volume of code involved makes meaningful audit impossible.

The surface area in numbers

Install a standard JavaScript framework and you inherit its entire dependency tree — the vast majority of which is transitive, packages that are pulled in by other packages. A development team implicitly trusts the authors of every node in that tree, most of whom they have never heard of, and none of whom they have a contractual relationship with.

~1,400 packages Create React App
~950 packages Next.js
5–15 packages Go server

npm hosts approximately 2.5 million published packages as of 2024. Any one of them can be transferred to a new owner without notification to dependents. Most are maintained by a single person with no security team, no formal review process, and no obligation to any of the applications that depend on them. The registry does not vet ownership transfers.

A Go web server performing equivalent work — HTTP routing, database access, HTML template rendering — typically carries five to fifteen direct dependencies, all auditable in an afternoon. The Go standard library covers TLS, HTTP/2, JSON encoding, cryptography, and templating without requiring external packages. The smaller surface area is not the product of better security practices — it is the product of less untrusted code being present.

Why client-side architectures are structurally more exposed

The polyfill.io attack was effective because the malicious code ran in users' browsers. It had access to the full DOM, all visible form inputs, session storage, and the ability to make arbitrary network requests. A compromised package in client-side JavaScript operates in the most privileged environment available to an attacker: the browser context, directly in front of the user, with full read access to everything the page contains.

Server-side code operates in a fundamentally different environment. A compromised package running on a server produces log entries, triggers monitoring alerts, and operates behind access controls the team has configured. It cannot directly access a user's browser storage. It cannot silently intercept form submissions before they are processed — all data passes through server-side validation first. The server is observable. The browser is not.

A Content Security Policy reduces browser-side risk but does not eliminate it. A CSP blocks injected inline scripts and restricts which origins can load resources — but if the compromised code is served from a trusted origin, the CSP passes it through unchanged. The polyfill.io attack served malicious JavaScript from the same domain that affected applications had explicitly whitelisted in their policy. The security control and the attack vector were pointed at the same origin.

What conservative architectures do differently

The conservative choice — server-side rendering, minimal client-side JavaScript, explicit dependency selection — is not primarily a performance or simplicity decision. It is a trust boundary decision. The question it answers is: how much code written by people outside your organisation will execute in environments you cannot observe?

In a server-authoritative architecture, the code that executes in response to a user request runs on infrastructure the development team controls, in a process the team can observe, against logs the team has configured. Client-side code is limited to what the server explicitly sends in the response body. The browser executes HTML, a small amount of carefully chosen JavaScript, and nothing that arrives from a third-party CDN at runtime.

This does not eliminate supply chain risk. Server-side dependencies can be compromised. Go modules are not immune to the class of attacks described here. But the explosion in attack surface that occurs when an application ships hundreds of third-party packages to every browser — from CDNs it doesn't operate, executing code it cannot observe — does not occur.

PHP applications from 2005 rarely had more than five or six external dependencies, all installed server-side. They were slow, and that slowness was a genuine constraint that justified moving logic into the browser. The web development community solved the latency problem — largely by 2016 — while simultaneously acquiring a supply chain liability the original architecture simply did not have. The latency constraint expired. The liability did not.

The supply chain attack exploits the implicit trust that package installation establishes between a development team and an unbounded set of strangers. Client-side architectures extend that trust to the browser, where untrusted code executes in front of the user with full DOM access and no server-side visibility.

The practical posture

No architecture eliminates supply chain risk entirely. The decisions that reduce it are structural:

  • Keep the number of dependencies small enough to audit. A package.json with forty direct dependencies has not been audited — it has been accepted.
  • Vendor dependencies where possible. Code copied into your repository under your version control cannot be silently updated by a third party.
  • Never load JavaScript from third-party CDNs at runtime. If the origin is not yours, you do not control what it serves.
  • Treat client-side JavaScript as the highest-risk execution environment. Code running in the browser runs in front of your users with no server-side observation and no interception layer.
  • Prefer architectures that keep application logic on the server. Not because the server is immune to supply chain attacks, but because server-side execution is observable, logged, and mediated.

The infrastructure argument for moving application logic into the browser was server latency. In 2026, a Go server handling a typical CRUD request returns a rendered HTML response in one to five milliseconds. A round-trip to a well-placed regional server adds fifteen to eighty milliseconds of network time — below the threshold of perceptible delay for most interactions. The original justification no longer holds.

What remains after the latency justification is removed is an architectural choice about trust: how much code written outside your organisation will execute in front of your users, in an environment you cannot monitor. Conservative architectures make that amount as small as possible. The supply chain liability they avoid was never an inevitable cost of building for the web — it was an artefact of a constraint that no longer exists.

Read the full argument