By Mahan Kenway
Cover: Original conceptual illustration created for this article. It does not depict the actual incident.
If you installed or upgraded Microsoft's agent-framework Python package around November 17, checking your lockfile may not be enough. Two unauthorized releases contained credential-stealing code that could run when Python started, even if an application never imported the package.
In a November 25 update, Microsoft said the affected versions were 1.26.1 and 1.26.2 of the agent-framework Python meta-package. Both have been removed from PyPI. The company recommends treating any machine, container or CI job that installed either version as compromised, rotating accessible credentials and rebuilding from a clean image rather than downgrading in place.
The uploads happened on November 17, not on the date of Microsoft's later update. This is a package-distribution incident, not evidence that every Microsoft Agent Framework component was compromised. Microsoft says other Agent Framework Python packages, its .NET packages and Semantic Kernel were not affected by these malicious releases. It also says the malicious code was in the published packages, not the GitHub repository.
Why importing the package was not required
According to the PyPI security advisory, PYSEC-2026-4388, the two unauthorized releases were wheel-only packages repackaged from the legitimate 1.26.0 release. They added a .pth file that triggered the payload during interpreter startup in an affected environment.
A .pth file is normally used to configure Python's import paths, but the site module documentation explains that executable import lines in these files can run during normal startup. That makes the distinction important: an application did not need import agent_framework to activate the malicious code. Running a command that starts the affected Python environment could be enough.
The advisory says the payload launched a background process to gather environment variables and credential files. It also attempted to collect cloud and CI identities, including Azure managed identity tokens; version 1.26.2 additionally requested GitHub Actions OIDC tokens. The reported payload compressed collected data and sent it to a webhook endpoint. These are descriptions of what the malicious code was designed to do, not proof that every affected installation successfully leaked every credential.
How to check for exposure without making it worse
Start with records you can inspect from a trusted machine: lockfiles, dependency-update pull requests, CI build and install logs, software inventory, container-image manifests, internal mirrors and cached wheel archives. The affected releases were available briefly on November 17, but a copied wheel or an already-built container image can survive its removal from the public index.
Avoid starting the suspected Python interpreter just to investigate it. In particular, python -m pip freeze in the affected environment may trigger the startup hook you are trying to investigate. Preserve relevant evidence and follow your incident-response process; if an image needs inspection, use trusted tooling without executing the image's Python or starting its application.
Microsoft lists these file indicators in site-packages:
- 1.26.1:
agent_framework_meta.pth and agent_framework_meta/_telemetry.py
- 1.26.2:
af_runtime_diag.pth and af_runtime_diag.py
The full advisory also includes wheel SHA-256 hashes, a network indicator and user-agent strings. Use those to help scope an investigation, not as a substitute for it: an absence of a particular file or log entry does not prove an environment was never exposed, especially if it has already been rebuilt or its logs have expired.
Look beyond the developer laptop. An unpinned CI job, automated dependency update, container build or internal artifact proxy could have pulled or retained one of the malicious versions. Check the resolved versions that actually ran, not just today's requirements.txt: a current file can look safe while an old image, cache or job used a different resolution.
If an affected version was installed
Microsoft's guidance is to treat the environment as compromised. A practical response is:
- Contain and preserve evidence. Follow your organization's incident process, restrict access where appropriate and retain relevant logs or images before cleaning them up.
- Rotate credentials from a clean, trusted environment. Include every credential the affected machine or job could access: cloud identities, API keys, Git credentials, package-registry tokens and CI/CD secrets. Review temporary credentials and identity permissions too, rather than assuming only static
.env secrets matter.
- Rebuild instead of downgrading in place. Remove or quarantine affected environments, images, cached distributions and copies in mirrors or proxies after evidence is preserved. Recreate the workload from a trusted clean image and reviewed dependencies.
- Review audit trails from November 17 onward. Microsoft specifically recommends checking cloud and CI logs for unfamiliar activity involving exposed identities. The advisory's indicators can help focus network-log searches.
Removing the package from PyPI helps prevent new downloads from that index. It does not erase a cached copy, undo a successful credential theft, revoke a token or make an old container image safe. Likewise, downgrading an existing environment does not establish what the payload already did.
If you did not install either release
Microsoft says version 1.26.0 and earlier are not affected by these specific malicious uploads. If neither affected version was installed, its current advice is to pin agent-framework==1.26.0, or pin the exact subpackages needed, until Microsoft issues further guidance. At the time of writing, the PyPI project page lists 1.26.0 as its release.
A version pin is useful because it prevents an unreviewed newer release from being selected automatically. It is not a security guarantee: a pin does not fix a machine that already ran malicious code, and a malicious artifact can be pinned too. If records are incomplete or conflicting, treat that uncertainty as an investigation problem rather than assuming there was no exposure.
A broader lesson for AI-agent projects
Agent applications often combine model-provider keys, cloud access, repositories and automation credentials in the same build or runtime environment. A compromised dependency can therefore reach far beyond the immediate Python application.
For future builds, use reviewed dependency changes, scoped short-lived credentials and isolated CI jobs where practical. For deployments that need stronger artifact integrity, pip's hash-checking mode requires pinned and hashed requirements for all dependencies. Hashes help ensure an install matches the artifacts you approved; they do not tell you whether an artifact was safe when it was approved. Apply these controls in addition to, not instead of, the incident response above.
The distinction is straightforward: pinning helps prevent an unexpected package change; incident response addresses what may already have happened.