News Application Security

Microsoft Agent Framework PyPI Releases Poisoned With Credential Stealer

Two malicious releases of Microsoft's agent-framework Python meta-package were published to PyPI and quarantined the same day. According to Wiz, they ran a credential stealer on every Python interpreter start and targeted Azure and CI pipeline identities.

Published
Line-art parcel with a key slipping out of an open seam, representing a poisoned Python package stealing credentials

Key takeaways

  • Two malicious agent-framework releases reached PyPI and were quarantined the same day, per PyPI's release history.
  • Wiz reports the payload ran from a .pth file at Python interpreter start, so it executed even when the package was never imported.
  • The stealer targeted Azure managed-identity and Azure DevOps tokens, credential files, and in the second release GitHub Actions OIDC tokens, according to Wiz.
  • How the attacker gained publishing access is unconfirmed; Wiz found no matching tag in the GitHub repository and the first malicious release was wheel-only.
  • Affected teams should pin to the last clean release, hunt for the .pth files, and rotate every credential reachable from affected runners.

Two malicious releases of agent-framework, the Python meta-package for Microsoft's Agent Framework, were published to PyPI roughly half an hour apart and quarantined the same day. PyPI's release history marks both as quarantined and shows the release before them as the most recent clean one. Wiz, which published a detailed analysis, puts the window between the first malicious upload and removal at about an hour.

Execution without import #

The important detail for defenders is how the payload ran. Wiz reports that each release dropped a .pth file into site-packages: agent_framework_meta.pth in the first and af_runtime_diag.pth in the second. Python processes .pth files at interpreter start, so the stealer executed on every Python invocation in that environment, even if the package was never imported. Tooling that only reasons about imported code will not see it.

What it took #

According to Wiz, the stealer targeted:

  • Secret-like environment variables, including those of other processes
  • Credential files, including Azure CLI, npm, pip, git and Docker configs
  • Azure managed-identity tokens and Azure instance metadata
  • Azure DevOps OIDC tokens
  • In the second release, GitHub Actions OIDC tokens in workflows with id-token: write

The OIDC theft is the part CI/CD owners should focus on. A stolen token can be exchanged for whatever cloud role the workflow federates to, so the blast radius is defined by your trust policies, not by the secrets stored on the runner.

Wiz reports exfiltration was a single HTTPS POST to a hard-coded webhook.site URL. It also notes the attacker's webhook token had a request cap of 100, with at most 50 requests observed. That is a Wiz figure, and it suggests a limited number of successful exfiltrations, not a guarantee.

How it got there is unconfirmed #

Wiz found no matching tag or release in the project's GitHub repository and notes the first malicious release was wheel-only, while legitimate releases ship a wheel plus a source distribution. That points to an upload outside the normal release process, but Wiz says the root cause is unconfirmed. SecurityWeek reports that a project maintainer confirmed in a GitHub discussion that the releases were removed and an investigation is underway.

Wiz says the package sees almost 200k downloads a month, again a vendor figure.

What to do #

  • Search lockfiles, container images, build caches and CI logs for the two quarantined releases listed on PyPI.
  • Pin to the last clean release and verify hashes.
  • Look for the two .pth filenames in site-packages on developer machines and runners.
  • Rotate every credential reachable from an affected environment, and review cloud audit logs for use of OIDC-federated roles from unexpected sources.
  • Review outbound connections to webhook.site from build infrastructure.

Sources

  1. Microsoft agent-framework Compromised: Credential Stealer Targets Azure and CI Pipelines, Wiz
  2. agent-framework · PyPI (release history), PyPI
  3. Microsoft Agent Framework Releases Poisoned With Credential Stealer, SecurityWeek
  4. Attackers Compromise Microsoft's Agent Framework PyPI Package to Steal Cloud Credentials, The Hacker News

Questions this raises

Do I need to have imported agent-framework to be affected?
No. Wiz reports the malicious releases installed a .pth file into site-packages, which Python processes at interpreter start. Installing the package in an environment was enough for the stealer to run on the next Python invocation.
How did the attacker publish to the package?
That is not known. Wiz found no corresponding tag or release in the project's GitHub repository and notes the first malicious release was wheel-only, but says the root cause is unconfirmed.
Which credentials should be rotated?
Anything reachable from an environment that installed a malicious release: secrets in environment variables, Azure CLI, npm, pip, git and Docker credentials, and any cloud role reachable through Azure managed identity, Azure DevOps OIDC or GitHub Actions OIDC federation.

supply-chainPyPIAI Agents