Independent analysis by NHI Mgmt GroupSource article: Delinea, “Keep your API keys out of the chat: A practical guide to secret-safe coding agents” (September 26, 2025)

TL;DR: Coding agents such as Copilot, Codex, and Cursor can expose API keys, database credentials, and tokens when secrets are pasted into chat, stored in files, or left in shell history, according to Delinea. It proposes MCP plus Secret Server to keep secrets in memory and auditable, as the deeper issue is that developer workflows are now secret-bearing runtime environments, so traditional paste-once or .env handling no longer matches the risk.


At a glance

What this is: NHI Mgmt Group's analysis, drawing on Delinea's blog post: Common developer workflows still leak credentials into chat, files and shell history, making practical steps necessary to keep API keys and other secrets out of coding-agent conversations.

Why it matters: IAM and NHI teams need to treat coding agents as secret-bearing runtime surfaces, because the exposure path is now workflow design as much as credential storage.


Context

Coding agents create a governance problem when developers use them as if they were harmless text interfaces. The identity issue is not the model itself but the fact that API keys, credentials and tokens can enter chat, shell history, logs and saved files as part of normal work.

That makes secret handling a runtime control problem, not a documentation problem. If the workflow can read, echo and persist secrets, then the organisation has already expanded the credential exposure surface beyond what traditional paste-once or .env habits were designed to handle.

For NHI governance teams, this sits squarely in secrets management and workload-style access patterns, even when the human developer remains the operator. The article’s starting point is typical for modern engineering teams using coding assistants, not an edge case.


Key questions

Q: What breaks when developers paste API keys into AI-built apps?

A: The application loses clean attribution, revocation, and scope control. Anyone using the app may inherit the same credential path, and the original builder often cannot explain or limit what that key can still reach later. That turns a convenience shortcut into an unmanaged access surface.

Q: Why do coding agents make secret exposure harder to govern?

A: Because the agent sits inside the same workflow where secrets are requested, displayed and reused, the organisation loses the clean separation between credential issuance and credential use. That makes auditability, rotation and revocation more important, not less, since the exposure path is now part of day-to-day development.

Q: How should security teams stop secrets from ending up in shell history and files?

A: They should redesign agent-assisted tasks so the secret is fetched into memory at runtime, used for the specific task and then cleared, rather than entered manually or stored in a file. The key is to eliminate durable copies that the agent or tooling can later replay or commit.

Q: Should organisations rotate credentials that were used with coding agents?

A: Yes, because once a credential has passed through a coding-agent workflow the organisation has to assume it may have reached logs, files or other persistent surfaces. Rotating and revoking those secrets reduces the chance that an old value remains usable after the original task is over.


Technical breakdown

Why coding agents turn secret handling into a runtime control problem

Coding agents such as Copilot, Codex and Cursor do not just assist with text, they operate inside a workflow where secrets may be requested, displayed, persisted or reused. That creates a runtime risk: once a secret enters the agent interaction, it can be copied into chat logs, shell history, temporary files or downstream automation steps. The control problem is therefore less about whether the developer knows the secret and more about whether the workflow can prevent durable exposure while the task is still executing.

Practical implication: treat the agent workflow as part of the credential boundary and remove plaintext secrets from any path the tool can store or replay.

Why .env files and manual environment variables are weak for coding agents

.env files, manual environment variables and paste-once widgets all assume a controlled, short-lived interaction. In practice, they leave artifacts on disk, in shell history or inside application configuration that coding agents can access or reproduce. They also fail to create a meaningful audit trail for secret access, which means the organisation cannot distinguish an approved fetch from an accidental disclosure. The underlying weakness is not convenience but persistence: these patterns make secrets available longer than the task needs them.

Practical implication: replace static handoffs with ephemeral access paths that do not leave reusable credential copies behind.

How MCP changes secret retrieval without exposing the secret itself

Model Context Protocol can be used as a broker between the agent and the secret store so the agent receives an ephemeral session key instead of the plaintext secret. In the article’s flow, the agent requests the secret, authentication happens through existing SSO or MFA, a short-lived key is issued, and the secret is fetched into memory for the task. The important architectural point is that the secret never needs to be pasted into chat or written to disk, and the fetch is auditable as a discrete event.

Practical implication: design secret delivery so the agent gets authorization to fetch, not durable possession of the secret itself.


Threat narrative

Attacker objective: The attacker or accidental leakage path aims to obtain reusable credentials that unlock development, deployment or production systems.

  1. Entry occurs when a developer pastes an API key, database credential or token into a coding-agent chat or places it in a file the agent can read.
  2. Credential exposure follows because the secret can be retained in chat logs, shell history or saved files, creating a durable copy outside the intended task.
  3. Impact is credential reuse or accidental disclosure, which can extend into debugging, deployment, on-call work or broader environment access.
  • Hugging Face Spaces breach 2024: Unauthorised access to Hugging Face Spaces may have exposed secrets users stored for AI apps; tokens were revoked and org tokens removed.

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

Secret-bearing developer workflows are now part of the identity surface: When coding agents can read, echo and persist secrets, the boundary for NHI governance extends into the developer workstation and chat layer. That means the real control question is not whether the secret is stored centrally, but whether the workflow can prevent plaintext exposure during task execution. Practitioners should treat the coding-agent session as a governed credential-handling environment, not a harmless productivity layer.

