How to Check If You Installed a Malicious PyPI or npm Package

Find out if a hijacked PyPI or npm release reached your machines or CI, scan lockfiles for malware, remove it cleanly and rotate exposed secrets.
BreachNews guide: how to check if you installed a malicious PyPI or npm package

When a trusted package gets hijacked, the hard part is not reading the advisory. It is figuring out whether the bad version ever touched your laptop, your servers or your CI runners. The November 17 compromise of Microsoft’s agent-framework package on PyPI is a good example: versions 1.26.1 and 1.26.2 were live for under an hour, yet anyone who installed them in that window may have handed over cloud and CI credentials.

This guide walks you through checking a Python or Node.js project for a known malicious package version, from the advisory to a clean rebuild. Every command below was tested on Python 3.13, pip 26.3, Node.js 24 and npm 11 and 12. We use agent-framework as the running example, but the same steps work for any hijacked PyPI or npm package.

Before you start

You need three facts from the advisory: the exact package name, the bad version numbers, and the time window they were available. You also need a list of every place your code runs, including developer laptops, build servers, containers and CI pipelines. Malicious releases are often pulled within hours, so the question is whether any install happened inside that window, not whether the package is on your machine today.

Step 1: Confirm the bad versions from an official advisory

Search the GitHub Advisory Database malware filter or OSV.dev for the package name. Malicious package reports on OSV use IDs that start with MAL-. For our example, the entries are GHSA-764m-3ppc-5m73 and MAL-2026-20101, and the PyPI project page shows 1.26.0 as the latest clean release.

Do not rely on a social media post or a forwarded screenshot for version numbers. Attackers sometimes publish a second bad version after the first is pulled, as happened here.

What success looks like: you have the package name, every bad version, the last known good version and the advisory link written down.

Step 2: Check what is installed right now

On each machine, activate the project’s virtual environment (or open the project folder for Node.js) and ask the package manager directly.

  • Python: python -m pip show agent-framework prints the installed version, or a “Package(s) not found” warning if it is absent. Use python -m pip list to see everything in that environment.
  • Node.js: npm ls package-name --all shows the package and every copy pulled in by other dependencies. Add -g to check globally installed tools.

Run the Python check once per virtual environment. A package can be clean in one environment and malicious in another on the same computer.

What success looks like: for every environment, you can say which version is installed or that the package is not present.

Step 3: Search lockfiles and requirements across your repositories

What is installed today does not tell you what your CI installed yesterday. Lockfiles and requirement files show what your builds were told to pull. From the top of your code folder, run:

grep -rln "agent-framework" --include="requirements*.txt" --include="poetry.lock" --include="uv.lock" --include="Pipfile.lock" --include="pyproject.toml" .

For npm projects, search package-lock.json, yarn.lock and pnpm-lock.yaml the same way. Pay close attention to loose version ranges such as >=1.20 or ^1.26.0 with no lockfile. Those can pull a brand new malicious release automatically.

What success looks like: a list of every repository that references the package, with the pinned version or range each one uses.

Step 4: Scan with a tool that knows about malware

Install OSV-Scanner from its official releases and run it against each project folder:

osv-scanner scan source -r .

It reads Python and npm lockfiles and requirement files and flags matches against OSV, including MAL- malware entries. In our test, a requirements file pinned to agent-framework==1.26.1 was flagged with both MAL-2026-20101 and PYSEC-2026-4388. For npm projects, npm audit also checks your lockfile against the GitHub advisory data.

One catch we hit in testing: pip-audit failed outright on the same file because PyPI had already quarantined the bad versions, so pip could not resolve them. A failed scan is not a clean scan. If a scanner errors on a pinned version, treat that pin as suspicious and check it by hand.

What success looks like: each project either returns no malware findings or a clear list of affected files and versions.

Step 5: Look for leftover startup hooks

Many Python stealers hide in .pth files. Per the Python site documentation, lines in these files that start with import run every time Python starts, so the code fires even if nothing imports the package. List them with:

python -c "import site,glob;[print(f) for d in site.getsitepackages() for f in glob.glob(d+'/*.pth')]"

A few .pth files are normal, such as distutils-precedence.pth from setuptools. Anything named after the compromised package, or one you cannot explain, deserves a closer look. For our example, the reported file names are agent_framework_meta.pth in 1.26.1 and af_runtime_diag.pth in 1.26.2. For npm, the usual hiding spot is a postinstall script in the package’s package.json.

What success looks like: every .pth file in your environments is accounted for.

Step 6: Work out whether you installed it inside the window

If the package is installed, check when that copy landed. On macOS or Linux, the folder date of its metadata is a reasonable clue:

ls -ld --time-style=full-iso venv/lib/python3*/site-packages/agent_framework-*.dist-info

On macOS, drop --time-style=full-iso and use ls -ld. For CI, open the build logs for every run inside the exposure window and search for the package name and version. Container images built during that window count too. If you cannot rule an install in or out, assume it happened.

What success looks like: a yes, no or unknown answer for each laptop, server, image and pipeline.

Step 7: Remove it and rebuild from a clean state

Uninstalling the package is not enough if it already ran. The safest fix is to delete the environment and rebuild it with the last good version pinned.

  • Python: delete the virtual environment folder, run python -m pip cache purge, create a new environment and install with the pin, for example python -m pip install agent-framework==1.26.0.
  • Node.js: pin the good version in package.json, delete node_modules, run npm cache clean --force, then reinstall from the lockfile with npm ci.
  • CI and containers: clear dependency caches in your pipeline settings and rebuild images from scratch so a cached layer does not bring the bad version back.

What success looks like: rerunning Steps 2 and 4 shows only the clean version and no malware findings.

Step 8: Treat every reachable secret as stolen

If the bad version ran anywhere, assume the attacker has every credential that machine or pipeline could read: environment variables, cloud CLI logins, .npmrc and .git-credentials files, .env files, and cloud tokens available to the runner. The agent-framework stealer went after all of those, according to the advisory and security firm analyses.

Rotate them in order of damage, starting with anything that moves money and cloud admin keys. Our guide on how to rotate leaked API keys after a platform breach covers the full process. Then review cloud and GitHub audit logs for activity you do not recognize since the install time.

What success looks like: every exposed secret is replaced, the old ones are revoked, and nothing unusual shows up in your logs.

Step 9: Make the next hijack harder to catch you

Most hijacked releases are found and pulled within hours or days. A short waiting period before new versions install blocks a large share of them.

  • pip 26 supports --uploaded-prior-to P3D, which only considers files uploaded at least 3 days ago.
  • Recent npm releases support the min-release-age setting, for example npm install --min-release-age=3. Older npm versions ignore it, so run npm --version and upgrade first.
  • Commit lockfiles, install with npm ci in CI, and use hash checking for Python as described in pip’s secure installs guide.
  • Give CI jobs only the secrets they need, so one bad package cannot reach everything.

What success looks like: your builds pull pinned, aged versions, and a single compromised package cannot see your most sensitive keys.

Common mistakes

  • Checking only your laptop and forgetting CI runners, build servers and container images.
  • Treating “it is not installed now” as proof it never ran. Quarantined versions disappear from the registry, not from your logs.
  • Searching only for the first set of file names when a later bad version used different ones.
  • Reading a scanner error as a clean result.
  • Uninstalling the package but keeping the same credentials.
  • Rebuilding from a cache that still holds the malicious version.

Related reading

Last verified: November 18, 2026

Picture of m00s3c

m00s3c

Moose (@m00s3c) is the author of BreachNews, focusing on data breach intelligence, dark web monitoring, and threat analysis. His work involves analyzing breach claims, reviewing leaked datasets, and tracking threat actor activity to provide clear, factual reporting.

Latest News

BREACHNEWS.COM/SUPPORT/

Support Independent News.

Help support breach monitoring, investigations, infrastructure, and reporting.

Support the site →