AI

Microsoft agent-framework PyPI Hijack: How Two Malicious Releases Used .pth Hooks to Steal AI and Cloud Keys

On November 17, 2026, attackers published two malicious releases (1.26.1 and 1.26.2) of Microsoft's official agent-framework Python AI SDK on PyPI within 33 minutes. Using .pth startup hooks that fire on every Python invocation—even without importing the package—the payload harvested environment variables, /proc/*/environ secrets, and cloud/AI keys, and attempted to mint Azure DevOps, GitHub Actions OIDC, and Azure managed-identity tokens. This defensive incident breakdown covers the full timeline, SHA-256 IOCs, safe non-Python containment steps, and token revocation.

By 0xScorPionSon

6 min read

Microsoft agent-framework PyPI Hijack: How Two Malicious Releases Used .pth Hooks to Steal AI and Cloud Keys

Microsoft agent-framework PyPI supply chain hijack infographic

Executive Summary

On November 17, 2026, attackers compromised publishing access for Microsoft's official agent-framework Python package on PyPI—the umbrella SDK for building and orchestrating AI agents on Azure and OpenAI, averaging roughly 192,534 downloads per month (Help Net Security). Within 33 minutes, the attackers shipped two malicious wheel-only releases: 1.26.1 at 20:35:20 UTC and 1.26.2 at 21:08:39 UTC, just 2 minutes and 23 seconds after PyPI quarantined 1.26.1 (StepSecurity).

Both releases preserved the clean dependency pin (agent-framework-core[all]==1.26.0) so AI agent code continued functioning normally, while silently planting .pth startup hooks (agent_framework_meta.pth in 1.26.1 and af_runtime_diag.pth in 1.26.2) in site-packages. Because Python's site module executes import lines inside .pth files automatically at interpreter startup, any Python invocation (pip, pytest, linters, or build scripts) triggered the stealer—even if agent_framework was never imported.

PyPI quarantined both 1.26.1 and 1.26.2 by 21:16:44 UTC, leaving 1.26.0 (published November 12, 2026) as the latest clean release. However, because the payload also attempted to mint fresh Azure DevOps, GitHub Actions OIDC, and Azure Managed Identity tokens, teams that installed either version during the 45-minute window must isolate hosts before running python or pip, rotate static secrets, and audit federated identity trusts.

Confidence Level: High for timeline timestamps, .pth mechanics, SHA-256 hashes, and exfiltration endpoint (webhook.site)—corroborated across StepSecurity, Aikido Security, and Help Net Security. Note that StepSecurity cautions static analysis confirms the attempts to request OIDC/IMDS tokens, not whether every target environment successfully issued them, and the initial PyPI publishing compromise vector remains unconfirmed.


Technical Mechanics and Architecture

1. Why .pth Startup Hooks Bypass Import-Time Controls

Python wheels do not execute setup.py install scripts, making .pth files in site-packages the functional equivalent of an npm postinstall hook—with a nastier persistence property: they run on every subsequent Python interpreter launch unless -S is passed.

[pip install agent-framework==1.26.1 / 1.26.2 (20:35–21:20 UTC, Nov 17)]
        │
        ▼  Writes .pth hook into site-packages (no code runs at install)
[Next Python Launch (pytest, pip, CI script — NO import needed)]
        │
        ▼  site.py executes `import af_runtime_diag` (1.26.2)
┌─────────────────────────────────────────────────────────────────┐
│  1. Sets _AF_TEL=1 guard & forks detached child (setsid())      │
│     (Windows fallback: daemon thread)                           │
│  2. Harvests Env Vars (35 patterns: AZURE, AWS, OPENAI, HF_, …) │
│  3. Scrapes /proc/[0-9]*/environ (first 300 processes)          │
│  4. Reads up to 80 credential files (~/.azure, .env, Docker)    │
│  5. Attempts Token Minting:                                     │
│     ├─ Azure DevOps OIDC (SYSTEM_OIDCREQUESTURI)                │
│     ├─ GitHub Actions OIDC (ACTIONS_ID_TOKEN_REQUEST_URL)       │
│     └─ Azure IMDS 169.254.169.254 (12 Azure/AI resources)       │
└─────────────────────────────────────────────────────────────────┘
        │
        ▼  zlib + base64 POST (User-Agent: runtime-diagnostics/1)