Ephemeral secret retrieval is the right pattern, but only if it eliminates durable possession: The value of short-lived access is not convenience, it is reducing the number of places a secret can survive after a task completes. MCP-style brokering matters because it separates authorisation to fetch from possession of the secret itself. The practitioner takeaway is that secrets handling must be designed around runtime exchange, not static distribution.

Auditability becomes a primary control, not a compliance extra: Once developers and agents interact with secrets through chat, the organisation needs a traceable record of each fetch, who requested it and under what authorisation context. That is especially relevant for incident review and access governance, because traditional file-based handling obscures who saw what. Teams should assume that if a secret path is not auditable, it is not governable.

Automatic rotation and revocation matter because exposure is now workflow-amplified: Coding agents increase the number of chances a secret can leak, which means stale credentials create a larger blast radius than they did in manual workflows. The governing issue is not just secret storage, but secret lifetime across many small interactions. Practitioners should align lifecycle controls to the pace of developer tooling, not to the convenience of the operator.

Identity governance for coding agents sits at the intersection of human intent and machine execution: The human developer approves the task, but the agent can still move secrets through tools, logs and scripts at machine speed. That combination makes this a cross-domain control problem spanning IAM, NHI governance and secrets management. Security teams should expect coding-agent adoption to expose gaps where human workflow assumptions were never designed for machine-mediated secret handling.

From our research library:

What this signals

Ephemeral secret delivery is becoming a control boundary, not a convenience feature: Coding-agent adoption pushes teams toward runtime access patterns where a secret should exist only long enough for the task to complete. That changes the governance model from storage-centric to session-centric, which is the right direction for NHI and secrets management in developer tooling.

Secret-safe coding agents need identity controls around fetch events, not just vault location: The critical question is who can request a secret, under what approval context and with what audit trail. If the workflow cannot answer those questions, the organisation still has an unmanaged exposure path even when the vault itself is centrally controlled.


For practitioners

  • Remove plaintext secrets from chat workflows Block developers from pasting API keys, tokens and credentials into coding-agent prompts, logs or transcripts, and enforce this in engineering policy and tooling.
  • Broker secret access through ephemeral fetches Use a short-lived retrieval path so the agent gets permission to fetch a secret at runtime rather than a reusable credential stored in the prompt or file.
  • Keep secrets out of shell history and disk Refactor agent-assisted workflows so sensitive values are injected only in memory and cleared immediately after use, with no .env or command-history persistence.
  • Log every secret fetch centrally Capture who requested the secret, what was requested and when the fetch occurred so reviews can distinguish approved access from accidental exposure.
  • Rotate credentials that have touched agent workflows Treat any secret exposed to a coding-agent session as higher risk and move it onto a tighter rotation and revocation schedule than ordinary developer credentials.

Key takeaways

  • Coding agents create a new credential-handling problem because the secret can leak through the same interfaces used to help developers work faster.
  • The article’s core operational point is that chat, shell history and saved files turn ordinary developer assistance into a secret exposure risk.
  • The practical fix is to move from durable secret possession to auditable, short-lived retrieval and immediate cleanup.

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 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageThe article is about keeping API keys, tokens and credentials out of chat and files.
NHI-07 — Long-Lived SecretsThe article argues that static handling creates exposure because credentials persist too long.
Recommendation — Prevent secret leakage by blocking plaintext credentials from agent prompts, logs and saved files. Replace long-lived secrets with short-lived retrieval paths and tighter revocation.
OWASP Agentic AI Top 10ASI02 — Tool MisuseCoding agents can misuse tools and workflows when secret access is not constrained.
Recommendation — Constrain agent tool access so secret fetches cannot become unrestricted credential handling.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementAPI keys and tokens are authenticators whose lifecycle must be managed.
Recommendation — Apply authenticator management to rotate, revoke and control API keys used in agent workflows.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe article centers on who can fetch secrets and under what permissions.
Recommendation — Limit secret access permissions to the minimum needed for each coding-agent task.

Key terms

  • Coding Agent: A coding agent is a software system that can plan, generate, and modify code with limited human prompting. In governance terms, it is not just a tool but an actor whose permissions, tool access, and rollback path must be managed as part of the delivery process.
  • Ephemeral key: A short-lived credential or key used for temporary access instead of persistent secrets. Ephemeral keys reduce exposure windows and blast radius, but they still depend on underlying cryptographic trust that may need to change during a PQC migration.
  • Secret-Bearing Workflow: A business workflow system that can store, move or expose credentials as part of normal operations. In this context, ServiceNow tickets, KBs, attachments and CMDB records become part of the secret surface because users paste tokens or keys into them during support activity.
  • Runtime Secret Retrieval: Runtime secret retrieval is the practice of fetching credentials from a vault or controlled service only when they are needed. It reduces secret exposure in repositories and configs, but it only works when the retrieval path is scoped, logged, and tied to a specific workload or agent.

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 building or maturing an IAM programme, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on June 24, 2026.
Updated on October 11, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org