learn deep. ship safe.Practice testsFollow ByteMunSubscribe
Cyber SecurityTrending #1

agent-framework PyPI Compromise: Who Is Affected and What to Rotate

Two hijacked releases of Microsoft's agent-framework Python package ran a credential stealer at every Python start. Here is how to check your machines and CI without triggering it again, and what to rotate.

Illustration of the agent-framework PyPI compromise: a package box tagged .pth leaking a key and a token, with Check, Remove and Rotate steps
Malicious agent-framework 1.26.1 and 1.26.2 used a .pth startup hook; 1.26.0 is the last clean release.

The agent-framework PyPI compromise hit two releases of Microsoft's Python package for building AI agents, 1.26.1 and 1.26.2, on November 17, 2026. Both carried a credential stealer that ran every time Python started in the environment, even if your code never imported the package. If any laptop, container or CI runner installed either version, treat every secret it could reach as stolen. Go back to 1.26.0.

This guide covers the timeline and how the startup hook works. It also lists what the stealer collected, how to check your machines without setting the code off again, what to rotate and in what order, and the indicators to search for. It ends with the habits that make the next hijacked SDK release much less dangerous.

What happened in the agent-framework PyPI compromise

Microsoft Agent Framework is an open-source framework for building, orchestrating and deploying AI agents and multi-agent workflows in Python and .NET. ByteMuni covered the production side of it in Microsoft's agent harness for production AI. The Python distribution on PyPI is called agent-framework, and it is published under the microsoft PyPI account. SafeDep puts its downloads at about 192,000 a month.

The last clean release, 1.26.0, went up on November 12. Five days later, someone with publishing rights uploaded two new versions 33 minutes apart. Neither had a matching release in the GitHub repository. Wiz found no python-1.26.1 tag and no malicious code on the main branch.

Time (UTC)Time (IST, by our conversion)EventReported by
Nov 12, 18:24–18:26Nov 12, 23:54–23:56Legitimate 1.26.0 published as a wheel and an sdist, alongside agent-framework-core and sibling packagesEndor Labs, Wiz
Nov 17, 20:35:20Nov 18, 02:05Malicious 1.26.1 uploaded: wheel only, 10,402 bytesSafeDep, Endor Labs, Wiz
Nov 17, 20:57Nov 18, 02:27SafeDep flags 1.26.1SafeDep
Nov 17, 21:08:39Nov 18, 02:38Malicious 1.26.2 uploaded: wheel only, 10,449 bytes, payload moved to new filesSafeDep, Endor Labs
Nov 17, 21:13Nov 18, 02:431.26.1 is gone from the index; 1.26.2 is the latest releaseEndor Labs
Nov 17, 21:16Nov 18, 02:461.26.2 is still the latest version, so unpinned installs still get the payloadEndor Labs
Nov 17, ~21:30Nov 18, ~03:00Neither version is available on PyPIWiz
Nov 17, 22:08Nov 18, 03:38A Microsoft maintainer replies to a researcher's GitHub report that the versions were pulledFourWeekMBA

The PyPI page itself now shows a banner on each bad version: "Release quarantined on Nov 17, 2026." Researchers describe the versions as "removed," but the release history still lists both, marked quarantined. Under PyPI's quarantine feature, a project or release can't be installed while PyPI admins review it. The current version on the page is 1.26.0.

Indian teams should note the clock. The upload window ran from about 2:05 to 3:00 am IST on November 18, which is when many nightly builds and scheduled image rebuilds run. The Hacker News also reported the incident.

How does a .pth file run the stealer without an import?

This is the part that makes the incident worse than a normal bad package. When the Python interpreter starts, its site module scans the site-packages directory for files ending in .pth. Most of these files list extra import paths. Any line that starts with import, though, is run as Python code on every interpreter start.

Both malicious wheels dropped a .pth file into site-packages. According to Socket's analysis, 1.26.1 added agent_framework_meta.pth, which imports agent_framework_meta and starts the payload in agent_framework_meta/_telemetry.py. Version 1.26.2 switched to af_runtime_diag.pth and af_runtime_diag.py.

Diagram of the agent-framework PyPI compromise: Python start loads a .pth file in site-packages, which launches a credential stealer
The stealer ran at every Python start, then sent compressed data to a webhook[.]site URL (based on Socket, SafeDep and Endor Labs analyses).

