Independent analysis by NHI Mgmt GroupSource article: Akeyless, “The agent-framework PyPI Compromise: Why AI Agents Should Never Hold Secrets” (November 19, 2026)

TL;DR: A compromised agent-framework PyPI release turned AI build environments into credential harvesters by reading environment variables, dotfiles and minted identities, according to Akeyless. Agents that can see secrets make every nearby dependency part of the trust boundary, so secretless access becomes a governance requirement rather than a hardening option.


At a glance

What this is: NHI Mgmt Group's analysis, drawing on Akeyless's blog post: Compromised agent-framework releases showed that AI runtimes leak secrets through environment variables, dotfiles, and minted host identities.

Why it matters: Identity teams need to treat AI agents as secret-adjacent workloads that must not inherit standing access to provider keys, cloud tokens, or managed identities.

👉 Read Akeyless's analysis of the Microsoft agent-framework PyPI compromise and credential theft


Context

The security gap is not a cloud vulnerability in the usual sense. It is the decision to place long-lived credentials inside the runtime boundary of code that can be extended, poisoned or replaced at install time.

AI agents intensify that problem because they sit close to model providers, cloud services, databases and developer tooling. Once secrets live in the same process or file system as the agent, any adjacent package can become part of the trusted path.

Agentic AI identity guide is the right foundation here because the question is not only what the agent can do, but what authority it inherits while doing it.


Key questions

Q: How do AI agent runtimes leak secrets from local files?

A: AI agent runtimes leak secrets when the process can read environment variables, dotfiles, CLI caches and sibling process state. If the agent can see reusable credentials, any transitive dependency or injected package running in the same environment can read them too. The safer pattern is to keep credentials out of the runtime and broker access only when needed.

Q: What is the best way to stop package installs from exposing agent credentials?

A: Use secretless runtime design so package installs never receive long-lived agent secrets, and bind access through short-lived workload identity, scoped tokens, or brokered retrieval at runtime. Package managers, build hooks, and install scripts should run with no direct access to API keys, certificates, or bearer tokens, because dependency code is a common exposure path for agent credentials.

Q: Why do managed identities increase risk in AI build environments?

A: Managed identities can increase risk when they are available to build tools, container steps, or agentic pipelines that should not hold standing credentials. If the identity can mint tokens automatically, a compromised build step can reuse that trust for lateral movement, so scope it tightly, separate build and deploy identities, and restrict token issuance outside approved runtime boundaries.

Q: How should organisations govern temporary access when AI agents and engineers both need elevated cloud permissions?

A: Organisations should treat temporary access as the default for both humans and AI agents. Grant access only for the task at hand, scope it to the minimum required permissions, and revoke it as soon as the work is complete. This reduces standing privilege, limits blast radius, and gives security teams a clearer view of who or what can act in production at any moment.


Technical breakdown

How .pth startup hooks become a supply-chain execution path

Python processes .pth files at interpreter start, which means malicious code can run before the application imports anything. In this case, the payload rode on a legitimate package release and executed whenever Python started in that environment, including pip, pytest and IDE language servers. That makes startup-time hooks more dangerous than ordinary library code because the activation point is structural, not behavioral. The issue is not just package trust, but the fact that environment initialization can be turned into a universal execution trigger across development and CI contexts. See the AI Coding Agents Security Guide.

Practical implication: Treat interpreter-start hooks as an execution surface and inspect them with the same discipline as build scripts.

Why secrets in environment variables, dotfiles and /proc are all one exposure class

The payload did not need a cloud exploit. It read what the process could already access: environment variables, local credential files, and other processes' /proc entries. That collapses multiple storage locations into one exposure class because any code running beside the agent can see the same local material. Static keys in .env files, CLI caches and service configs are therefore not separate problems; they are one trust decision expressed in different file paths and process surfaces.

Practical implication: Design secret handling so the agent runtime never contains reusable credentials in memory, on disk or in sibling processes.

Why minted identities expand the blast radius beyond stored keys

The stealer also requested GitHub Actions, Azure DevOps and managed identity tokens, which means the problem is not limited to passwords copied into files. Workloads that can mint fresh identities on demand create a second exposure path: live authority that can be harvested during execution. That matters because a token minted by the host often carries broader or fresher access than a static secret, and it can be used immediately without touching the underlying source credential.

Practical implication: Separate workload authentication from direct target access so runtime token minting never occurs inside the agent's trust boundary.


Threat narrative

Attacker objective: Steal reusable cloud, developer and AI-provider credentials from environments that run the agent framework, then turn them into broader access across adjacent systems.

  1. Entry occurred through two malicious agent-framework releases published to PyPI, with the payload installed as a .pth file that executes at Python startup.
  2. Credential harvesting followed immediately as the stealer collected environment variables, local credential files and /proc entries from the host.
  3. Escalation came from minting fresh OIDC, managed identity and cloud tokens from the runtime itself, extending reach beyond stored secrets.
  4. Impact was the exfiltration of credentials and identity material to an external webhook, creating exposure across development, CI and production workloads.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Secretless AI runtime is the only durable answer to poisoned packages: The issue here is not whether a scanner catches a bad release fast enough. It is that any secret placed inside the agent's runtime can be taken by code running beside it. That means the control boundary has to move from detection after install to designing the agent so it has nothing reusable to expose.

Runtime authority collapses when one process can see every nearby credential: The agent-framework compromise shows that the trust boundary is the whole process, not the package you intended to run. A transitive dependency, a helper library or a language server can all reach the same local secrets, which makes conventional file-based isolation too weak for agent workloads. Identity governance has to assume shared-process exposure unless authority is brokered outside the agent.

