Secrets Sprawl Is an Identity Problem That AI Just Made Impossible to Ignore

AI coding agents are changing how quickly developers can build and ship software as well as how quickly credentials can become exposed. According to GitGuardian’s 2026 State of Secrets Sprawl Report, commits identified as AI-assisted are leaking secrets at approximately twice the rate of human-written ones. Most of the fastest-growing categories of leaked credentials are now connected to AI services, meaning the tools meant to advance development are also accelerating the exposure of the keys development relies on.

This isn’t a new vulnerability; what is new is AI changing the scale and pace at which those mistakes can happen. A coding agent can read an entire project, modify files, generate configurations and interact with external services in the time a developer might take to review a single pull request. The main issue isn’t that AI agents sometimes encounter secrets but that many of those secrets were never designed for an environment in which software can act autonomously. AI coding agents are contributing to secrets sprawl by hardcoding credentials into more files and spreading existing ones into more systems than security teams can track and rotate.

How secrets sprawl has changed in the agentic AI era

Secrets sprawl occurs when credentials such as API keys, tokens and service account credentials accumulate across more systems than an organization can reliably inventory and rotate — hardcoded in source files, pasted into configurations and copied into tickets. Security teams have historically tried to control this sprawl by detecting exposed secrets retroactively; scanners watch repositories, pre-commit hooks catch what they can and security teams rotate credentials after an exposure is discovered. Those controls still matter, but AI agents expose the limitations of depending on detection alone. Agents can read local files, execute commands, call APIs, interact with Model Context Protocol (MCP) servers and modify configuration. Each additional capability creates another place where a credential may be required and another path through which that credential can spread.

This is why organizations should treat secrets sprawl in the agentic AI era as a Non-Human Identity (NHI) problem, not a model-behavior one. Every useful action an agent takes on another system has an identity behind it. When agents query a database, call an API and deploy to staging, some credential authorizes that action. Organizations cannot reliably predict every action an autonomous system will take, but they can control what the identity behind that system is allowed to access.

How AI coding agents can expose secrets

What makes coding agents useful is also what creates new credential risks: agents need context. An agent that can’t read an entire project doesn’t provide much assistance, especially one that must be re-authorized for every operation. Below are several ways this plays out in practice, demonstrating why organizations should be more careful when granting AI coding agents access to credentials and secrets.

Agents can access sensitive files in the project context

Developers often keep credentials in .env files and local configurations, left behind from a prior debugging session and never intended for source control. An AI coding agent with broad access to a project may be able to read those files along with the application code it was asked to analyze. To an AI agent, a configuration file containing a production API key is still part of the working environment, so unless access is explicitly limited, the credential may become available to the agent even if it is irrelevant to the task. This shifts security assumptions around developer workstations: Local plaintext credentials are no longer accessible only to the developer and the applications that explicitly reference them but are now also potentially available to software agents operating across the same environment.

Agent and MCP configurations can contain hardcoded credentials

Setup instructions for agents and MCP servers routinely simplify how developers connect AI applications with databases, APIs and other external systems. Because many integrations require authentication, that simplification often means pasting the credential directly into a configuration file. Since that file never enters version control, it's easy to assume the credential is safe. However, the credential may still exist in plaintext on a developer machine, often in a location the agent has permissions to read.

Secrets are duplicated across surfaces that teams may not scan

A secret rarely lives in one location; the same key ends up in an .env file, a CI/CD variable or even a Jira ticket while engineers troubleshoot a failed deployment. An AI coding agent connected to those systems introduces another vulnerability: since every copy of a secret authenticates, rotating the one in the repository leaves the rest working. This is why repository scanning alone cannot solve secrets sprawl. A large share of secret incidents can originate completely outside code repositories, with exposures in collaboration and ticketing tools, which is why rotating the copy found in a repository has minimal benefit if the same credential is valid elsewhere.

Agent credentials are often over-permissioned