That design has three consequences:

  • No import is needed. The stealer runs whenever Python starts in that environment. That includes your app, your test runner, a stray python -c and, as Endor Labs points out, pip itself.

  • The install step is enough. SafeDep reports that the stealer runs on pip install without the package ever being imported.

  • A code review of the package misses 1.26.2. Socket reports that 1.26.2 restored the legitimate agent_framework_meta/__init__.py byte for byte. Anyone who compares only the package's own module against 1.26.0 sees no change.

Socket says the collector forks and detaches on Unix, and uses a daemon thread on platforms without fork. There is no marker on disk, so a fresh process tree can trigger collection again. SafeDep found an in-memory run-once marker, the environment variable _AF_TEL. Endor Labs found that neither release changes the actual Agent Framework code or pulls in a malicious dependency.

What the agent-framework stealer collects

The stealer doesn't just copy secrets already on disk. SafeDep and Socket both report that it asks identity endpoints for fresh tokens, so a machine with no stored secrets can still leak working cloud access through its managed identity. The table combines Socket's and SafeDep's findings.

TargetWhat it takesVersion
Its own environment variablesNames containing TOKEN, SECRET, KEY, AZURE, AWS, GITHUB, OPENAI, HF_, FOUNDRY, TENANT, CLIENT or MANAGED (Socket). SafeDep counts 31 substrings, including NPM and PIP.Both; 1.26.2 adds ACTIONS, OIDC, RUNNER and ARM_
Other processes' environments/proc/*/environ entries matching TOKEN, SECRET, PASSWORD, KEY=, SYSTEM_ACCESSTOKEN or IDENTITY_HEADER. SafeDep says it reads up to 300 processes, which can expose other jobs on shared or self-hosted runners.Both; 1.26.2 adds ACTIONS_ID_TOKEN
Azure managed identity (IMDS)Requests new tokens for Resource Manager, AI, ML, Cognitive Services, Storage, Key Vault, Search, Graph, Container Registry and Azure DevOps (SafeDep)Both
Azure CLI~/.azure/*.json filesBoth
Azure DevOpsUses SYSTEM_ACCESSTOKEN and SYSTEM_OIDCREQUESTURI to request a federated token for api://AzureADTokenExchange; reads agent .credentials filesBoth
GitHub Actions OIDCRequests OIDC tokens for api://AzureADTokenExchange and https://management.azure.com/, which only works in jobs with id-token: write; reads /home/runner/work/_temp/* and /home/runner/.azure/1.26.2 only
Registry and git credentialspip.conf, .npmrc, .netrc, .git-credentials, Docker config.jsonBoth
AI service credentialsHugging Face token, Azure AI Foundry configBoth
Application files.env and JSON config files in /app and /workspace, token*.json under .config. SafeDep says up to 60 files under 256 KB each.Both
Host detailsHostname, user, working directory and sys.argv (SafeDep)Both

SafeDep says the data is serialized to JSON, compressed with zlib, Base64-encoded and sent in an HTTPS POST to a webhook[.]site URL, with a 25-second timeout and all errors suppressed. Socket adds that the payload doesn't download or run any further code. In other words, this is a smash-and-grab of credentials, not a persistent backdoor. The damage depends on what those credentials can reach.

Am I affected? How to check without running the bad code

Start with one rule from Endor Labs: don't run the suspected environment's Python or pip, because every start runs the collector again. That rules out pip show agent-framework and pip list as first checks. Read the disk instead.

  1. Search lock files and requirements in your repositories. Exact pins show up directly. In Poetry and uv lock files, the name and version sit on adjacent lines.

    # requirements files with an exact pin
    grep -RnE 'agent-framework *===? *1\.26\.[12]' --include='requirements*.txt' .
    
    # poetry.lock and uv.lock
    grep -RnA1 --include='poetry.lock' --include='uv.lock' 'name = "agent-framework"$' . \
      | grep -E 'version = "1\.26\.[12]"'
    
    # Pipfile.lock (JSON)
    jq -r '.default["agent-framework"].version, .develop["agent-framework"].version' Pipfile.lock

    A loose range such as agent-framework>=1.26 won't show up here, but it would have resolved to a bad version during the window. That makes step 2 the more reliable check.

  2. Search CI logs from November 17 onward. pip prints the wheel name and the "Successfully installed" line, so search for both spellings of the name. For GitHub Actions, the gh CLI can loop over runs:

    for id in $(gh run list --created '>=2026-11-17' --limit 500 --json databaseId -q '.[].databaseId'); do
      gh run view "$id" --log 2>/dev/null | grep -qE 'agent[-_]framework-1\.26\.[12]' \
        && echo "run $id installed a malicious version"
    done

    In Azure DevOps, search the pipeline logs for the same pattern. Endor Labs also suggests checking dependency caches and any container image built after 20:35 UTC that installs Python packages.

  3. Look for the hook files on disk. This command, based on the indicators from Wiz and Endor Labs, covers virtualenvs, system Python and conda environments:

    find / \( -name 'agent_framework_meta.pth' -o -name 'af_runtime_diag.pth' \
      -o -name 'af_runtime_diag.py' -o -path '*agent_framework_meta/_telemetry.py' \
      -o -name 'agent_framework-1.26.[12].dist-info' \) 2>/dev/null

    On Windows, use PowerShell:

    Get-ChildItem -Path C:\ -Recurse -Force -ErrorAction SilentlyContinue `
      -Include agent_framework_meta.pth,af_runtime_diag.pth,af_runtime_diag.py

    If anything turns up, run sha256sum on it and compare against the hashes in the indicator table below.

  4. Check container images without starting Python. Override the entrypoint so only the shell runs:

    docker run --rm --entrypoint sh your-image:tag -c \
      "find / -name 'agent_framework_meta.pth' -o -name 'af_runtime_diag.pth' 2>/dev/null"
  5. Check running processes for the marker. Run this as root so you can read other processes' environments:

    grep -la '_AF_TEL=1' /proc/*/environ 2>/dev/null
  6. Check proxy, firewall and DNS logs. Search for the path d381fd80-ec62-42ad-8f5c-d1b15103c9bb and the User-Agents af-runtime-diagnostics/1 and runtime-diagnostics/1. Endor Labs advises matching the full path, because webhook.site is a legitimate service your teams may use. Wiz notes that a 200 response means the data was accepted, while a 410 or 429 means it was rejected.

