<Postmortem: Microsoft's agent-framework PyPI Package Was a Credential Stealer — Twice in One Day
On November 17, 2026, the agent-framework package that Microsoft publishes on PyPI stopped being agent-framework for a few hours. Version 1.26.1 went out carrying a credential-stealing payload. PyPI pulled it. Then a second malicious build, 1.26.2, landed before PyPI pulled that one too. Same day, same package, two separate bad releases.
This is a short postmortem: what we know about the timeline, what this kind of payload typically does, and — the part that actually matters if you have this package anywhere in a lockfile — how to check whether you pulled either version.
The timeline, as reported
- v1.26.1 published. Installable from PyPI like any normal release. No typosquat, no lookalike name — this was the real, previously-trusted package path.
- v1.26.1 pulled. Someone caught it fast enough that PyPI removed it the same day.
- v1.26.2 published. A second build went out with a modified version of the same payload — not a rollback to a clean release, but another malicious one.
- v1.26.2 pulled. PyPI removed this one too, same day.
The detail that makes this worth a postmortem rather than a one-line alert: this wasn't a single bad upload that got caught and fixed. Whoever controlled the release pipeline pushed malicious code twice in the same window, which points at either a compromised publishing credential that stayed compromised across both releases, or a build/CI step that was injecting the payload automatically on every release in that period rather than a one-off tampered artifact.
What this kind of payload does
We don't have the decompiled payload in front of us for this specific incident, so treat the specifics below as the general pattern this class of attack follows, not a confirmed description of what the agent-framework payload did byte-for-byte.
Python supply-chain credential stealers overwhelmingly follow the same playbook, because it works and it's cheap to build:
- Trigger on install, not on import. A malicious
setup.py, abuild.pyhook, or a post-install step inpyproject.tomlruns arbitrary code the momentpip installfinishes — before you've even imported the package, let alone used it. - Harvest what's already on disk.
~/.aws/credentials,~/.config/gcloud,~/.azure, SSH private keys,.netrc, browser-stored tokens, and any environment variable whose name matchesKEY,TOKEN, orSECRET. - Exfiltrate over a channel that looks like normal traffic. A POST to a webhook endpoint, a DNS lookup encoding stolen data in the subdomain, or — increasingly — a request to a legitimate-looking cloud storage bucket that doesn't stand out in a network log.
- Clean up or stay quiet. Some variants remove themselves after running once; others persist via a modified shell profile or scheduled task so the next shell session re-triggers collection.
Given this package's install base — anyone building agentic Python tooling against Microsoft's SDKs pulls it in as a dependency, often transitively — the realistic blast radius isn't "a few people who typed the wrong package name." It's every CI pipeline, dev laptop, and production container that happened to run pip install or pip install -U during that window.
How to check if you installed either version
This is the part worth actually running, not just reading. The script below checks three things: whether the bad version is installed right now, whether any lockfile in your repo pins it (so a fresh pip install -r requirements.txt next week would reintroduce it even if your current environment is clean), and gives you a clear exit code for CI.
#!/usr/bin/env python3
"""Check whether a known-bad version of a PyPI package is installed
or pinned anywhere in this project, and flag it before it runs again."""
import importlib.metadata as im
import pathlib
import re
import sys
PACKAGE = "agent-framework"
BAD_VERSIONS = {"1.26.1", "1.26.2"}
def installed_version(pkg: str) -> str | None:
try:
return im.version(pkg)
except im.PackageNotFoundError:
return None
def scan_lockfiles(root: pathlib.Path, pkg: str, bad: set[str]) -> list[str]:
"""requirements*.txt, poetry.lock, uv.lock, Pipfile.lock - anywhere
one of the bad versions is pinned, even if it's not installed
in *this* environment right now."""
hits = []
patterns = [f"{pkg}=={v}" for v in bad] + [f'"{pkg}"' for v in bad]
lockfile_glob = ("requirements*.txt", "poetry.lock", "uv.lock", "Pipfile.lock")
for pattern in lockfile_glob:
for path in root.rglob(pattern):
text = path.read_text(errors="ignore")
if pkg in text:
for v in bad:
if re.search(rf"{re.escape(pkg)}[^\n]*{re.escape(v)}", text):
hits.append(f"{path}: pins {pkg} {v}")
return hits
def main() -> int:
current = installed_version(PACKAGE)
exit_code = 0
if current in BAD_VERSIONS:
print(f"[CRITICAL] {PACKAGE} {current} is INSTALLED right now. "
f"Uninstall immediately: pip uninstall -y {PACKAGE}")
exit_code = 2
elif current:
print(f"[ok] {PACKAGE} {current} is installed and not in the bad set.")
else:
print(f"[ok] {PACKAGE} is not installed in this environment.")
hits = scan_lockfiles(pathlib.Path("."), PACKAGE, BAD_VERSIONS)
if hits:
exit_code = max(exit_code, 1)
print("[WARNING] Found pinned references to the bad versions:")
for h in hits:
print(f" - {h}")
else:
print("[ok] No lockfile in this tree pins the bad versions.")
return exit_code
if __name__ == "__main__":
sys.exit(main())Run it from the root of each repo that depends on agent-framework, directly or transitively:
python3 check_agent_framework.py; echo "exit code: $?"Exit code 0 means clean. 1 means a lockfile still pins a bad version even though nothing's installed yet — fix it before the next clean-room install picks it back up. 2 means the bad version is installed right now — stop and treat the host as compromised, not just "needs an upgrade."
If you find either version
Don't just upgrade and move on. Uninstalling the package removes the ongoing risk, not the risk that already happened. If the payload ran once, assume it read what it could reach, and rotate accordingly:
# After confirming exposure, rotate anything the process could have read.
# Don't just rotate the obvious ones -- a credential stealer grabs whatever
# the interpreter's environment and filesystem permissions let it see.
# 1. Anything injected as an env var into that process
env | grep -Ei '(_KEY|_TOKEN|_SECRET|PASSWORD|_CREDENTIAL)' | cut -d= -f1
# 2. Cloud CLI credential files readable by the user that ran pip install
ls -la ~/.aws/credentials ~/.config/gcloud/credentials.db ~/.azure/credentials 2>/dev/null
# 3. SSH keys and git credential helpers in the same home directory
ls -la ~/.ssh/id_* ~/.git-credentials 2>/dev/nullIf the affected host runs in CI with cloud credentials injected via OIDC or short-lived tokens, the blast radius is smaller by default — but still rotate any long-lived secret (API keys, PATs, static IAM access keys) that was present in that environment's variables during the window the bad version was installed.
The actual lesson here
"Pin your dependencies" doesn't save you from this — the bad versions were the pinnable releases on PyPI for part of that day. What actually helps:
- Hash-pin, not just version-pin. A
requirements.txtwith--hashentries (or auv.lock/poetry.lockwith hashes) won't silently accept a replacement artifact published under the same version string on a mirror, and forces you to notice when a hash changes on upgrade. - Run
pip-auditorosv-scannerin CI, not just locally and not just before a release. Advisory databases typically get the yanked-version flag within hours, and a scheduled CI job catches it even if nobody manually re-checks. - Treat "republished under a new patch version within hours" as a signal on its own. Legitimate maintainers ship hotfixes; two malicious builds in one day from a high-profile package is the kind of anomaly that should trip an internal alert on your dependency-update bot, independent of whether a CVE has been filed yet.
- Isolate what
pip installcan see. Running installs in a container or sandboxed build step without live cloud credentials mounted turns "credential stealer ran" into a non-event, because there's nothing in reach to steal.
Supply-chain compromises on PyPI aren't rare anymore. What makes this one worth a write-up is the double release in one day — it's a reminder that "the package I trust" and "the account that can publish under that package's name right now" are not the same guarantee, even for packages published by a name as recognizable as Microsoft's.

Experienced DevOps Engineer proficient in Python, Docker, Kubernetes, CI/CD, and cloud technologies. Specialized in automating processes and building scalable infrastructure for seamless development and deployment.