[https://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb]

2. Evolution Between 1.26.1 and 1.26.2 in 33 Minutes

As documented by Aikido Security and StepSecurity, the attacker adapted rapidly after 1.26.1 was quarantined:

  • Iteration 1 (1.26.1): Placed agent_framework_meta.pth (import agent_framework_meta) at the wheel root, added agent_framework_meta/_telemetry.py, and appended an 8-line loader to agent_framework_meta/__init__.py.
  • Iteration 2 (1.26.2): Restored agent_framework_meta/__init__.py to its byte-identical 1.26.0 state to evade package-directory diffs, moved the payload to top-level af_runtime_diag.py (7,658 bytes) + af_runtime_diag.pth (23 bytes), raised the credential file cap from 60 to 80 files, added GitHub Actions OIDC token minting (api://AzureADTokenExchange and https://management.azure.com/), and added /home/runner/work/_temp/* and /home/runner/.azure/* to file globs.

Safe Non-Python Containment & Audit Commands

Critical Warning: Do not start containment by running pip show, pip uninstall, or python inside a suspected environment—starting the Python interpreter will execute the .pth hook again. Use OS-level, non-Python file inspection first:

# 1. Search site-packages and container filesystems WITHOUT invoking Python
find / -type f \( -name "agent_framework_meta.pth" -o -name "af_runtime_diag.pth" \
  -o -name "af_runtime_diag.py" -o -name "_telemetry.py" \) 2>/dev/null

# 2. Inspect installed distribution METADATA without running Python
grep -rnE "^Version:\s*1\.26\.(1|2)$" /usr/local/lib/python*/site-packages/agent_framework-*.dist-info/METADATA \
  ~/.local/lib/python*/site-packages/agent_framework-*.dist-info/METADATA 2>/dev/null

# 3. Check running processes for the _AF_TEL=1 anti-recursion marker (Linux)
grep -l "_AF_TEL=1" /proc/[0-9]*/environ 2>/dev/null

Evidence: Timeline, Package Forensics, and Verified IOCs

Forensic Anomalies & Timeline (November 12–17, 2026)

  • November 12, 2026 (18:24 UTC): Clean agent-framework==1.26.0 published (both wheel and source distribution sdist, 40 seconds apart).
  • November 17, 2026 (20:35:20 UTC): Maintainer account vibiret added; malicious 1.26.1 uploaded (wheel-only, uploader User-Agent RestSharp/106.13.0.0, no provenance attestation, injected files world-writable rw-rw-rw-).
  • November 17, 2026 (21:06:16 UTC): PyPI quarantines 1.26.1.
  • November 17, 2026 (21:08:39 UTC): Attacker publishes 1.26.2 (wheel-only, RestSharp User-Agent, GitHub Actions OIDC targeting).
  • November 17, 2026 (21:16:44 UTC): PyPI quarantines 1.26.2; 1.26.0 restored as latest.

Verified Indicators of Compromise (IOCs)

Indicator Type Value Notes
Wheel 1.26.1 (SHA-256) d27fa34414e6201d5e03e559ef634f020057554d7b3f4898dd5d7cd3e989e110 Quarantined on PyPI
Wheel 1.26.2 (SHA-256) 3d20a8bc91351a9a16b6db243b848ceca0206b7a8623b02d2af553a9c9f7e0a9 Quarantined on PyPI
Hook 1.26.2 (af_runtime_diag.pth) 325e7e9f0ec94e41ad1a1b7a3f18a6b8b5bffece2e2b97b8d3369eb967452f93 Top-level site-packages
Payload 1.26.2 (af_runtime_diag.py) 54d885b7d7161c9ed96489c66364c4bfbf635929166843bba10d97d46b5a2e1f Top-level site-packages
Exfiltration Endpoint https://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb?t=telemetry POST, application/octet-stream
HTTP User-Agents af-runtime-diagnostics/1 (1.26.1), runtime-diagnostics/1 (1.26.2) Searchable in proxy/egress logs

Hardening Playbook: Containment, Secret Rotation, and CI/CD Defense

Step 1: Isolate Exposed Environments Before Running Python

If any developer machine, container image, or CI runner resolved agent-framework between 20:35 UTC and 21:20 UTC on November 17, 2026 (including via loose constraints like agent-framework>=1.26 or Dependabot/Renovate PRs), isolate it from the network immediately. Do not run pip uninstall in place; inspect via find/grep and rebuild the container or virtual environment from a clean base.

Step 2: Pin Clean Versions and Purge Caches

Pin agent-framework==1.26.0 using hash-pinned lockfiles (pip-compile --generate-hashes, uv.lock, or poetry.lock). Purge local pip caches, CI dependency caches, and internal PyPI mirrors (Artifactory, Nexus, Azure Artifacts) that may still cache 1.26.1 or 1.26.2 even after PyPI quarantined them.

Step 3: Rotate Static Secrets and Audit Federated Identity

Treat every credential readable from the host or /proc/*/environ as compromised:

  • Rotate Azure service principal secrets, Azure DevOps PATs, OpenAI/Azure AI Foundry/Hugging Face API keys, GitHub/PyPI/npm/Docker tokens, and .env secrets.
  • Audit Entra ID sign-in logs, GitHub Actions id-token: write permissions, Azure DevOps service connections, and Managed Identity role assignments. As StepSecurity notes, deleting a federated trust stops future exchanges, but may not revoke already-issued short-lived access tokens.

Step 4: Hunt Egress Logs and Enforce CI Controls

Search DNS, firewall, and proxy logs since November 17 for webhook[.]site (and specifically /d381fd80-ec62-42ad-8f5c-d1b15103c9bb), distinguishing blocked attempts from completed transfers. Going forward, enforce egress allowlisting on CI runners, ephemeral single-use runners, and a package cooldown period (e.g., 48 hours) on automated dependency updates.

Step 5: Safe Rollback Verification

After rebuilding affected environments on agent-framework==1.26.0, verify zero .pth anomalies remain in site-packages before re-attaching production AI service credentials.


Frequently Asked Questions (FAQs)

1. Am I affected if my code never imported agent_framework after pip install? Yes. Both 1.26.1 and 1.26.2 installed .pth startup hooks in site-packages, which Python's site module executes automatically on every interpreter launch—including running pytest, pip, or any unrelated Python script in that environment.

2. Why shouldn't I run pip uninstall agent-framework to clean up an infected host? Because pip itself is a Python process. Launching pip triggers site.py, which executes the .pth hook one more time before pip can uninstall the package. Isolate the host first and inspect or rebuild without starting Python.

3. Were satellite packages like agent-framework-openai or agent-framework-core also compromised? According to StepSecurity's preserved investigation, agent-framework-openai, agent-framework-redis, agent-framework-postgres, agent-framework-purview, and agent-framework-tools showed no uploads after November 12 at the time of inspection, and 1.26.1/1.26.2 depended on the genuine agent-framework-core[all]==1.26.0.

4. Which version of agent-framework is safe to pin? Version 1.26.0 (published November 12, 2026) is the last verified clean release. Always pin with SHA-256 hashes in your lockfile and clear internal PyPI proxy caches.

5. Why did the attacker release 1.26.2 33 minutes after 1.26.1? After PyPI quarantined 1.26.1 at 21:06:16 UTC, the attacker still held publishing access and uploaded 1.26.2 at 21:08:39 UTC—restoring __init__.py to avoid directory diffs, moving the payload to af_runtime_diag.pth, and adding GitHub Actions OIDC token theft.


Sources

More on AI

AI

GPT-6.2 Astra vs Gemini 4 Carbon and Claude Opus 5.5: Token Cost Inversion, Code Review Noise, and Jailbreak Regressions

OpenAI launched GPT-6.2 Astra and Sol on November 17, 2026, alongside a new System Card and Codex sandbox architecture. While Astra leads Claude Opus 5.5 on Intelligence Index v5.0.1 (62.1 vs 59.1) and costs 2.5x less per task despite double the rate-card price, teams face a 272K long-prompt surcharge, noisier PR review comments, and a reported universal jailbreak regression. Here is how Astra, Sol, Gemini 4 Carbon, and Claude Opus 5.5 compare.

7 min read

AI

LiteLLM Proxy Flaw (CVE-2026-40217) Added to CISA KEV: How Guardrail Bytecode Rewriting Enables LLMjacking

On November 18, 2026, CISA added BerriAI LiteLLM CVE-2026-40217 (CVSS 3.1: 8.8) to its Known Exploited Vulnerabilities catalog with a December 2 deadline under BOD 26-04. Attackers are exploiting the /guardrails/test_custom_code sandbox escape in LLMjacking campaigns to steal provider API keys and run code as root in default Docker containers. Learn why you must target 1.83.11+ rather than 1.83.10 and how to block the endpoint at your gateway.

7 min read

Tell us what is not working

A thirty-minute call, no deck and no obligation. You will leave with a straight answer about whether this is worth building - including if that answer is no.

Start a project

Direct line

hello@codebumble.net
Dhaka, Bangladesh  :   local timeCalls in English or Bangla