Compromised maintainer accounts: a trusted package with an untrusted release

When a maintainer’s registry account is taken over, a new release of a trusted package can carry malicious code. How to notice unusual releases, use provenance and trusted publishing, and pin versions so updates are deliberate.

Lesson 19 of 26 · 10 min read · practice only with authorization

Diagram

An unexpected release

Follow the path. One example at a time.

Step 1 of 4

Release

A popular package publishes a patch release outside its usual pattern.

Illustration: Release
version  published            publisher        provenance
4.2.1    2026-08-02 14:10     ci (trusted)     yes
4.2.2    2026-10-31 03:12     jdoe (token)     no

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Provenance gaps

    What fails
    A release without provenance from a package that usually has it.
    Who is affected
    All consumers.
    What you would notice
    Publisher changes from CI to a personal token.
    What you change
    Verify provenance and alert when it disappears.
  2. Floating ranges

    What fails
    Caret and tilde ranges accept new releases automatically.
    Who is affected
    Projects without lockfile installs.
    What you would notice
    npm install in CI instead of npm ci.
    What you change
    Install from lockfiles and update through reviewed PRs.
  3. Instant adoption

    What fails
    Bots that update the moment a release appears.
    Who is affected
    Everyone downstream.
    What you would notice
    Updates merged within hours of release.
    What you change
    Add a minimum release age to update bots.

Reading a release diff

Compare the published tarball, not just the repository, because a hijacked release may not match any commit.

$ npm pack example-lib@4.2.1 example-lib@4.2.2
$ mkdir a b && tar -xzf example-lib-4.2.1.tgz -C a && tar -xzf example-lib-4.2.2.tgz -C b
$ diff -r a/package b/package | head
Only in b/package: lib/telemetry.min.js
<   "scripts": {"test": "jest"}
>   "scripts": {"test": "jest", "postinstall": "node lib/telemetry.min.js"}

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A trusted package’s new release has no provenance and a new postinstall script. What do you do?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.

Glossary

  1. CardCompromised maintainer accountA legitimate package publishes a malicious update because the maintainer's account was stolen.