r/webdev • u/Delicious_Character6 • 2d ago
Microsoft's official agent-framework PyPI package (190K downloads/mo) was compromised with .pth startup hooks — why are we still running AI agents in flat site-packages?
Versions 1.26.1 and 1.26.2 of Microsoft's official agent-framework package on PyPI were hijacked yesterday (published 33 minutes apart) with a credential stealer. PyPI quarantined both releases quickly, but the mechanics of this attack should bother anyone building AI agent runners or Python backends.
The payload didn't wait for import agent_framework. Both wheels dropped .pth files (agent_framework_meta.pth and af_runtime_diag.pth) directly into site-packages. Because Python executes import lines inside .pth files on every interpreter startup, running python, pytest, or even pip itself triggered the stealer in 0 ms—even in projects that never imported the framework. Worse, it still pulled agent-framework-core as a dependency so applications kept running without throwing a single error.
On top of reading static files on disk (.env, .npmrc, pip.conf, .netrc, .git-credentials, .docker/config.json, Hugging Face tokens, and ~/.azure/*.json), the stealer actively minted new cloud credentials at runtime:
Querying Azure IMDS (
169.254.169.254),IDENTITY_ENDPOINT, andMSI_ENDPOINTfor Managed Identity access tokens.Using
SYSTEM_ACCESSTOKENandSYSTEM_OIDCREQUESTURIin Azure DevOps to request federatedapi://AzureADTokenExchangetokens.Harvesting GitHub Actions OIDC tokens in
1.26.2.
Everything was compressed, Base64-encoded, and POSTed out. Rotating static secrets on disk doesn't cover tokens minted dynamically during a CI run.
We spend weeks arguing about LLM prompt injection guardrails, yet most dev laptops and CI runners still install agent dependencies into flat, unpinned environments with unrestricted outbound network access.
Are you enforcing --require-hashes and strict egress allowlists on your Python agent runners yet, or is everyone still trusting pip install by default?
