· via dev.to (home feed)
Malicious Microsoft Agent Framework PyPI releases appeared with no matching git commits
Malicious versions of Microsoft's Agent Framework landed on PyPI with no matching repo changes, harvesting cloud credentials at Python startup. The split between registries and source control leaves consumers exposed.

What happened
According to a dev.to analysis, versions 1.26.1 and 1.26.2 of Microsoft's Agent Framework package were published to PyPI carrying code designed to steal cloud credentials as soon as the Python interpreter starts. The project's GitHub repository, however, shows nothing unusual: no matching commits, clean pull requests, and branch protection that was never visibly broken. The malicious code exists only in the registry, not in the source history — a divergence the article's author describes as a "phantom commit" attack.
Why the registry can diverge from the repository
The write-up attributes the problem to how source control and package registries are wired together. PyPI is a storage and distribution service for built archives such as wheels, not a mirror of a Git repository. When a release is uploaded with an API token or an OpenID Connect exchange, PyPI checks only that the presenter is authorized to publish under that project name. It does not unpack the wheel, locate the corresponding commit hash, or verify that the files inside match reviewed source lines.
That decoupling creates a direct route from stolen credentials to code execution. An attacker who obtains a long-lived PyPI token, or who compromises a build environment or OIDC trust configuration, can assemble a wheel on their own infrastructure, inject a startup hook, and upload it directly to the index while the upstream repository stays clean.
How the payload executes
The delivery mechanism described in the article relies on Python's own initialization sequence. A crafted .pth file placed in site-packages is scanned by the interpreter's site module during startup, and any line beginning with import is executed before application code ever loads.
The payload then reads ambient secrets — environment variables such as AWS_SECRET_ACCESS_KEY and AZURE_CLIENT_SECRET, files like ~/.aws/credentials, and the cloud metadata endpoint at 169.254.169.254 — and exfiltrates them in an HTTP request header to an attacker-controlled endpoint. The write-up estimates the entire sequence completes in under 15 milliseconds, and notes that because it runs during interpreter initialization, application code cannot intercept it.
Why provenance is not enforced
A natural question is why PyPI does not require a verified commit or build provenance for every update. The article points to practical friction: reproducible builds in Python are brittle, since timestamps, build paths and native extensions easily change archive hashes even when source code does not. Many maintainers also publish from laptops, private runners or non-GitHub workflows, and universal provenance gates would slow urgent security patches. Provenance therefore remains optional, which is what lets unattested uploads through.
What the article recommends
The dev.to piece ranks the available controls. Long-lived API bearer tokens are the weakest option, since one leaked secret grants upload capability from anywhere until revoked. OIDC Trusted Publishing combined with provenance attestations is the strongest publisher-side measure, because short-lived credentials are issued only to a specific repository and workflow run, tying the artifact's digest to build metadata. Even OIDC can fail, though, if workflow permissions are overly broad, if a compromised dependency runs inside the build pipeline, or if the workflow configuration itself is altered.
On the consumer side, the recommendation is to pin exact versions with cryptographic hashes via --require-hashes, and to mirror or delay adopting brand-new releases rather than running an unpinned pip install. Relying on takedowns is not a defense: removal happens only after publication, so CI jobs, container builds and developer shells can pull and execute a malicious wheel during the window between upload and removal.
Why it matters
This incident shows that a clean repository is no longer evidence that a release is safe. Upload authority and commit history are separate systems, and an attacker who bridges the gap gets code execution in every environment that installs the package — especially CI runners, containers and AI agents that carry ambient cloud credentials. Trust has to be established at the artifact level, through attestations and hash pinning, rather than inferred from what the source repository happens to show. Teams that assume a well-known vendor's package or PyPI's response time substitutes for those controls are exposed during exactly the window this attack exploited.
- #pypi
- #python
- #supply-chain-security
- #package-management
- #cloud-credentials