Supply chain22 Mar 2016

left-pad Unpublished from npm

A developer deleted an 11-line package after a naming dispute, and builds failed across the JavaScript world, Babel included.

Severity
Status page turned red
Difficulty
beginner
Companies
npm, Inc., Kik Interactive, Babel
Tech
npm, JavaScript, Node.js, Package registries
Root cause
dependency cascade, insecure defaults

The story

Quick (1 min)

On 22 March 2016, thousands of JavaScript projects suddenly stopped building. The cause was a tiny package called left-pad, just 11 lines of code that add spaces or characters to the start of a string.

Its author, Azer Koçulu, was in a dispute with the company Kik over the package name "kik". When npm (the JavaScript package registry) gave the name to Kik, he deleted all 273 of his packages in protest, including left-pad.

Huge projects like Babel depended on left-pad indirectly, through other packages. When they tried to install it, they got a 404 error and failed. npm took the unprecedented step of restoring the old version from a backup. The disruption lasted about two and a half hours.

The lesson: modern software is built on a deep tree of other people's packages, and one removal deep in the tree can break everything above it.

Keep reading to the end to earn XP.Read. XP earned.

Engineer (2 min)

Background. Koçulu owned the npm packages kik and left-pad, among 273 modules. Kik Interactive asked him to give up the kik name over its trademark. He refused. Under its package-name dispute policy, npm decided "kik" should be maintained by Kik.

The removal. On 22 March 2016, "without warning to developers of dependent projects, Azer unpublished his kik package and 272 other packages. One of those was left-pad" (npm). At the time, npm allowed unrestricted unpublishing.

The cascade. "Shortly after 2:30 PM (Pacific Time)... we began observing hundreds of failures per minute, as dependent projects — and their dependents, and their dependents… — all failed when requesting the now-unpublished package." Projects like Babel and Atom pulled left-pad in transitively via line-numbers, which pinned version 0.0.3.

Why the quick fix didn't work. Within ten minutes, Cameron Westland published a functionally identical left-pad as 1.0.0. But dependents explicitly asked for 0.0.3, so errors continued.

The real fix. npm took "the unprecedented step of re-publishing the original 0.0.3," restored from a backup, completed at 4:55 PM. Total disruption: about 2.5 hours.

Security angle. Several of Koçulu's other freed package names were quickly taken by other people, some with unknown code (Wikipedia). Anyone could have published malicious code under a trusted name. That's a supply chain attack waiting to happen.

Policy change. npm later blocked unpublishing a package if more than 24 hours had passed since publishing and at least one other package depends on it.

Interview takeaway: pin and vendor or mirror dependencies, use lockfiles and an internal registry proxy, and understand your transitive dependency tree.

Keep reading to the end to earn XP.Read. XP earned.

Deep dive (2 min)

Timeline (npm blog, Wikipedia)

  • 11 March 2016: Kik Interactive asks Koçulu to give up the kik package name, citing its trademark.
  • 18 March 2016: npm CEO Isaac Z. Schlueter tells both parties ownership of kik will be transferred to Kik.
  • 22 March 2016, shortly after 2:30 PM PT: Koçulu unpublishes all 273 of his modules. Hundreds of failures per minute.
  • Within ten minutes: Cameron Westland republishes a functionally identical left-pad as 1.0.0. Errors persist because dependents want 0.0.3.
  • 4:05 PM: npm announces it will restore the original 0.0.3 from backup.
  • 4:55 PM: restoration complete, about 2.5 hours after the disruption began.
  • Later: npm restricts unpublishing (no removal after 24 hours if anything depends on the package).

Who was affected

Wikipedia lists dependents including Babel, Webpack and React-related projects, and companies including Meta, PayPal, Netflix, Spotify and Kik itself.

npm's own assessment

"It was abrupt unpublishing, not our resolution policy, that led to yesterday's disruptions." (npm)

"Unrestricted un-publishing caused a lot of pain... npm needs safeguards to keep anyone from causing so much disruption." (npm)

npm also said poor communication during the incident made things worse, and that the other 272 affected modules were adopted by community members who republished forks or created placeholder packages to prevent malicious publishing.

Why it's in the supply chain category

No attacker was involved, but it exposed the mechanics later exploited by real supply chain attacks: deep transitive trees, trust in package names, and registries that let names change hands.

Keep reading to the end to earn XP.Read. XP earned.

Failure replay