Long-lived secrets in agent environments create trust debt: The article's core failure mode is not just secret leakage, but the accumulation of static credentials around systems that already execute third-party code. That trust debt grows every time teams copy provider keys into env vars, dotfiles or runner configs. The practical conclusion is that AI agents should be treated as secret-hostile by default.

Runtime minting changes the credential problem from storage to issuance: This payload did not only steal stored keys; it also requested fresh identities from the host. That means the governance problem is not solved by hiding files alone, because the agent can still become a credential factory if standing workload identity is available. The control question becomes who is allowed to mint, not just who can read.

SecretlessAI gap: The attack succeeded because the environment assumed the agent could safely hold credentials for later use. That assumption fails when the actor is an AI workload running arbitrary dependencies because access can be read, copied and reused within the same runtime session. The implication is that governance must stop treating agent-held secrets as reviewable assets and start treating them as avoidable liabilities.

From our research library:

What this signals

Secretless runtime will become the baseline expectation for agentic systems: Governance programmes built on access reviews assume that privilege persists long enough to be observed, certified and revoked. When the agent can mint and consume access inside one task, that assumption breaks, so controls have to move to issuance time and runtime policy enforcement.

The next pressure point is not whether agents are useful, but whether they can exist without credential residue. As Akeyless's post and the wider NHI evidence show, exposed agent credentials are already common enough to make secretless design a programme-level decision rather than an edge-case hardening task.

Agentic build and test pipelines will keep attracting credential-stealing packages because they concentrate model keys, cloud tokens and developer access in one place. Security teams should expect the boundary between software supply chain compromise and identity compromise to keep narrowing.


For practitioners

  • Remove reusable credentials from agent runtimes Stop placing provider keys, cloud tokens and passwords in environment variables, dotfiles or local caches that agent code can read. See the Agentic AI Identity Guide.
  • Broker access outside the agent process Require a gateway or broker to issue task-scoped credentials only when the action is approved and the target is known.
  • Treat startup hooks as execution surfaces Inspect .pth files, interpreter startup paths and package-install behavior as part of runtime trust review for every build and test host.
  • Separate workload identity from direct target access Prevent the host identity from carrying standing roles into databases, storage services or key vaults that the agent can reach directly.
  • Validate agent observability on credential access Log when an agent requests, receives or is denied authority, then compare those events with token minting and secret-read activity.

Key takeaways

  • The breach pattern is simple: AI agent runtimes that store reusable secrets invite any malicious dependency to harvest them.
  • The evidence points to a broad exposure path across environment variables, credential files and minted identities, not a single flawed application.
  • The limiting control is to remove secrets from the agent runtime and broker access through task-scoped authority that expires automatically.

Related NHI Mgmt Group resources: Agentic AI Identity Guide · AI Agent Authorisation Guide · AI Agent Observability, Audit and Incident Response Guide · Microsoft Agent Framework PyPI compromise 2026


Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and MITRE ATT&CK define the specific risk controls and attack patterns relevant to this term.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageThe compromise harvested environment variables, dotfiles and other local secrets from agent runtimes.
NHI-07 — Long-Lived SecretsStatic provider keys and cloud tokens created the exposure surface the payload exploited.
NHI-05 — Overprivileged NHIThe host and workload identities had enough authority to make the harvested tokens valuable.
Recommendation — Remove reusable secrets from agent environments and revoke any credential exposed to package-level execution. Replace long-lived agent credentials with task-scoped issuance and automatic expiry. Constrain workload authority so agent hosts cannot directly access target systems or mint broad tokens.
OWASP Agentic AI Top 10ASI03 — Identity & Privilege AbuseThe article shows how agentic workloads can abuse runtime identity when secrets are present.
Recommendation — Evaluate every agent request against runtime privilege rules before any credential is issued.
MITRE ATT&CKTA0006;TA0010 — Credential Access; ExfiltrationThe payload focused on harvesting credentials and sending them out of the environment.
Recommendation — Hunt for credential-access behaviour and outbound exfiltration from agent build and test hosts.

Key terms

  • Microsoft Agent Framework PyPI compromise 2026: A supply-chain incident in which two PyPI releases of Microsoft's agent-framework package carried credential-stealing code. It is notable because the malware executed at Python startup and targeted the local secrets, tokens and cloud identities already present in AI build and runtime environments.
  • Python package supply chain: Python package supply chain is the set of processes and dependencies involved in obtaining, building, and installing Python packages. It covers package indexes, maintainers, transitive dependencies, build backends, and install-time scripts, which makes it the path through which malicious or compromised packages can enter development and production systems.
  • .Pth File: A .pth file is a Python startup file that can extend interpreter search paths and, when it contains import statements, execute code automatically. In supply-chain attacks, adversaries abuse this mechanism to run payloads at every Python startup, before the application imports anything. It turns package installation into a delayed execution trigger.
  • Dynamic Secret: A secret generated on-demand for a specific task and automatically revoked after use or expiry. Dynamic secrets dramatically reduce the risk of credential exposure compared to static, long-lived secrets and are considered best practice.

What's in the full analysis

Akeyless's full blog post covers the operational detail this post intentionally leaves for the source:

  • Step-by-step breakdown of the malicious .pth startup mechanism used to execute the payload
  • Detailed comparison of what the stealer pulled from environment variables, dotfiles and /proc
  • Runtime enforcement flow for brokered, task-scoped credentials versus stored agent secrets
  • Operational guidance on separating package screening from secretless access design

👉 Akeyless's full post covers the attack chain, exposed credential types and the response steps for affected environments.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org