One more place to look: your company's package mirror. If Artifactory, Nexus or devpi cached either wheel before PyPI quarantined it, internal installs could keep getting it.

What to remove, rebuild and rotate, in order

Wiz's advice is to treat any affected host as compromised, because any Python process started there ran the payload. The order of the steps matters. Clean the machine before you rotate, and rotate from a machine you know is clean.

  1. Isolate the host or container. Cut its network access and keep its process listings and egress logs as evidence, as Endor Labs recommends.

  2. Remove the payload without starting the affected interpreter. Delete the two .pth files, the payload modules, their __pycache__ entries and the agent_framework-1.26.x.dist-info directory. Endor Labs prefers rebuilding from a clean image or a fresh virtualenv. Throw away ephemeral and self-hosted runners rather than cleaning them.

  3. Clear caches. Delete the wheel from ~/.cache/pip, or run uv cache clean, using a clean environment. Block 1.26.1 and 1.26.2 in your package proxy.

  4. Pin and reinstall 1.26.0. Use hashes (more on that below). SafeDep advises waiting for Microsoft to confirm that any newer release is clean before upgrading.

  5. Rotate everything the machine could reach, from a clean machine. Wiz's list includes every secret in the environment, Azure CLI sessions, Azure DevOps PATs and service connections, npm, PyPI, NuGet, Docker and Hugging Face tokens, and git credentials. Add OpenAI and other model-provider keys, which match the stealer's patterns. For a service principal secret, az ad sp credential reset --id <appId> issues a new one.

  6. Handle managed identities separately. There is no secret to rotate, and Endor Labs notes that access tokens already issued generally can't be revoked before they expire. Wiz says stolen tokens may stay valid for up to 24 hours. Endor Labs suggests temporarily removing role assignments from the affected identities until that window has passed.

  7. Review GitHub Actions jobs that ran 1.26.2. If a job had id-token: write, Wiz says to treat its OIDC tokens as exposed. Review the Entra ID federated credentials they map to, and rotate the repository and organization secrets that job could see. ByteMuni's guide to checking your GitHub Actions secrets after the Gheist attack walks through finding which secrets a workflow exposes.

  8. Read the logs from the install time onward. In Entra ID, check the managed identity and service principal sign-in logs. In Azure, pull the activity log for each affected identity, for example az monitor activity-log list --caller <principal-id> --start-time 2026-11-17T20:30:00Z. SafeDep warns that rotation alone doesn't revoke tokens already issued, which is why this review is part of the fix, not an extra.

