A recent PyPI incident involving a credential stealer highlights the risks of unverified dependencies. Here is how to audit your build pipeline.
Imdadullah BabuDesigned & DeveloperPyPI supply chain: 5 ways to stop dependency malware
On November 17, 2026, a malicious package named agent-framework was published to PyPI, functioning as a credential stealer for Python environments. This incident is not isolated; it follows a pattern of sophisticated attacks on trusted registries like PyPI, npm, and Docker Hub. For businesses relying on Python-based services, a single compromised dependency can expose API keys, cloud tokens, and SSH credentials to threat actors.
The speed of these attacks has increased significantly. In recent campaigns, such as the TeamPCP incidents affecting LiteLLM and Telnyx, malicious versions were live for mere hours before detection. This window is enough for thousands of developers to install the payload, leading to massive data exfiltration. If your team is building products with Python backends or AI integrations, understanding the mechanics of a PyPI supply chain attack is no longer optional—it is a core operational requirement.
Key takeaways
- Credential stealers are the primary goal: Modern malware packages like
agent-frameworkdo not just crash systems; they actively hunt for environment variables,.envfiles, and cloud config folders to steal secrets. - Typosquatting and name collisions: Attackers exploit package name resolution, publishing malicious versions of popular libraries or creating look-alike names to trick installers.
- CI/CD is a weak link: Many recent attacks involved stealing publishing tokens from Continuous Integration pipelines, allowing attackers to push malicious versions to PyPI under legitimate project names.
- Locking and hashing are essential: Relying on
pip installwithout version pinning or hash verification leaves your build environment vulnerable to immediate compromise.
Understanding the 'agent-framework' Incident
The agent-framework package gained attention on November 18 when security researchers noted its activity. The package masqueraded as a utility for building AI agents, a popular niche in 2026. Upon installation, the code executed hidden scripts that scanned the user's machine for sensitive credentials.
Unlike traditional viruses that might display pop-ups or encrypt files, this credential stealer operated silently. It targeted standard locations where developers store secrets: ~/.aws/credentials, ~/.config/gcloud/application_default_credentials.json, and environment variables in active shells. Once collected, the data was exfiltrated to a command-and-control (C2) server.
This incident highlights a broader trend: attackers are targeting the "official" looking libraries that developers trust implicitly. As noted in reports on the LiteLLM compromise, the trust in package maintainers is a key vector. When a maintainer's token is stolen, the attacker can publish a malicious version that looks identical to the legitimate one, except for the added malicious payload.
The Mechanics of a PyPI Supply Chain Attack
To defend against these threats, you must understand how they work. A typical PyPI supply chain attack follows one of two paths:
- New Malicious Package: An attacker registers a new name similar to a popular one (e.g.,
requestrinstead ofrequests). They use social engineering to get developers to install it. - Compromised Legitimate Package: An attacker steals the API token of a package maintainer (often via a phishing attack or a vulnerability in their CI/CD tool) and publishes a new, malicious version of an existing popular package.
In the second scenario, the danger is high because developers are updating a dependency they trust. For example, in the 2026 LiteLLM incident, attackers poisoned the CI/CD pipeline, allowing them to upload malicious versions 1.82.7 and 1.82.8. These versions were live for a short window but were downloaded thousands of times, spreading the malware package to production servers globally.
Auditing Your Python Dependencies
You cannot prevent every attack, but you can reduce your surface area. Here is a practical checklist for auditing your Python projects:
1. Lock Your Dependencies
Never install dependencies without a lock file. If you use pip, you must pin specific versions. Even better, use a tool like pip-tools or uv to generate a requirements.txt or uv.lock file that includes hashes for every package.
# Example: Using uv to lock dependencies and verify hashes
uv lock
uv sync --frozen --verify-hashes
The --verify-hashes flag ensures that the downloaded file matches the exact hash recorded in the lock file. If an attacker modifies a package file, the hash will not match, and the installation will fail.
2. Restrict Outbound Network Access
Python packages should not need to make arbitrary network calls during installation or import. Use network isolation in your CI/CD runners and production environments. If a package tries to connect to a domain not on your allowlist (like pypi.org or files.pythonhosted.org), it is likely exfiltrating data.
3. Monitor for Anomalies in CI/CD
Check your CI/CD logs for unexpected commands. Attackers often inject code that runs during the build process to steal secrets. Look for lines in your requirements.txt that include @ file: or complex script execution. Additionally, monitor for any PyPI releases in your dependency tree that do not have matching GitHub tags, which can indicate a backdoored release.
Implementing Defense in Depth
Security is not a single tool; it is a layered approach.
| Defense Layer | Tool/Method | Purpose |
|---|---|---|
| Dependency Scanning | pip-audit, Snyk |
Identifies known vulnerabilities in your current dependency tree. |
| Hash Verification | pip install --require-hashes |
Ensures the exact file integrity of the downloaded package. |
| Network Isolation | Docker Network Policies | Prevents the Python process from talking to unauthorized C2 servers. |
| Secret Management | HashiCorp Vault, AWS Secrets Manager | Avoids storing secrets in plain text environment variables that stealers can easily grab. |
| Provenance | PyPI PEP 740 Attestations | Verifies that the package was built from a specific, trusted source code commit. |
By combining these layers, you create a situation where even if one fails (e.g., a new zero-day in a package), the others (network isolation, hash checking) catch the anomaly.
For teams managing complex microservices or SaaS products, this level of scrutiny is critical. If you are struggling to implement these checks in your existing pipeline, we can help you integrate Service: Software Maintenance to harden your build infrastructure without disrupting your release cycle.
Frequently asked questions
What is a PyPI supply chain attack?
A PyPI supply chain attack occurs when malicious code is introduced into a Python package or its dependencies. This can happen through typosquatting (fake package names) or by compromising the credentials of a legitimate package maintainer, allowing the attacker to publish a backdoored version.
How do I verify if a package is compromised?
You can check the PyPI JSON API for the upload time of the specific version you are using. If the upload time does not match the expected release date or the GitHub tag, it is suspicious. Additionally, use tools like pip-audit to check against known vulnerability databases.
Does using a virtual environment protect me?
No. A virtual environment isolates the Python packages from your system Python, but it does not stop the package from executing malicious code or exfiltrating data. If the package has network access, it can steal credentials from the virtual environment's activation scripts or the surrounding OS environment variables.
What is the role of PyPI Trusted Publishing?
PyPI Trusted Publishing (OIDC) allows maintainers to bind their publishing rights to a specific CI/CD workflow. This means the attacker would have to compromise the specific CI/CD runner, not just the maintainer's personal account or a static API token. It significantly raises the difficulty for attackers.
How often should I audit my dependencies?
You should audit dependencies on every build in your CI/CD pipeline. Tools like pip-audit are fast enough to run in minutes. Additionally, subscribe to security advisories for the specific libraries you use, so you are alerted immediately if a version is compromised.
Protect Your Build Pipeline
The landscape of Python security is changing rapidly. What was a standard pip install yesterday could be a vector for a credential stealer today. By implementing hash verification, network isolation, and strict dependency locking, you can secure your product and your customers' data.
If you are planning to build a new Python-based service or want to audit your existing infrastructure, we can help you set up a secure pipeline from the start.
Sources
- Microsoft's durabletask PyPI Package Compromised in Supply Chain Attack - StepSecurity
- Defense in Depth: A Practical Guide to Python Supply Chain Security · Bernát Gábor
- Incident Report: LiteLLM/Telnyx supply-chain attacks, with guidance - The Python Package Index Blog
- Weaponizing the Protectors: TeamPCP’s Multi-Stage Supply Chain Attack on Security Infrastructure
- Guggenheim reiterates JFrog stock rating after supply chain attack By Investing.com
- The Packages You Didn't Install Are Now Your Biggest Risk | Anaconda
- LiteLLM and Telnyx compromised on PyPI: Tracing the TeamPCP supply chain campaign | Datadog Security Labs
- No Off Season: Three Supply Chain Campaigns Hit npm, PyPI, and Docker Hub in 48 Hours
- #Python
- #Security
- #DevOps
- #PyPI
- #Supply Chain
- #Backend
- #CVE-2026
- #Risk Management
- #Web Security
Working on something similar?
We help teams design, build and scale software like this. Tell us about your project.
Start a projectKeep reading
NGINX RCE Vulnerability: Fixing CVE-2026-123633
NGINX RCE Vulnerability: Fixing CVE-2026-123633
Critical unauthenticated RCE flaw in NGINX HTTP/2 handling. Get the step-by-step remediation guide to patch CVE-2026-123633 and secure your infrastructure.
By Imdadullah Babu