DEV Community

Anoymask
Anoymask

Posted on Edited on

Microsoft Agent Framework Supply Chain Compromise: Two Malicious PyPI Versions Steal Cloud Credentials on Python Startup

1. Basic Information

  • Article Title: We caught the agent-framework PyPI compromise six minutes after it published
  • Source: Elastic Security Labs
  • Published Date: November 18, 2026
  • Source URL: Elastic Security Labs
  • Related Sources: BleepingComputer
  • Affected Products: Microsoft Agent Framework 1.26.1 and 1.26.2
  • Severity: Critical (Author Priority)

2. Executive Summary

Malicious versions 1.26.1 and 1.26.2 were published to the official PyPI project. According to Elastic's analysis, a .pth startup hook is implemented to execute credential-stealing tools upon Python startup, even without importing the package.

3. Attack Flow

The following describe alternative paths via separate malicious releases. Both paths involve publication to the legitimate PyPI project, followed by installation in the target environment. The malicious code runs during Python startup when the site module processes the installed .pth files. Note that this description is based on Elastic's artifact analysis and does not indicate successful execution or exfiltration on victim endpoints.

Path A: Version 1.26.1

  1. Installation places agent_framework_meta.pth, agent_framework_meta/_telemetry.py, and related files.
  2. Upon Python startup, the hook invokes a loader that collects environment variables, the environment of up to 300 readable processes, and credential files.
  3. Depending on the runtime environment, it requests Azure DevOps OIDC or managed identity tokens and transmits the collected data to webhook[.]site.

Path B: Version 1.26.2

  1. Installation places af_runtime_diag.pth, af_runtime_diag.py, and related files.
  2. Upon Python startup, it performs collection and exfiltration similar to Path A and also attempts to collect GitHub Actions OIDC tokens.

Requests to Azure DevOps do not include a serviceConnectionId, and Elastic noted that it remains unconfirmed whether tokens corresponding to available federated credentials can be acquired.

4. Attacker Position and Execution Environment

The attacker gained the ability to publish releases to PyPI, but the compromise vector remains undetermined. The credential stealer runs on developer endpoints, build agents, and containers.

5. Visibility for Victims and Administrators

Inference: The following outlines expected visibility during investigations and does not represent confirmed observations published from victim environments. Visibility depends on logging and monitoring configurations.

Because the package installs with a legitimate name and the framework functions normally, anomalies are difficult to spot. To administrators, activity appears as .pth files, Python requests to IMDS or OIDC, and POST requests to webhook.site.

6. Success and Failure Conditions

After installing version 1.26.1 or 1.26.2, execution occurs during Python startup when the site module processes site-packages containing the malicious hook. The collection scope depends on execution privileges and the environment, and acquiring tokens requires reachability to each endpoint as well as necessary environment variables and permissions.

Pinning hashes to the known good version 1.26.0 prevents the introduction of malicious versions, and removing the malicious hook before startup blocks this execution vector. Blocking egress only limits external exfiltration and does not stop hook execution or local collection. Caches and internal mirrors must also be checked.

7. Impact of Successful Exploitation

Process environments, configuration files, cloud credentials, OIDC tokens, and managed identity tokens may be exfiltrated. The number of affected organizations and the overall scale of actual credential theft have not been disclosed.

8. Observable Logs

Inference: The following are candidate log sources and artifacts for investigation. Because they depend on collection settings, permissions, and retention periods, the absence of records does not prove that a compromise did not occur.

  • Proxy/SWG/DNS: POST requests to webhook.site and User-Agent headers (af-runtime-diagnostics/1 or runtime-diagnostics/1)
  • Endpoint/EDR: agent_framework_meta.pth, af_runtime_diag.pth, and corresponding modules
  • Identity/IdP: Token requests to Azure DevOps, GitHub Actions OIDC, and Azure IMDS
  • SaaS/Cloud: Usage of service principals, managed identities, and CI tokens since November 17, 2026, at 20:35 UTC

9. Determining Attack Success

Confirmed Information in Public Reports

Elastic has analyzed the hooks, collection, and exfiltration code for Path A (1.26.1) and Path B (1.26.2). Analysis alone does not confirm successful hook execution, token acquisition, or external exfiltration on victim endpoints.

Criteria for Internal Assessment

  • Path A (1.26.1): The presence of files such as agent_framework_meta.pth confirms installation. Evidence of the stealer executing from the hook indicates initial execution.
  • Path B (1.26.2): The presence of files such as af_runtime_diag.pth confirms installation. Execution from the hook is verified similarly. Requests to GitHub Actions OIDC serve as an additional investigation point for this version.

For both paths, successful transmission of sensitive information confirms data theft. Unauthorized use of stolen tokens establishes compromise of the access those tokens provide; session compromise requires evidence specific to the affected session. Destination or response data alone does not prove the contents of the transmission.

10. Investigation Playbook

  1. Check package versions and search caches, SBOMs, and container layers for the malicious releases.
  2. Remove malicious hooks before starting Python and isolate the endpoint.
  3. Check IOCs along with IMDS and OIDC requests.
  4. Rotate long-term credentials and investigate activity logs for short-term tokens.
  5. Rebuild build artifacts and mirrors from known good versions.

11. Defense and Detection Ideas

Avoid immediate adoption of new versions by implementing hash pinning and a quarantine period. Correlate package installation followed by .pth generation, reading of credential files, IMDS connections, and external POST requests.

12. Facts / Inference / Hypothesis

  • Fact: Elastic detected version 1.26.1 six minutes after publication and analyzed version 1.26.2 as a stealer using the same destination.
  • Fact: PyPI removed both versions within an hour.
  • Inference: Credentials or accounts with release permissions were likely abused, but the compromise vector remains undetermined.
  • Hypothesis: None.

13. MITRE ATT&CK Mapping

ID Technique Confidence Basis
T1195.002 Compromise Software Supply Chain High Malicious versions were published to the official PyPI project.
T1552.001 Credentials In Files High Searches for credential files.
T1567 Exfiltration Over Web Service High Code analyzed by Elastic POSTs collected data to webhook.site. Successful transmission on victim endpoints is unconfirmed.

14. Unknowns and Further Investigation

The compromise vector for PyPI publishing permissions, the number of installations, the actual number of victim organizations, and subsequent exploitation status remain unknown.

15. Impact on SOCs and Organizations

AI and cloud development environments can contain high-privilege tokens. Even releases available only briefly may later be reintroduced from CI caches or mirrors. Organizations must simultaneously advance credential rotation and cloud activity reviews alongside package removal.

16. Audience-Specific Summary

  • SOC: Correlate and check IOCs, Python startup events, IMDS and OIDC requests, and external POSTs.
  • Administrators: Remove malicious hooks before starting Python, rebuild using clean versions, and rotate credentials.
  • Users: If there is any possibility of having installed version 1.26.1 or 1.26.2, contact administrators without operating the endpoint.

Top comments (0)