An agent needs enough access to perform its work, creating pressure to grant broad permissions to ensure its tasks are useful. Permissions granted during prototyping to avoid errors may become part of a production process, so the original permissions with temporary intentions remain — no one revisits them once the workflow is running. The risk grows further in multi-agent systems. An orchestration layer holding keys for several agents may trigger a domino effect of compromised identities, with attackers inheriting access to everything the orchestrator was authorized to reach.

The governance gap is already measurable. In Keeper Security’s RSAC 2026 survey, 46% of respondents said AI-powered tools have access to critical systems and sensitive data, yet 76% of respondents said those identities aren’t consistently governed under privileged access policies. Even when access is granted, the controls that normally accompany that level of access often don't exist.

How to secure secrets in AI-assisted development

Banning AI coding tools entirely isn’t realistic for most organizations, and it honestly isn’t necessary. Instead, organizations should view AI agents as another identity operating across development environments and grant access accordingly. Here are several ways to secure secrets in AI-assisted development:

  • Remove static credentials from the developer environment: Instead of storing secrets in .env files, MCP configurations or IDE settings, organizations should retrieve secrets from a centralized secrets management platform when they are needed. If the plaintext credential is not on the workstation, an agent cannot accidentally read it from the developer environment.
  • Replace long-lived keys with short-lived, automatically rotated credentials: A static key that leaks remains a liability for as long as it stays valid, which may be months or years. A short-lived credential that expires in minutes and rotates on a set schedule narrows that window substantially and removes the need to find every copy before an attacker does.
  • Give every agent its own scoped identity: Shared service accounts make it nearly impossible to identify which agent performed which action, and they ensure that every agent inherits the broadest permission any of them needs. Organizations should give each AI agent only the permissions required for its task, and make those permissions temporary whenever possible. By treating an AI agent like a contractor, organizations let it handle specific resources and take specific actions within a defined period of time.
  • Extend secrets management beyond code repositories: CI/CD infrastructure, developer workstations, MCP configurations, ticketing systems and collaboration tools hold credentials that repository scanning never sees, and a large portion of secret incidents now originate in those attack surfaces. Security teams need to have more visibility beyond source control.
  • Require a human in the loop for sensitive operations: Credential access, production deployments and privilege changes should not become autonomous and instead must involve explicit approval. Auto-approve modes should be an intentional policy decision with a defined scope, not a default that a developer enables once and never revisits.
  • Inventory agents and MCP servers already running: Most organizations have more agents running than they think, installed by individual developers without proper review. Organizations should know which agents and MCP servers are operating in their environments, who owns them, which identities they use and what those identities can access.
  • Log and audit all agent activity: NHIs need the same access trail as human identities. Without a record of which credential an agent used and what it reached, incident response can't help reconstruct a breach and has nothing to prove in compliance audits.

Secrets sprawl is an identity issue, not an AI one

Software development is one of the main enterprise use cases for AI, and no security team will change that by policy alone. AI agents didn’t create secrets sprawl; they exposed how many organizations have poor strategies for machine credential security. Realistically, the goal is ensuring that the secrets AI agents encounter aren’t worth stealing. That means eliminating unnecessary static credentials, removing standing privileges, shortening credential lifespans, separating identities and maintaining visibility into how machine identities are being used. More scanning doesn’t fix this problem because it still finds credentials once they’ve spread; what helps is centralized, zero-knowledge control over how secrets are stored, scoped and expired. Keeper Secrets Manager allows organizations to centrally secure infrastructure secrets, remove hardcoded credentials from development workflows and control secrets usage as part of a zero-trust, zero-knowledge platform. AI agents will continue working faster and more efficiently, but the credentials behind them must become shorter-lived and more narrowly scoped to help govern their access.

Note: This article was thoughtfully written and contributed for our audience by Ashley D’Andrea, Senior SEO and Content Marketing Specialist at Keeper Security.

source: TheHackerNews