Indicators of compromise for agent-framework 1.26.1 and 1.26.2

These indicators for the agent-framework PyPI compromise match across SafeDep, Socket and Wiz. The exfiltration URL is defanged on purpose; don't turn it back into a link.

TypeValueVersion
Packageagent-framework==1.26.1, agent-framework==1.26.2Both
Fileagent_framework_meta.pth, agent_framework_meta/_telemetry.py1.26.1
Fileaf_runtime_diag.pth, af_runtime_diag.py1.26.2
Wheel SHA256d27fa34414e6201d5e03e559ef634f020057554d7b3f4898dd5d7cd3e989e1101.26.1
Wheel SHA2563d20a8bc91351a9a16b6db243b848ceca0206b7a8623b02d2af553a9c9f7e0a91.26.2
_telemetry.py SHA25639fa329f2a93f734b0bb8f5adb203ea3331d1ae479832a5015a54cb17aabd6631.26.1
af_runtime_diag.py SHA25654d885b7d7161c9ed96489c66364c4bfbf635929166843bba10d97d46b5a2e1f1.26.2
agent_framework_meta.pth SHA25621f28e8517a10ffe431f8d68f5875c85eca4001ae6d118322b0a41873998eb5e1.26.1
af_runtime_diag.pth SHA256325e7e9f0ec94e41ad1a1b7a3f18a6b8b5bffece2e2b97b8d3369eb967452f931.26.2
Exfiltration URLhxxps://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb?t=telemetryBoth
User-Agentaf-runtime-diagnostics/1 (1.26.1), runtime-diagnostics/1 (1.26.2), per SafeDep and WizBoth
Process markerEnvironment variable _AF_TEL=1Both

What is still unknown as of November 18, 2026

Several basic facts about the agent-framework PyPI compromise are still open, and you shouldn't fill the gaps with guesses.

  • No formal Microsoft advisory. By our search, Microsoft had not published a Security Response Center advisory, a GitHub Security Advisory or an OSV malware entry for this package. Wiz and SafeDep cite none either. The only Microsoft response we found was second-hand: FourWeekMBA reports that a Microsoft maintainer replied to Upwind researcher Lidor Machluf's GitHub report with "The compromised versions for agent-framework: 1.26.1, 1.26.2 have been pulled from the package feed". We couldn't open that GitHub thread ourselves.

  • How the attacker got publishing access. Wiz says the root cause has not been confirmed. Wiz and SafeDep both mention that another Microsoft Python package, durabletask, was compromised earlier in 2026; Wiz says that happened after its PyPI token was stolen. Both say there is no evidence the two incidents are linked. Endor Labs adds only that the uploads came from an account or token with publishing rights, and that the second upload 33 minutes later suggests the access lasted after the first. Stolen publishing keys are a familiar pattern, as in the Claude Code extension trojanized through a stolen key, but nothing yet says that is what happened here.

  • How many installs. SafeDep says the install count for the bad versions is unknown.

  • Provenance as a signal. Endor Labs found no PyPI provenance attestation on either malicious wheel, but 1.26.0 doesn't have one either. A missing attestation doesn't tell the bad uploads apart from good ones.

My take on pinning AI SDKs in CI

My read is that the startup hook is the lasting lesson, not the brand name on the package. AI SDKs ship often, sit in CI jobs that hold cloud identities, and get installed with loose version ranges because teams want the newest model support. That combination gave this attacker an hour-long window in which a routine nightly build was enough.

