Microsoft's agent-framework on PyPI: a .pth hook stole credentials
On 17 November 2026, unknown actors published two versions of the agent-framework package on PyPI, the Python package of Microsoft's Agent Framework. Both carried a credential stealer that runs every time Python starts, even if nobody imports the package. About 41 minutes later the last version was isolated on PyPI. This post gives times, files and sources, shows the mechanism with a harmless probe, and lists what an admin should check and rotate.
A .pth file is a text file in the site-packages folder of a Python installation. When the interpreter starts, the site module reads every .pth file, and Python runs lines that begin with import through exec(), whether or not a program later uses the package. Installing a package that ships such a file therefore starts foreign code on every following Python call. Only the -S startup switch prevents that.
What the sources agree on
The core facts are in the GitHub advisory GHSA-764m-3ppc-5m73, published on 18 November 2026 as a malware entry, weakness CWE-506 (embedded malicious code), with no patched version. It names 1.26.1 (20:35 UTC, wheel only) and 1.26.2 (21:08 UTC) and states that agent_framework_meta.pth and af_runtime_diag.pth respectively trigger the code at interpreter start. Wiz, Aikido, StepSecurity and Socket agree on file names and data destination. None of the pages we opened names a CVE.
| Property | Version 1.26.1 | Version 1.26.2 |
|---|---|---|
| Uploaded (UTC, 17 Nov 2026) | 20:35:20 | 21:08:39 |
| Startup file | agent_framework_meta.pth | af_runtime_diag.pth (one line: import af_runtime_diag) |
| Malicious code | agent_framework_meta/_telemetry.py | af_runtime_diag.py |
__init__.py | eight lines appended | reset to the 1.26.0 content |
| User-Agent when sending | af-runtime-diagnostics/1 | runtime-diagnostics/1 |
| Extra | Azure identities only | GitHub Actions OIDC token, 80 instead of 60 files |
| Isolated (UTC) | 21:06:16 | 21:16:44 |
Unit: time to the second, file names, number of files. Source dates: 17 to 18 November 2026, read by us on 22 November 2026. Carrier: vendor analyses by StepSecurity (times) and by Wiz, Aikido and Socket (files). We did not take the wheels apart ourselves. Their checksums are listed by StepSecurity and in the advisory.
Both versions still depended on the genuine agent-framework-core[all]==1.26.0, so the framework worked normally. According to the advisory, the stealer detaches into a background process, sets _AF_TEL=1 to stop restarts in child processes, and silences all errors.
What was stolen
According to Wiz, Aikido and Socket, the stealer collects in a single pass:
- Environment variables whose names contain, for example, TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS, GITHUB or OPENAI, plus the environment of other processes from
/proc/<pid>/environ(up to 300 processes). - Files: Azure CLI state in
~/.azure,pip.conf,.npmrc,.netrc,.git-credentials, Dockerconfig.json, Hugging Face tokens, Azure DevOps agent.credentials, and.envfiles in/appand/workspace. - Fresh identities: Azure managed identity access tokens for twelve resources through the local metadata service, Azure DevOps OIDC tokens and, in 1.26.2 only, GitHub Actions OIDC tokens.
The destination is webhook.site, a public service for inspecting requests. StepSecurity notes that a connection to the domain alone does not prove exfiltration, and that the analysis shows token requests without proof that any token was issued. Wiz analysed the 50 requests stored on the attacker's free account: 17 of them hold data from just three victims (vendor figure, not verified).
Where the sources disagree
Two points are inconsistent, and a third is missing.
End of the window. Aikido says both versions were removed around 21:20 UTC, Wiz says they were gone by about 21:30, and StepSecurity shows 1.26.1 isolated at 21:06:16 and 1.26.2 at 21:16:44. With the StepSecurity times, 1.26.1 was reachable for 30 minutes 56 seconds, 1.26.2 for 8 minutes 5 seconds, and the whole span was 41 minutes 24 seconds (our own calculation). BleepingComputer writes that the second version appeared about 2.5 minutes after the first. According to StepSecurity there were 33 minutes between the uploads, and 2 minutes 23 seconds between the isolation of the first version and the upload of the second. The 2.5 minutes most likely belong to that second figure.
Reach. Aikido gives about 190,000 downloads a month, Wiz about 41,000 a week: two units, both vendor figures. No source we opened says how many installs fell into the window.
Cause. On 18 November Wiz wrote that the attacker apparently compromised a client certificate and private key for Microsoft's ESRP release service. A first attempt from an AWS network failed on IP filtering, a second from Microsoft-owned address space succeeded. How the certificate leaked is open. StepSecurity states that the initial access, the account used and the uploader's identity cannot be determined from the evidence. It notes a maintainer account created the same day and no provenance attestation for the wheels. BleepingComputer reports that the point of entry is unclear. None of the pages we opened contains a statement from Microsoft: BleepingComputer had no reply by publication. We could not open GitHub issue #10411 in the Microsoft repo, which press reports mention (login wall). The ESRP explanation remains a vendor claim by Wiz.
On the PyPI project page (read on 22 November 2026) the current version is 1.26.0 from 12 November 2026. 1.26.1 and 1.26.2 are not in the list, and the page carries no notice about a removal.
How a .pth file starts: our probe
The Python documentation for the site module says that lines in .pth files starting with import are run with exec() for backward compatibility. A note there states that such lines always run at startup unless -S disables site.py entirely. Since Python 3.15 they are deprecated but still run, and a message appears only with -v.
Our own probe from 22 November 2026, in two fresh virtual environments (Python 3.14.4 and 3.15.2): each holds a demo.pth with the line import demo_hook, and demo_hook.py only prints a message. The hook has no malicious function and no network access.
| Call | Python 3.14.4 | Python 3.15.2 |
|---|---|---|
python -c pass | hook runs | hook runs |
python -I -c pass (isolated) | hook runs | hook runs |
python -S -c pass | hook does not run | hook does not run |
python -m pip --version | not measured | hook runs |
Unit: hook runs yes or no. Date: 22 November 2026. Carrier: Linux machine (aarch64) with distribution Python 3.14.4 and a second installation 3.15.2. Our own measurement.
Two consequences. First, -I does not protect: the hook ran with -I in both environments (measured). Second, running pip show or python -m pip list on a suspect machine starts the hook again. Search for the files with find and grep first, then use Python.
How to check your environment
All commands are read-only. The first does not need Python:
find / -xdev \( -name 'agent_framework_meta.pth' -o -name 'af_runtime_diag.pth' \
-o -name 'af_runtime_diag.py' -o -name '_telemetry.py' -path '*agent_framework_meta*' \) 2>/dev/null
find / -xdev -name '*.pth' -exec grep -lE '^import[[:space:]]' {} + 2>/dev/null
The second command lists every .pth file with an executable line. Legitimate hits exist: it showed the distutils-precedence.pth from setuptools in the system path of a Linux distribution, and editable installs write such files too. What matters is the comparison with a known good environment.
Then run pip list | grep -i agent-framework or uv pip list in every virtual environment, every image built since 17 November 2026 and the CI caches. In our measurement pip cache list shows only locally built wheels (empty here, pip 26.3), so downloaded wheels do not appear. Purge the cache instead (pip cache purge, for uv uv cache clean agent-framework) and search lockfiles and CI logs for 1.26.1 and 1.26.2. On the network side, search proxy and DNS logs for webhook.site.
Our own result from 22 November 2026, read-only: we do not use the package. There were zero hits for agent-framework in our repositories, and none in the package lists (pip list) and the file search of ten containers on two Linux hosts. That holds for the set we checked. Only part of the systems was included, other virtual environments and single workstations were not searched.
What helps against a repeat
Pin hard and check hashes. A range such as agent-framework>=1.26 would have pulled the malicious version on 17 November 2026, a pin to ==1.26.0 would not. The pip hash-checking mode (pip install --require-hashes -r requirements.txt) demands a == pin and a hash for every requirement, including dependencies you did not name yourself, and pip aborts if one is missing. Install the project itself with --no-deps. A hash protects against a different file under the same version. If you raise the pin yourself to a new, already tampered version, you gain nothing: the hash then fits the bad file.
Cooldown. uv supports exclude-newer with a relative duration such as 1 week, and files uploaded more recently are not resolved. Against a 41-minute window a week is enough (our own calculation, an inference). The PHP counterpart is described in Composer 2.11 and its waiting period for new packages. With uv sync --locked the build aborts if the lockfile does not match the project. Whether the lockfile contains hashes is not stated on the uv pages we read, so we say nothing on that.
Limit privileges. The stealer takes what is there: managed identity, OIDC tokens, .env. A runner without id-token: write and without metadata service access has less to give. An egress allowlist would block that public destination (inference, not measured).
What to rotate after a hit
Anyone who had 1.26.1 or 1.26.2 installed should treat the environment as exposed. Aikido, Wiz and BleepingComputer agree: pin to 1.26.0, rebuild environments from a clean state and rotate every secret the machine could reach. For Azure that means renewing credentials and tokens of the pipeline service accounts, and Aikido adds that the Entra sign-in logs of pipeline service principals and federated credentials should be reviewed. For GitHub Actions it means repo and organisation secrets and every federated trust for workflows that may have loaded 1.26.2. An earlier case with a key swap is described in LiteLLM 1.107.0 and the malicious code, and the topic hub on security and privacy collects more. Pins, cooldowns and rotation for your own Python environments are part of IT operations: virtualisation, network, security and backup.
Our recommendation: run the search commands across all build and runtime environments today, move to == pins with hashes, and set a one-week cooldown for uv projects. On a hit, rotate first, then clean up.
Further reading
- GitHub Advisory GHSA-764m-3ppc-5m73: Malicious code in agent-framework (PyPI), 18 Nov 2026, primary source, read on 22 Nov 2026.
- Wiz: Microsoft agent-framework Compromised, updated 18 Nov 2026 14:00 UTC, vendor claim (ESRP hypothesis, 50 requests), read on 22 Nov 2026.
- Aikido: Two malicious agent-framework releases hit PyPI in 33 minutes, vendor claim, read on 22 Nov 2026.
- StepSecurity: Microsoft agent-framework PyPI package compromised, vendor claim (times to the second), read on 22 Nov 2026.
- Socket: agent-framework PyPI package compromised with credential stealer, vendor claim, read on 22 Nov 2026.
- BleepingComputer: Microsoft's agent-framework PyPI package compromised, 18 Nov 2026, independent press, read on 22 Nov 2026.
- PyPI: agent-framework, project page, read on 22 Nov 2026.
- Python documentation: site, primary source, read on 22 Nov 2026. pip: Secure installs and uv: Resolution, primary sources, read on 22 Nov 2026.
- Own check on 22 November 2026 (read-only): repositories,
pip listand file search in ten containers on two Linux hosts;.pthprobe in two virtual environments (Python 3.14.4 and 3.15.2, aarch64). - Logos: Wikimedia Commons, Microsoft logo (2012) and Simple Icons, pypi.svg.
Which agent-framework versions are affected, and which is clean?+
Versions 1.26.1 and 1.26.2 are affected. Both were uploaded to PyPI on 17 November 2026 and removed shortly after. The last clean version is 1.26.0 from 12 November 2026. If you never installed the package, or only run 1.26.0 or older, the reports say you are not affected. PyPI currently lists 1.26.0 as the latest release, and 1.26.1 and 1.26.2 are missing from the list.
Does a .pth file run even if I never import the package?+
Yes. At startup Python reads every .pth file in site-packages and runs lines that begin with import through exec(), whether or not a program uses the package. We measured it on Python 3.14.4 and 3.15.2: a harmless hook ran on python -c pass, on python -I and on pip --version. Only the -S switch, which skips the site module entirely, suppressed it.
What do I have to rotate if one of the two versions was installed?+
Everything the machine or the CI runner account could reach: environment variables holding tokens, keys and passwords, the Azure CLI login, .npmrc, pip.conf, .netrc, .git-credentials, Docker and Hugging Face credentials, and Azure and GitHub Actions identities. Removing the package does not undo data that was already sent.
senn-tech