Step by step, what broke and what it hit next.

  1. Mar 11–18
    Name disputedegraded

    Kik claims the "kik" package name over its trademark, and npm transfers it to Kik.

    Affects: Author's packages

  2. Mar 22, ~2:30 PM PT
    Author's packagesdown

    In protest, the author unpublishes all 273 of his packages, including the 11-line left-pad.

    Affects: left-pad 0.0.3

  3. ~2:30 PM
    left-pad 0.0.3down

    Packages like line-numbers request exactly version 0.0.3, which now returns 404.

    Affects: Babel and Atom builds

  4. ~2:30 PM
    Babel and Atom buildsdown

    Transitive dependents fail to install. npm sees hundreds of failures per minute.

    Affects: Developers

  5. +10 min
    Community republishdegraded

    A developer republishes an identical left-pad as 1.0.0, but builds still want 0.0.3.

    Affects: left-pad 0.0.3

  6. 4:55 PM
    left-pad 0.0.3recovering

    npm takes the unprecedented step of restoring the original 0.0.3 from backup. Builds recover.

    Affects: Babel and Atom builds

  7. Later
    Developershealthy

    npm restricts unpublishing of packages that others depend on.

Impact

Who was affected
Many thousands of JavaScript projects depending directly or transitively on left-pad, including Babel, Atom and Webpack users.
How long
About 2.5 hours (from shortly after 2:30 PM PT to 4:55 PM PT on 22 March 2016).
Cost
not disclosed

Lessons

  • Tiny dependencies deep in the tree can break everything above them.
  • Registries shouldn't allow removal of packages others depend on.
  • Use lockfiles plus an internal mirror or proxy so builds don't depend on the public registry staying unchanged.
  • Freed package names are a supply chain risk; anyone could publish under a trusted name.

Quiz

  1. Why did left-pad disappear from npm?

    Check answer

    Its author unpublished all his packages in protest after npm gave the "kik" name to Kik. Azer Koçulu unpublished 273 packages after the naming dispute.

  2. Why didn't the community's republished left-pad 1.0.0 fix things immediately?

    Check answer

    Dependents like line-numbers explicitly requested version 0.0.3. npm had to restore the original 0.0.3 from backup.

  3. How long did the disruption last?

    Check answer

    About 2.5 hours. npm completed the restoration at 4:55 PM PT, about 2.5 hours in.

  4. What policy did npm change afterwards?

    Check answer

    Packages can't be unpublished after 24 hours if another package depends on them. The rule stops one person removing a widely used dependency.

Interview prep

Try answering out loud before you open the model answer.

  1. system design

    How would you make your company's builds resilient to a package disappearing from a public registry, as in left-pad?

    Show model answer

    Use lockfiles with exact versions and integrity hashes so builds are reproducible. Route installs through an internal registry proxy or mirror (Artifactory, Nexus, Verdaccio) that caches every version you've used, so upstream deletion doesn't break you. For critical apps, consider vendoring dependencies. Monitor and minimise dependency trees, and alert when a dependency is removed or changes ownership.

    A strong answer hits:

    • Lockfiles with integrity hashes
    • Internal registry proxy or cache
    • Vendoring for critical paths
    • Monitor dependency ownership and removal
  2. security

    left-pad wasn't an attack. Why is it still considered a supply chain security lesson?

    Show model answer

    It showed how much code depends on packages controlled by individuals, how deep transitive trees are, and that package names can change hands. After the unpublish, other people took over some of the author's freed names, and anyone could have published malicious code under a name that thousands of builds would pull automatically. Later real attacks (event-stream, ua-parser-js, npm worms) used exactly these mechanics. Defences include pinning, integrity checks, provenance and monitoring for ownership changes.

    A strong answer hits:

    • Concentrated trust in individuals
    • Freed names can be hijacked
    • Same mechanics as later attacks
    • Pinning, integrity, provenance
  3. behavioural

    Your team wants to add a small npm package for a one-line utility. How do you decide?

    Show model answer

    Weigh cost against risk. If it's trivial (like padding a string), writing it yourself or using a standard library function avoids a new dependency and its whole tree. If it's complex or security-sensitive, a well-maintained package is better than rolling your own. Check maintainers, activity, dependency count and download stats. Note that modern JavaScript added String.prototype.padStart, which covers left-pad's job.

    A strong answer hits:

    • Cost vs risk of each dependency
    • Prefer standard library for trivial code
    • Evaluate maintenance and transitive deps

Go deeper