Malicious Credential Stealer Hidden in Microsoft's Official PyPI Package
Written by AI from the linked story. Not reviewed by an editor. How this works
Two versions of Microsoft's agent-framework package on PyPI were compromised to include credential-stealing malware, demonstrating that even packages from reputable publishers can be weaponized through supply chain attacks. The malware used a .pth startup hook—a subtle Python mechanism that executes code at interpreter startup—to silently harvest cloud and CI/CD credentials from environment variables and .env files. This incident matters because developers often implicitly trust packages from well-known vendors, making supply chain poisoning an especially effective attack vector. The theft of CI/CD credentials in particular can cascade into full pipeline compromise, enabling attackers to inject malicious code into downstream software builds.
Tactical Insight
Immediate actions
- Isolate any hosts that installed versions 1.26.1 or 1.26.2 of agent-framework and rotate all credentials found in environment variables and .env files on those hosts.
- Pin the agent-framework dependency to the last known-good version (1.26.0) in all project lock files and dependency manifests.
- Audit CI/CD pipeline secrets and cloud credentials for unauthorized access or usage since the malicious versions were published.
Long-term improvements
- Implement a private package mirror or artifact proxy (e.g., Artifactory, AWS CodeArtifact) so all third-party packages are vetted before reaching developers.
- Enforce dependency hash pinning (e.g., pip's `--require-hashes`) in all production and CI/CD environments to detect unexpected package changes.
- Adopt a software composition analysis (SCA) tool integrated into CI/CD pipelines to flag newly introduced or modified packages before deployment.
Detection measures
- Monitor runtime process behavior for unexpected outbound network connections or file reads of .env files from Python interpreter startup hooks.
- Alert on any environment variable access patterns at process startup that are inconsistent with the application's normal behavior.