Three habits would have closed most of that window:

  • Pin with hashes. pip's hash-checking mode refuses any file whose hash isn't in your requirements. Generate the whole file rather than writing hashes by hand, because --require-hashes needs a hash for every dependency:

    # pip-tools
    pip-compile --generate-hashes requirements.in
    
    # uv
    uv pip compile requirements.in --generate-hashes -o requirements.txt
    
    # install
    pip install --require-hashes -r requirements.txt

    Endor Labs lists 14267ec8e6929c139015f8ec918adc638a71c7656901413426bb30ab199b6d71 as the SHA256 of the 1.26.0 wheel. Check it against PyPI's file details before you trust it.

  • Don't auto-upgrade in CI, and add a delay. Endor Labs recommends a minimum release age in your package proxy. uv's --exclude-newer option does something similar on the client side by ignoring anything uploaded after a given date. A delay of even a day would have skipped both bad versions here.

  • Publish with Trusted Publishing and attestations, and scope OIDC. Endor Labs makes a fair point: PyPI Trusted Publishing with attestations wouldn't stop a stolen token from uploading, but a consistent history of attested releases makes an unattested upload stand out. On the consuming side, give id-token: write only to jobs that deploy.

Two cheap checks are worth adding to any review of a new dependency. Endor Labs suggests treating a release that suddenly drops its sdist as suspicious; both bad versions here were wheel-only. And before you install a wheel you're unsure about, list what's inside it: unzip -l package.whl | grep '\.pth$'. We covered the wider pattern of trusted vendor code turning hostile in our Optimizely supply chain attack explainer.

The bottom line on the agent-framework PyPI compromise

If none of your lock files, CI logs, images or disks show 1.26.1 or 1.26.2, pin agent-framework==1.26.0 with hashes, block the two bad versions in your proxy, and move on. If any of them do, the package is the smaller problem. Rebuild that machine or runner, rotate every credential it could reach from a clean machine, and read your Entra ID and Azure activity logs from 20:35 UTC on November 17. Hold off on any newer release until Microsoft says it's clean.

Frequently asked questions

Is agent-framework 1.26.0 safe to install?

Wiz, SafeDep and Endor Labs all name 1.26.0 as the last clean release, published on November 12, 2026, before the malicious uploads. Pin it with a hash, and wait for Microsoft to confirm that any newer release is clean before upgrading.

I only installed agent-framework and never imported it. Am I still affected?

Yes. The malicious wheels added a .pth file to site-packages, and Python runs import lines in .pth files at every interpreter start, so any Python process in that environment ran the stealer.

Can I run pip show agent-framework to check?

Not on an environment you suspect. Starting pip starts Python, which runs the stealer again, so search the disk for the .pth files and the 1.26.1 or 1.26.2 dist-info folders instead.

Does deleting the package or rotating secrets cancel tokens that were already stolen?

Not fully. Endor Labs notes that access tokens already issued generally can't be revoked before they expire, and Wiz says stolen tokens may stay valid for up to 24 hours, so you also need to review sign-in and activity logs.

Were the agent-framework-core or .NET packages affected?

The research reports name only the agent-framework package at 1.26.1 and 1.26.2. Wiz notes that 1.26.1 depended on agent-framework-core 1.26.0, and none of the sources report malicious versions of other packages.

How did the attacker get permission to publish under Microsoft's account?

That is not known as of November 18, 2026. Wiz says the root cause is unconfirmed, and both Wiz and SafeDep say there is no evidence linking it to the earlier durabletask compromise.

Concepts in this article

AI agents
Systems where a model plans and takes actions with tools in a loop toward a goal.
Active Directory
Microsoft's directory service for Windows domain identities and permissions.
Artificial intelligence
Computer systems that perform tasks that normally need human intelligence.
GitHub
A hosting platform for Git repositories, issues and CI.
GitHub Actions
GitHub's built-in CI/CD workflow system.
Hugging Face
A hub and set of libraries for sharing and running machine-learning models.
OAuth
A standard for granting an app limited access to an account without sharing the password.
Python
A general-purpose language widely used for scripting, web back ends and machine learning.

How we research, write and check articles

Written by

· Senior Software Engineer

Deepak Kumar is a Senior Software Engineer based in New Delhi. He maintains production systems with millions of readers, where a missed patch is an incident rather than a headline. He started ByteMuni to publish clear, source-checked guides for working developers.