Supply chain attacks: how a compromised package or script reaches your website, and what to do first
A supply chain attack reaches a website through code you trust but did not write: a package your build installs, a step in your pipeline, or a script your pages load from someone else's server.
This guide explains each route at the level a defender needs to recognise it, the signals that give one away, and what you and your developers, or your incident responder, do in the first days. It comes with a provenance worksheet and a response timeline you can copy.
In this guide
Package-release provenance worksheet and compromise response timeline
Copy this into a document or ticket. Part A has one block for each dependency that matters, Part B one for each script the browser loads from another server, and Part C covers the build.
How to use itHide the instructions
Part D is the response timeline for the first days after you learn a dependency or script was compromised, and Part E is an invented example filled in. Fill every line from evidence such as the lockfile, the registry page or a build log.
supply-chain-attacks.txt
Introduction8 lines
Part A. One block per package21 lines
Part B. One block per script the browser loads from another server12 lines
Part C. The build and the artefact it produces6 lines
Part D. Compromise response timeline47 lines
Part E. Worked example (illustration)30 lines
Whole template139 lines
PACKAGE-RELEASE PROVENANCE WORKSHEET
Application: (name and address)
Commit or build checked: (commit hash, build number or image digest)
Package manager and version: (output of npm --version or pnpm --version on the build runner)
Completed by: (name and role) Date: (date)
Which entries to fill: every package your own code imports directly, every package the lockfile flags with an install script, every package that handles sign-in, payments, file uploads or secrets, the build steps in Part C, and every script your pages load from a domain you do not control. Fill each line from evidence (the lockfile, the registry page, a build log) and write "unknown" rather than leaving a line blank. An unknown is a finding.
PART A. ONE BLOCK PER PACKAGE
A1. Package and job: (name; what it does in this application; runtime, build only or development only)
A2. Locked version: (exact version in the lockfile of the deployed commit)
Resolved from: (the resolved address in the lockfile; is it the registry you intend? yes / no)
Integrity hash recorded in the lockfile: (yes / no)
A3. Who can publish it: (owners the registry lists today, from npm owner ls)
Source repository: (address linked from the package page)
A4. Latest release: (version, and its publish time from the time field in npm view)
What changed: (one line from the release notes or the source diff; "no notes and no matching commit" is an answer)
Change of maintainer: (anyone added to or removed from the owner list since the release you run? yes / no / unknown; if yes, who and when)
A5. Install scripts: (does the lockfile mark this version hasInstallScript? yes / no)
Did the latest release add one? (yes / no)
Allowed to run: (listed in allowScripts or allowBuilds, by exact version or by name? not applicable if there is no script)
Why it needs one: (for example, a native module compiled on the machine that installs it)
A6. Lockfile pin: (does every workflow install with npm ci or a pnpm frozen-lockfile install? yes / no; name any that do not)
Installed tree matches the lockfile: (did the last CI install finish without changing the lockfile? yes / no; build number)
A7. Provenance: (does the locked version show provenance on its registry page? yes / no; did earlier releases? yes / no)
Source commit and build file named in the provenance: (links)
npm audit signatures result: (no errors / errors listed; date run)
A8. Release-age delay in force: (min-release-age or minimumReleaseAge value, or none)
A9. Decision: (keep / pin to an exact version / replace / remove)
Owner: (role) Look again when: (trigger, such as a new major version or a change of maintainer)
PART B. ONE BLOCK PER SCRIPT THE BROWSER LOADS FROM ANOTHER SERVER
B1. Script and job: (what it does; every page that loads it, marking sign-in, account, checkout and form pages)
B2. Address in the script tag: (full address)
B3. Who controls the copy visitors receive (tick one):
( ) our own domain: it changes only when we deploy
( ) the vendor's live file: it changes when the vendor, or whoever controls the vendor's server, changes it
( ) a tag manager: it changes when anyone with publishing access changes it
B4. Who can change it: (vendor; tag manager users by role; developers)
B5. Integrity attribute: (sha256, sha384 or sha512 hash present, with crossorigin set? yes / no; if no, why not)
B6. Content Security Policy: (is this host in script-src? yes / no; enforced or report-only; where reports go and who reads them)
B7. What it can reach: (form fields, payment fields, tokens or personal details on the pages that load it)
B8. Vendor commitments: (does the contract say how the vendor controls and monitors changes to this script? yes / no)
B9. Decision: (keep / self-host a reviewed copy with an integrity hash / isolate in an iframe on another domain / remove from sensitive pages / remove)
PART C. THE BUILD AND THE ARTEFACT IT PRODUCES
C1. Build service and file: (CI service; path of the workflow or pipeline file)
C2. Install command in each workflow: (npm ci / pnpm install with a frozen lockfile / other, named)
C3. Third-party build steps: (each action or plugin, and how it is referenced: lockfile, full commit SHA, tag or branch)
C4. Secrets the install and build steps can read: (names only, never values; which steps need each)
C5. Deployed artefact identity: (image digest or build number recorded for each deployment? where it is kept)
C6. Provenance of your own artefact: (signed or attested? where the record is kept)
PART D. COMPROMISE RESPONSE TIMELINE
Start here. Is the live site serving the attacker's code to visitors now, does an attacker still seem to be active, or may customer data have been taken? If any answer is yes, call your host and an incident response specialist first, check whether your insurance policy asks you to call the insurer before engaging anyone, and let the specialist's instructions override this list.
First hour: freeze, without wiping anything
[ ] Start an incident log: the time, where the news came from (advisory, alert, vendor email), the package or script, and the versions named as bad. Add every later step with its time and who did it.
[ ] Pause deploys, scheduled builds, automated dependency update pull requests and auto-merge.
[ ] Do not run npm install, npm ci or a cache clean on any machine that may hold a bad version. npm ci deletes node_modules before it installs.
[ ] Copy, from each affected machine and runner you can reach: node_modules, the lockfile, the package manager cache, the CI logs and the identity of the deployed artefact. Label each copy with the machine, the time and who took it, and store it where nothing will run it.
[ ] For a browser script: save the file the vendor is serving now, and any earlier copy you hold.
First day: which versions ran, where and when
[ ] Read every lockfile (each branch, each deployment, each service) and record the version of the affected package in each, including nested copies.
[ ] Search caches, artifact repositories and container images for the bad versions.
[ ] From version control history, record when a bad version entered and left each lockfile.
[ ] From the registry, record when each bad version was published. From CI logs, record every install that ran after that time.
[ ] List every machine that installed it: developer laptops, CI runners, build servers, preview environments.
[ ] For a browser script: list the pages that load it and the period the changed file was served.
[ ] Write down the exposure window: (earliest possible install or page load) to (latest).
First day: secrets
[ ] List every credential readable on each affected machine or runner during the window: registry tokens, repository tokens, cloud keys, deployment keys, database connection strings and API keys in environment files.
[ ] Remove the bad version from a machine or pipeline before rotating anything from it.
[ ] Rotate each listed credential, revoke the old value, and check each provider's access logs for use during the window.
[ ] If a secret appears in a CI log: rotate it first, copy the log lines you need for the record, then delete the log.
[ ] For a browser script: list what its pages collected during the window (form fields, payment fields, session tokens).
Days two and three: tell
[ ] Your developer, agency and host, and everyone with access to the tag manager or the package registry account.
[ ] Your insurer, before engaging a responder if the policy asks for that.
[ ] Your payment provider, if the script ran on a checkout or payment page.
[ ] A privacy lawyer, if personal information could have been read. Ask whether the Notifiable Data Breaches scheme applies.
[ ] ASD's ACSC, through its report page, if you decide to report a cyber security incident.
[ ] npm Security, through Report malware on the package page, if no advisory exists yet. List every affected version.
[ ] Customers, only after taking advice, so that what you say matches what you found.
Days two and three: restore from a known-good state
[ ] Choose the restore point: the last lockfile commit before the bad version arrived, or an exact pin to a release published before it.
[ ] Rebuild on a clean runner with npm ci or a pnpm frozen-lockfile install, so the build fails if the lockfile and package.json disagree.
[ ] Run npm audit signatures on the rebuilt tree and record the result.
[ ] Deploy a new artefact. Do not redeploy an image or bundle built during the exposure window.
[ ] For a browser script: remove it, or serve a reviewed copy from your own domain with an integrity hash.
[ ] Confirm the bad version appears nowhere in the deployed artefact before automated updates are switched back on.
Before you close it
[ ] Keep the pin until a release you have reason to trust is published.
[ ] Record what changed: install-script allow list, release-age delay, narrower build secrets, scripts moved to your own domain.
[ ] Update Parts A to C for the affected package or script.
[ ] Keep the copies, logs and incident log for as long as your lawyer or insurer advises.
PART E. WORKED EXAMPLE (ILLUSTRATION)
An illustration written for this page. It is not a real incident or a client, and the shop, packages, versions and times are invented.
The site: shop.lab.test, a Next.js storefront built with npm 11 on a hosted CI service and deployed as a container image. Every workflow installs with npm ci. A bot opens automated dependency update pull requests, and every pull request gets a preview deployment.
Part A, the image-resizing package
A1. Resizes product photos in an API route. Runtime.
A2. Locked version 3.4.1 on the production commit, resolved from the public npm registry. Integrity hash recorded: yes.
A3. Two owners on the registry at the last check. Source repository linked from the package page.
A4. Latest release 3.4.2, published Tuesday 02:10. No release notes and no matching commit in the source repository. Change of maintainer: yes, a third owner who was not on the list at the last check.
A5. 3.4.1 is marked hasInstallScript because it compiles a native module. 3.4.2 adds a postinstall script that 3.4.1 did not have. The project has no allowScripts list, and npm 11's documentation says unreviewed install scripts run with a notice.
A6. All workflows use npm ci. At 09:40 the bot opened a pull request moving the lockfile to 3.4.2, and the preview workflow installed and built it.
A7. 3.4.1 shows provenance; 3.4.2 does not. npm audit signatures had not been run.
A8. No release-age delay.
A9. Decision: pin to 3.4.1; approve its install script by exact version so a later release's script is not approved with it; set a release-age delay; review lockfile diffs on bot pull requests before preview builds run. Owner: lead developer.
Part B, the chat widget
B1. Loaded on every page, including checkout.
B3. The vendor's live file.
B5. No integrity attribute, because the vendor updates the file in place.
B6. The vendor's host is in script-src, and violation reports go to an address nobody reads.
B9. Decision: remove from checkout and account pages, ask the vendor for a versioned file, and route reports to a monitored inbox.
Part D as it ran
Tuesday 14:00. A malware advisory names 3.4.2. Incident log started. Preview and production workflows paused, bot pull requests closed without merging.
Tuesday 14:20. The preview runner's working directory and npm cache copied before anything was reinstalled. CI logs for Tuesday exported.
Tuesday 15:30. Lockfiles read on every branch: production on 3.4.1 throughout; only the bot's branch on 3.4.2, from 09:40. The production image was built on Monday, before 3.4.2 was published.
Tuesday 16:00. Secrets readable by the preview workflow listed: a preview deployment token, a preview database connection string and a registry read token. Runner image replaced, each secret rotated from the clean pipeline, old values revoked, provider logs checked for use between 09:40 and 16:00.
Wednesday. Insurer called, host and team told. The preview database held only seeded test data, which was recorded for the lawyer's question about personal information. An advisory already existed, so no new malware report was needed.
Wednesday afternoon. Preview rebuilt from the Monday lockfile with npm ci on a clean runner. npm audit signatures run and recorded. New preview image deployed.
Thursday. Install-script allow list and release-age delay added, worksheet updated, bot pull requests switched back on.What a supply chain attack is
A supply chain attack does not break into your code.
It changes something your code depends on, so that the next install, build or page load delivers the attacker's code under a name you already trust. The change happens upstream, in a package registry, a maintainer's account, a build service or a script host, and it reaches you through the same channels you use to stay up to date.
OWASP files this under A03:2025 Software Supply Chain Failures, which it describes as breakdowns or other compromises in the process of building, distributing or updating software, often caused by vulnerabilities or malicious changes in third-party code, tools or other dependencies. Two different problems sit inside that definition.
A vulnerable component is an honest mistake: a bug with an advisory and a fixed release, which the dependency security guide deals with. A compromised component is a deliberate change: a release, build step or script altered to do harm. This guide is about the second kind.
For a website or web application, the supply chain has five links worth naming. Each is a place where a change made by someone else can become part of what your visitors receive.
- Packages: everything in the lockfile, including the packages your packages depend on. OWASP's A03 guidance counts nested, or transitive, dependencies as part of what you need to track.
- Install-time code: scripts a package runs on the machine that installs it, before your application has started.
- The build: the CI service, its third-party steps and the secrets it holds, which together turn your repository into something deployable. The CI/CD security guide covers hardening it.
- The artefact: the bundle or image that is actually deployed, which can differ from your repository if the build that made it was tampered with.
- Browser scripts: analytics, chat widgets, tag managers, booking and payment widgets that each visitor's browser fetches from another server on every page load.
How an upstream compromise reaches your site
Each route below is described at the level you need to recognise it in your own setup.
None of them needs an attacker to touch your server. A software bill of materials, which has its own guide, is the inventory that tells you whether a reported compromise involves a component you run.
Anyone listed as a package's owner can publish a new version. npm's documentation for its owner command says an added maintainer can modify metadata, publish new versions and add other owners, and that there is only one level of access. Whoever controls one of those accounts, or a publishing token for it, can ship a release that looks exactly like a routine update.
npm's threats page calls compromising passwords the most common attack, on npm and on any web service, and describes a second route into an account: registering the expired email domain behind it, then resetting the password of an account without two-factor authentication. Publishing now needs either two-factor authentication or a granular access token with its bypass-2FA option enabled, and npm's default package setting accepts both.
The stricter setting, which npm marks as recommended, requires an interactive publish with a two-factor prompt and refuses granular access tokens.
The release reaches you through your version ranges. In package.json, a range such as ^1.0.4 accepts minor releases. npm install keeps the exact versions in package-lock.json while they satisfy those ranges, but resolves new versions and updates the lockfile when they do not, so a change that triggers fresh resolution can bring in a matching release however recently it was published. npm ci never writes to package.json or the lockfile, and exits with an error when the two disagree, which is why it belongs in builds.
This is the route the npm worm of September 2025 used. On 22 September 2025, GitHub wrote that it had been notified on 14 September of the Shai-Hulud attack, a self-replicating worm that infiltrated the npm ecosystem via compromised maintainer accounts by injecting malicious post-install scripts into popular JavaScript packages.
GitHub said it removed more than 500 compromised packages from the registry, and that npm blocked uploads of new packages containing the malware's indicators of compromise. CISA's alert of 23 September 2025 adds that, after gaining initial access, the actor deployed malware that scanned the environment for credentials, targeting GitHub personal access tokens and API keys for AWS, Google Cloud Platform and Microsoft Azure.
The malware sent what it harvested to an endpoint the actor controlled, and spread by authenticating to npm as the compromised developer, injecting code into other packages and publishing compromised versions.
Ownership also changes for ordinary reasons: a maintainer hands a project on, or a company takes one over. A release from someone newly added deserves the same reading as a new dependency, because the new owner controls every release after it. npm owner ls lists everyone who can currently publish, which makes the change easy to record and compare.
Some attacks need no stolen account. npm's threats page describes typosquatting, registering a name close to a popular package in the hope that someone mistypes or confuses the two, and says npm can detect typosquats and block them from being published. It also describes dependency confusion, where a public package is registered under the same name as a private package an organisation is using. npm says it is not able to detect dependency confusion attacks, and strongly encourages scoped packages so that a private package is not substituted with one from the public registry.
GitHub says the malware advisories in its Advisory Database are mostly about this kind of substitution, and that users whose dependencies are appropriately scoped should not be affected. Package names suggested by AI coding assistants raise a related problem, and the secure code review guide covers how a review checks them.
A package can declare lifecycle scripts, such as preinstall, install and postinstall, that run on whatever machine installs it: a developer's laptop, a CI runner or a build server. That machine can hold cloud keys, repository tokens and registry tokens: the kinds of secret that GitHub and CISA say the 2025 npm malware went after.
npm's own best-practice note says the only valid use of install or preinstall scripts is compilation that must be done on the target architecture. pnpm's documentation goes further, saying that historically most compromised packages have used postinstall scripts to run code immediately on installation.
Whether those scripts run depends on the package manager and its version, so check rather than assume. pnpm does not run dependency build scripts unless the package is listed in allowBuilds, and with strictDepBuilds, which is on by default, the install fails when an unlisted dependency has one. npm's version 12 documentation says dependency install scripts are blocked by default: they are skipped, and the install ends with a list of the skipped packages to review with npm approve-scripts.
Its version 11 documentation describes unreviewed scripts running with a notice instead.
In both versions, strict-allow-scripts turns the policy into a hard error, and ignore-scripts stops npm running scripts specified in package.json files.
Blocking install scripts closes one door, not every door. A package's ordinary code still runs when your build or your application imports it, and OWASP notes that components typically run with the same privileges as the application itself.
Your pipeline is part of the supply chain too. GitHub's security guidance for Actions warns that jobs in a workflow can interact with and compromise each other, so a compromised third-party action would have access to all secrets configured on the repository and may be able to use the GITHUB_TOKEN to write to it.
A tag on an action can be moved or deleted if a bad actor gains access to the action's repository. GitHub calls a workflow dependency lockfile the strongest protection available, and for repositories that cannot adopt one, advises pinning each action to a full-length commit SHA.
OWASP's A03 guidance lists a CI/CD pipeline with weaker security than the systems it builds and deploys among the signs you are likely vulnerable, and asks for artefacts whose integrity can be shown through provenance, signing and time stamping. The CI/CD security guide covers the pipeline itself. For this page, what matters is that a third-party build step can reach the secrets and source your build holds.
Every script tag that points at another domain gives that domain a say in what your visitors run. OWASP's Third Party JavaScript Management Cheat Sheet names a compromise of the third-party JavaScript server, with malicious code injected into the original tag, as the single greatest risk. It notes that third-party code runs with the same privileges as the user, much like cross-site scripting, that there is usually no guarantee the hosted code will stay the same as the code your developers and testers saw, and that any testing done before production loses some of its validity.
Two further routes need no break-in at the vendor. A tag manager returns whatever its users have configured, and OWASP notes those scripts can be changed through the tag manager's own interface by staff such as the marketing team, without any change to your site's code.
And a vendor's domain can expire and be re-registered by someone who then serves their own code from the address your pages still request.
MDN's Subresource Integrity documentation states the general case: an attacker who gains control of a third-party host can inject malicious content into its files or replace them completely, which MDN calls a supply chain attack.
How you would notice a compromised dependency
Detection comes from two directions.
Some signals arrive from outside, as an advisory, an alert or a vendor notice. Others sit in files you already have, but only help if someone reads them when they change.
Outside signals tell you that something is wrong somewhere. Your own records then tell you whether it reached you.
- A malware advisory. GitHub publishes malware advisories into its Advisory Database automatically from the npm security team and the OpenSSF Malicious Packages repository. With malware alerts enabled, Dependabot raises an alert when malware is detected, and a search for type:malware lists the advisories.
- A registry action. npm says that for each confirmed malware report it removes the package, publishes a security placeholder and publishes a security advisory. A version that has disappeared from the registry, or been replaced by a placeholder, is a reason to check before anyone reinstalls.
- A government alert, such as CISA's September 2025 alert on the npm compromise, or a notice from a vendor whose script your pages load.
- A signature check. npm audit signatures checks registry signatures and provenance attestations, and returns an error when either is missing or invalid, which npm says could indicate the package has been tampered with.
These signals depend on someone reading changes as they happen, which is cheapest in the pull request that makes them.
- A lockfile diff you did not expect. package-lock.json records, for each package, the address it was resolved from and an integrity hash of what was unpacked, and npm lists readable diffs of tree changes among the lockfile's purposes. Read for packages nobody added on purpose, a resolved address that points somewhere other than your registry, and an integrity hash that changed while the version did not.
- A new install script. The lockfile flags packages that have a preinstall, install or postinstall script with hasInstallScript. A dependency that gains the flag in an update is exactly the case pnpm's allowBuilds advice is designed for: a package that never needed a build should not start running one unannounced.
- A blocked or failed install. A pnpm install that fails under strictDepBuilds means a dependency has a build script that is not allowed, and an npm 12 install that ends by listing skipped scripts names the packages whose scripts nobody has approved. Find out whether it had that script before.
- A release that lost its provenance. A package page on npm shows a green check mark when a version was published with provenance. A new release without one, from a package whose earlier releases carried it, deserves a closer look, and pnpm's trustPolicy setting, set to no-downgrade, fails the install when a package's trust evidence drops below that of its earlier releases.
- An owner you have not seen before on the package, or an owner list that changed since your last update.
- A build that behaves differently, such as an install step that reaches unfamiliar hosts. CISA's recommendations after the 2025 npm compromise included monitoring for anomalous network behaviour and blocking outbound connections to webhook.site domains.
- Browser reports. A Content Security Policy violation report records what was blocked and under which directive, as MDN's example report shows, and a script that fails its Subresource Integrity check is refused with a network error. Customers reporting card fraud after buying from you, or a checkout that behaves differently, belong on this list too.
What signatures, provenance and trusted publishing prove
Registry tooling now answers some provenance questions, and it pays to be exact about which ones. npm signs packages published to its public registry so that tampering with the package content can be detected.
That protects against an attacker who controls a registry mirror or proxy and alters a package on its way to you. A registry signature does not tell you whether the maintainer meant to publish that release.
Provenance answers a different question: where and how a version was built. npm's provenance attestation links a package to the source code and build instructions that produced it, and its publish attestation records that an authorised user published it. npm is explicit that provenance does not mean the package is free of malicious code; it gives you a verifiable link to the source and build that you can audit before deciding to trust it.
If a malicious change was committed to the source repository and built by the project's own workflow, the provenance is accurate and the package is still malicious.
Trusted publishing replaces long-lived npm tokens in the publishing workflow with short-lived tokens specific to that workflow, issued through OpenID Connect. When a public package is published through trusted publishing from a public repository on GitHub Actions or GitLab CI/CD, npm generates provenance automatically unless the publisher turns it off.
Trusted publishing does not close the other doors by itself: npm accepts trusted publishes in addition to token publishes and interactive publishes by a maintainer, and recommends selecting the setting that requires two-factor authentication and disallows tokens once trusted publishing is set up.
Even then, a maintainer can still publish interactively with a two-factor prompt. A release that arrives without provenance from a project that normally has it is a question to ask, not a formality.
A delay buys time for someone else to notice. npm's min-release-age setting installs only versions that have been available for more than a given number of days, and pnpm's minimumReleaseAge, which defaults to 1440 minutes (one day), does the same in minutes. The cost falls on urgent fixes too. npm's documentation says that when the window stops npm audit fix from installing a patched version, npm keeps the vulnerable version, warns and exits with a non-zero code, and a package listed in min-release-age-exclude can skip the delay.
The third-party script supply chain
Packages are checked when you build.
Browser scripts are fetched when someone visits, by every visitor, from whoever controls the address in the script tag. That changes which controls fit.
Start with who controls the copy. A script served from your own domain changes only when you deploy, and OWASP lists in-house mirroring of third-party scripts among its typical defences, to prevent alterations by the third party.
A script fetched live from the vendor changes whenever the vendor, or whoever controls the vendor's server, changes it. A script added through a tag manager changes whenever someone with publishing access to the tag manager publishes.
Subresource Integrity lets the browser check a file against a hash in the script tag's integrity attribute, and refuse it with a network error when the content differs. It works on script elements and on stylesheet, preload and modulepreload links, and a file from another origin needs CORS from its host and the crossorigin attribute on the tag.
Because the hash pins exact content, it suits a versioned file.
On a vendor file updated in place, OWASP points out the other side: a vendor update can leave you with secure but non-working code, so vendor scripts need watching for changes either way.
A Content Security Policy controls which resources a page may load. Its script-src directive sets the allowed sources for JavaScript, and a violation report records what was blocked. MDN describes report-only mode for trying a policy without enforcing it, and recommends the report-to directive for reports while still declaring the deprecated report-uri until every browser supports report-to.
A policy that allows a script because of the host it comes from does not look at the file itself, so a changed file served from a host you already allow still passes; the content check is Subresource Integrity.
What the policy adds is a block, and a report where reporting is set up, when a page tries to load script from a source the policy does not list.
For scripts that only need to show something, OWASP describes isolating them in an iframe served from a different domain, where the vendor code has no direct access to the host page's DOM or cookies. For vendors you cannot isolate, its advice extends to the contract: agreements that cover how the vendor monitors and controls its own source code to prevent and detect malicious changes to its JavaScript.
Begin with the pages that collect passwords, payment details or personal information. A third-party script on those pages runs with the same privileges as the visitor, on the same page as what they type, so each one should have a reason to be there and an owner who can say who controls it.
Package compromise response: the first days
The first news of a compromised dependency or script may be an advisory, an alert or a vendor email naming a package and a list of bad versions.
The response timeline in the worksheet turns that into steps; this section explains the reasoning behind their order.
First, decide whether this is a website incident right now. If the live site is serving the attacker's code to visitors, an attacker still seems to be active, or customer data may have been taken, call your host and an incident response specialist before anything else, and use the hacked website guide for the first hour.
Clever Ops does not provide incident response, forensic investigation or monitoring, so it is not the right first call. The timeline is written for you and your developers, or your responder, to work through.
Stop new builds and deploys, and pause automated dependency update pull requests and auto-merge, so that nothing installs a fresh copy while you are still working out what you have. Then copy before you change anything. npm ci removes an existing node_modules folder before it installs, so a reinstall on an affected machine deletes the installed copy. npm also says its cache should not be relied on as a persistent store, so copy cached packages out rather than assuming they will still be there.
When npm Security confirms malware, it removes the package from the registry, which can leave your own copies as the ones a responder has to examine.
The question has three parts. Which version: read package-lock.json on every branch and every deployment, not only the main branch. For the 2025 npm compromise, CISA recommended checking package-lock.json or yarn.lock files for affected packages, including those nested in dependency trees, and searching artifact repositories and dependency management tools for cached versions.
Where: developers' machines, CI runners, build servers, preview deployments and container images. When: the lockfile's history in version control shows when a bad version entered and left each branch, the registry's publish time for the version marks the earliest moment it could have been installed, and CI logs record each install that ran. The overlap is your exposure window.
For a browser script, the same three questions become what the file contained, which pages loaded it, and between which times. The vendor's notice, any earlier copy you kept and your CSP reports give the outline.
Assume the bad code could read anything the process running it could read. For an install script or a build step, that is the environment of the machine or runner: registry tokens, repository tokens, cloud keys, deployment credentials and environment files on a developer's laptop. GitHub notes that a compromised action has access to every secret configured on the repository, and CISA's recommendations after the 2025 compromise included rotating all developer credentials immediately.
For a browser script, it is whatever the page held: form fields, payment fields and any token a script on the page can read.
Order matters. Rotate from a machine and pipeline that no longer has the bad version installed, because a credential rotated on a machine that is still affected can be read again. Revoke the old value rather than waiting for it to expire, and check each provider's logs for use during the window.
Where a secret was printed in a CI log, GitHub's guidance is to delete the log and rotate the secret; rotating first makes the logged value useless and leaves time to copy what the log shows about the install before it goes.
Inside the business, tell whoever builds and hosts the site, and everyone with access to the tag manager or the package registry account. Outside it, the decisions are ones to make with advice: your insurer, if the policy asks to hear before you engage a responder; your payment provider, if a checkout page loaded the affected script; and a privacy lawyer, if personal information could have been read.
The OAIC explains that under the Notifiable Data Breaches scheme, an organisation or agency covered by the Privacy Act 1988 must notify affected individuals and the OAIC when a data breach is likely to result in serious harm to a person whose personal information is involved.
Whether that applies to you is a question for the lawyer. ASD's ACSC also offers an option on its report page for reporting a cyber security incident.
If you found the malware yourself and no advisory exists yet, npm's documentation says you can report it to npm Security through the Report malware link on the package page, including all affected versions. A vulnerability, as distinct from malware, goes privately to the package's maintainers.
Recovery means rebuilding, not patching in place. Pick the last lockfile commit from before the bad version arrived, or pin the package to a known safe release published before it. For the 2025 compromise, CISA advised pinning npm dependencies to known safe releases produced before 16 September 2025. Build on a clean runner with npm ci, or pnpm with a frozen lockfile, so the install follows the lockfile and fails if the lockfile and package.json disagree.
Run npm audit signatures, and deploy the result as a new artefact rather than redeploying an image built during the window.
The NIST Cybersecurity Framework 2.0 states the same idea as two recovery outcomes: the integrity of backups and other restoration assets is verified before they are used for restoration, and the integrity of restored assets is verified, systems and services are restored, and normal operating status is confirmed.
Keep the pin until the maintainers publish a release you have reason to trust, and write down what changed in your setup as a result.
Making the next compromise smaller
No setting stops a determined attacker upstream, but several shrink what a bad release can reach and how long it goes unnoticed.
The dependency security guide covers routine updates and advisories; these are the controls aimed at deliberate changes.
- Builds install with npm ci or a pnpm frozen-lockfile install, never with a command that can rewrite the lockfile.
- Install scripts run only for packages on an explicit list, approved by exact version where the package manager allows it. npm approve-scripts writes version-pinned entries by default, so approving one release's script does not approve the next.
- New releases wait out a release-age delay before a build can pick them up, with a written route for exempting an urgent fix.
- Deployments roll out in stages where your platform supports it, which OWASP suggests as a way to limit exposure if a trusted vendor is compromised.
- The machines and runners that install packages hold only the secrets their job needs. Developer accounts on GitHub and npm use phishing-resistant multi-factor authentication, as CISA recommended after the 2025 compromise.
- Third-party scripts on sign-in, account and payment pages are few, listed, and either self-hosted with an integrity hash or isolated.
- Publishing rights in the tag manager are treated like deploy rights, with a named owner and a record of changes.
- Lockfile diffs are read in every dependency pull request, and the worksheet is updated when a package that matters changes hands.
Where a security review or test fits
Clever Ops does not monitor your dependencies or your site and does not respond to incidents.
What it offers sits either side of one: a check of the application before an incident, and a check of the rebuilt application after one, once any responder has finished their work.
A secure code review reads the lockfile against the package manifest, checks new packages and versions against published advisories, and reads what runs on its own at install, build or deploy time, such as package scripts and CI workflow files. A website security audit reviews the Content Security Policy on public pages, including whether it lists the script sources the site actually uses.
A vulnerability assessment identifies each component by its exact version where the application reveals it, and matches it to the vendor's own advisories.
Each of these describes the build and the pages that were tested, on the dates they were tested. None of them is monitoring, and a release published the day after the report is outside what the report can speak to. If Clever Ops built or hosts the site, the work is a security review rather than an independent test, and the report says who built it and who hosts it.
Frequently asked questions
An attack that changes something your software depends on, such as a package, a build step or a script loaded from another server, so the attacker's code reaches you through a normal update, build or page load. OWASP covers it under A03:2025 Software Supply Chain Failures, which it describes as breakdowns or other compromises in the process of building, distributing or updating software.
One that reaches you through the npm registry: a malicious release of a package you already use, published from a compromised maintainer account or token, or a lookalike or substitute package. GitHub wrote in September 2025 that the Shai-Hulud worm infiltrated npm via compromised maintainer accounts by injecting malicious post-install scripts into popular packages, and CISA reported that its malware harvested credentials and published compromised versions of other packages.
It stops a new release being picked up quietly, as long as builds install from it with npm ci or a frozen lockfile, which fail instead of rewriting the lockfile. It does not help when someone updates the lockfile to the bad version, or when the bad version was locked before anyone knew. Its history in version control is also your best record of what was installed and when.
Block them by default and approve the few packages that need them. npm says the only valid use of install or preinstall scripts is compilation that must be done on the target architecture. pnpm blocks unlisted dependency build scripts, and npm's version 12 documentation says it blocks unreviewed dependency install scripts by default, while version 11 runs them with a notice, so check which version your build uses. Blocking scripts does not stop a package's ordinary code running when it is imported.
No. Provenance tells you which source commit and build workflow produced a package and that an authorised account published it. npm says it does not mean the package has no malicious code; it gives you something to audit. A release that lacks the provenance its earlier releases carried is still a useful warning sign.
Pause builds, deploys and automated dependency updates, and copy the installed packages, lockfiles, caches and build logs before reinstalling anything, then work out which versions ran where and when. If the live site is serving malicious code or customer data may have been taken, call your host and an incident response specialist first. The response timeline on this page sets out the order for the first days.
No. Clever Ops does not provide incident response, forensic investigation or monitoring, so start with your developers, your host and an incident response specialist. Once the application has been rebuilt, a secure code review can read the lockfile, install scripts and CI workflow files, and a website security audit can review the Content Security Policy your public pages send. Each report records what was checked and what was not.
Scope the right test for your application
Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.