{"slug": "ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them", "title": "AI Agents and Non-Human Identities: The Security Risks and How to Reduce Them", "summary": "AI agents are non-human identities whose leaked API keys, OAuth tokens and service accounts let attackers log in rather than break in, according to a GitGuardian security guide citing the CrowdStrike 2026 Global Threat Report. Palo Alto Networks estimates non-human identities now outnumber human employees 109 to 1, and the guide recommends teams inventory every agent and credential, assign each a named owner, scope permissions to the task, prefer short-lived credentials, keep secrets out of prompts and shared tools, and monitor agent activity with a revocation plan.", "body_md": "## TL;DR\n\n- **AI agents are non-human identities:** They decide which systems to call, then authenticate with API keys, OAuth tokens, and service accounts.\n- **The risk sits in the credentials:** Agents get broad, standing permissions, their secrets spread into prompts, logs, tickets, code, and MCP configuration files, and many keys outlive the person who created them.\n- **Attackers log in rather than break in:** Whoever holds a leaked agent credential logs in as the agent and inherits whatever it can reach.\n- **Start with inventory and ownership:** List every agent and its credentials, inside and outside the vault, and give each one a named owner.\n- **Then shrink and guard access:** Scope permissions to the task, prefer short-lived credentials, keep secrets out of prompts and shared tools, and monitor agent activity with a revocation plan.\n\nAI agents are non-human identities (NHIs) that make their own decisions and can take direct actions that affect the world around them. They choose which systems to call and then authenticate with API keys, OAuth tokens, and service accounts. The credentials they hold to your critical systems are the most direct path an attacker has into your data.\n\nThis guide is for security, application security, and platform teams rolling out AI agents. It explains why agents need to be treated like any other non-human identity, seven risks they introduce, and six controls that reduce those concerns. A short FAQ at the end answers the questions teams ask most.\n\nIt is not a coincidence that NHIs have come into focus while AI tools and autonomous agents spread through the enterprise. AI adoption is part of what drives the explosion of NHIs, and it has sparked a lot of conversation about machine identity and governance.\n\nNHIs such as AI agents, bots, scripts, and cloud workloads operate using secrets granted to them by a human user, often using the developer's credentials directly. These credentials grant access to sensitive systems and data. They take many forms, and each one must be accounted for from creation to offboarding. Unlike humans, machines can't use multifactor authentication or passkeys, and developers can generate hundreds of these credentials through their work deploying applications.\n\nAttackers have noticed. According to the [__CrowdStrike 2026 Global Threat Report__](https://www.crowdstrike.com/en-us/resources/reports/global-threat-report-executive-summary-2026/?ref=blog.gitguardian.com), adversaries used valid credentials and trusted identity flows instead of malicious code. When an agent's key leaks, an attacker doesn't need to break in. They log in as the agent and inherit whatever it can reach.\n\n## **What is a non-human identity? AI agents and other machine identities**\n\nNon-human identities are the digital identities that software, workloads, and devices use when authenticating and accessing resources. These identities, which commonly look like service accounts or Kubernetes workers, leverage API keys, OAuth tokens, CI/CD tokens, and the credentials stored in configuration files.\n\nEach one lets automated processes access systems without a person present, and that automated access is exactly what an attacker wants.\n\nPalo Alto Networks estimates that non-human identities now outnumber human employees 109 to 1. AI agents are the newest and most demanding kind of NHI. They are systems built with large language models (LLMs) that decide independently how to accomplish a specified task.\n\nThese are not the deterministic bots we have been using in many workflows for years. Those bots can only perform the specific instructions the developer laid out step by step. These AI agents can access internal data sources to look up information, search the internet, and interact with other applications on behalf of the user.\n\nBots and scripts are automated systems that follow instructions. AI agents are autonomous systems that choose their own steps, and as teams deploy one for every workflow, agents outnumber human users too. That autonomy changes the identity picture in three ways:\n\n- **Many credentials per agent:** An agent calls models, tools, APIs, and Model Context Protocol (MCP) servers, and each connection needs its own credential.\n- **Inherited permissions:** Agents often act on behalf of a person, so they can inherit that user's access on top of their own.\n- **No natural decommissioning date:** Human identity programs assume a person who joins, changes roles, and leaves. An agent has no HR record, no manager, and no offboarding date unless someone creates one.\n\nThe result is identity sprawl that traditional identity governance was never designed to track. The table below shows where the differences matter most.\n\n## **Non-human identity risks AI agents introduce**\n\nMost of the security risk around AI agents comes back to their credentials. The questions are how much they can reach, where they end up, and whether anyone still owns them. These are the NHI security gaps security teams run into most often. Unlike classic security vulnerabilities in code, these are hidden vulnerabilities in how access is granted. They create security blind spots that code scanners alone never show.\n\n### **Excessive permissions and standing privilege**\n\nIt is common to grant AI agents broader read, write, and even creation and deletion permissions than we would give deterministic bots. For traditional machine workers, we define which systems they can and cannot access as part of the work we assign them. Since AI agents decide the best path to complete a job without direct supervision, scoping access too tightly blocks the requested work. Which permissions an agent will need might not be clear from the beginning, and many teams are erring on the side of being too permissive.\n\nThe result is standing privilege: broad permissions that stay active around the clock, whether or not the agent is using them. Excessive privileges turn a small leak into a large incident, because whoever holds the credential inherits all of that unnecessary access. A leak of any one of the many keys involved could lead to a data breach or unauthorized purchases, among other risks.\n\n### **Secrets sprawl across the agent pipeline**\n\nFor example, an AI-powered procurement agent could analyze purchasing needs and compare vendors through online shopping sites. It could negotiate prices with AI chatbots and even place orders on its own if allowed. Every secure communication requires access credentials. This new agent is produced through a DevOps process, requiring even more authentication across the pipeline. Along the way, credentials often end up scattered across systems, logs, and repositories.\n\nThe numbers show how fast that sprawl grows. GitGuardian's [__State of Secrets Sprawl 2026__](https://www.gitguardian.com/state-of-secrets-sprawl-report-2026?ref=blog.gitguardian.com) report counted 28.65 million new hardcoded secrets on public GitHub in 2025, up 34% year over year. Secrets for AI services alone reached 1.27 million, up 81%. Public code is only the visible part: internal repositories are about six times more likely than public ones to contain hardcoded secrets.\n\n28.65M\n\nnew hardcoded secrets on public GitHub in 2025, up 34% YoY\n\n1.27M\n\nAI-service secrets exposed in 2025, up 81% YoY\n\n24,008\n\nunique secrets in public MCP configuration files (2,117 valid)\n\n~2×\n\nleak rate of Claude Code-assisted commits vs the baseline (3.2% vs 1.5%)\n\nSource: GitGuardian, [State of Secrets Sprawl 2026](https://www.gitguardian.com/state-of-secrets-sprawl-report-2026?ref=blog.gitguardian.com)\n\n### **Orphaned API keys and unclear ownership**\n\nAn orphaned API key is an API key that is no longer associated with a user account. This happens when a user leaves a company or deletes their account. Any API keys they made stay valid, but now no one owns them. Unless someone accounts for them, they will likely never get rotated or deleted.\n\nIn the world of machine identities, the question of who owns an NHI is a tricky one. Is it the person who created it? A dedicated DevOps team? Without clear NHI ownership, the chance that a credential becomes orphaned and forgotten while still allowing access is high.\n\nAI agents add new elements of speed and scale to this old story. A developer can wire an agent to a new SaaS integration in minutes, and the key often outlives the project or the person.\n\nPolicies lag behind: a January 2026 Cloud Security Alliance survey found that 78% of organizations lack documented policies for creating or removing AI identities. Old credentials also stay dangerous for years. GitGuardian found that 64% of credentials that were valid in 2022 were still valid in January 2026.\n\nA better question than \"who owns the key\" would be, \"who owns the risk associated with a breach caused or aided by these API keys?\"\n\n### **Secrets in prompts, logs, and agent context**\n\nWhen we think of an AI assistant, we immediately think of players like ChatGPT, Gemini, and Claude, all of which use prompt-based architectures. So does GitHub Copilot. The AI models process, store, and transmit sensitive information through prompts, sending context, commands, and data to an LLM provider. This approach makes these tools exceptionally easy to interact with, leading to rapid prototyping and tool development.\n\nThis is not isolated to your development teams. As more teams embrace coding assistants for \"citizen developers,\" the risks of data exposure, proprietary business data leaks, and credential leakage spread across the enterprise. People, many of whom have never been trained as developers, paste tokens into unapproved AI tools, and those tools keep their own histories.\n\nFor example, if a finance team member uses an AI-powered chatbot to automate invoice processing, and their prompt contains Find all invoices over $100,000 in the past 6 months using API key ABC123, that API key will most likely now be logged. If those logs are left in plaintext, they would allow an attacker unauthorized access to that invoicing system. Hopefully, that key is properly scoped.\n\nPut safeguards in place that stop developers and other users from embedding sensitive data in prompts and logs. Ideally, you also scan each LLM output for information that should not be there. Defining which returned data is sensitive can be tricky, but finding and eliminating secrets should be straightforward and a priority.\n\n### **Data sources agents read: messaging, ticketing, and cloud platforms**\n\nAI agents often ingest, process, and store data from various sources, including:\n\n- Cloud storage such as AWS S3 and Google Drive.\n- Enterprise applications like Jira, Confluence, and Salesforce.\n- Messaging systems, including Slack and Microsoft Teams.\n\nWe need to keep sensitive information, such as credentials, personally identifiable information, or other private data, out of these systems. If your AI agent can access any data in these systems, then the path for an attacker to abuse this NHI also exists.\n\nSimon Willison calls this dangerous setup [__the lethal trifecta__](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/?ref=blog.gitguardian.com): an agent with access to private data, exposure to untrusted content, and the ability to communicate externally. A crafted message in a ticket or chat thread can instruct that agent to send whatever it can see to an attacker. That includes any credential sitting in the thread.\n\nThe most reliable way to close this path is to find and revoke the keys sitting in the systems around your AI agents. That includes version control systems, ticketing systems, and messaging platforms. Replace what you revoke with properly stored credentials. Combined with good log sanitation, this goes a long way toward keeping your secrets secret.\n\n### **AI-generated code and hardcoded secrets**\n\nAI coding tools like GitHub Copilot, Cursor, Claude Code, and Amazon Q Developer (formerly CodeWhisperer) have seen rapid adoption. These tools generate code snippets based on vast amounts of training data. That creates a real security risk: AI-generated code can lead a busy developer to hardcode secrets, such as API keys, database credentials, and even OAuth tokens.\n\nFor an example of the risk, imagine a developer asks an AI assistant to generate an API call to a cloud service, and it produces:\n\nimport requestsAPI_KEY = \"sk_live_ABC123XYZ\"response = requests.get(\"https://api.example.com/data\", headers={\"Authorization\": f\"Bearer {API_KEY}\"})\n\nChatGPT produced that example code.\n\nWhile that is not a real key, a developer under a time crunch might swap a real key for the generated one. So might someone who is not familiar with secrets security. If left unchecked, such code may get committed to version control systems, exposing credentials to attackers who gain access or anyone if the repo becomes public.\n\nThis pattern is part of how secrets sprawl keeps getting worse. GitGuardian's research found that Claude Code-assisted commits leaked secrets at a rate of 3.2%, roughly double the 1.5% baseline. To be clear, we believe the issue is that developers are moving fast and not checking their work, not that they are using AI agents. Developers need guardrails that keep them moving: pre-commit hooks and code editor checks that catch a secret before it reaches a shared repository. AI agents themselves need guardrails to stop them from using or abusing credentials, which is [__why we built our AI hooks__](https://blog.gitguardian.com/ai-hooks-ai-coding-assistants/). Our guide to [__credential security for AI coding agents__](https://blog.gitguardian.com/ai-coding-agents-credential-security/) covers those controls in more depth.\n\n### **MCP servers and agent configuration files expand the attack surface**\n\nMCP gives agents a standard way to connect to tools and data sources, and every MCP server needs credentials to do its job. Those credentials often land in plaintext configuration files on developer machines and in repositories. In 2025, GitGuardian found 24,008 unique secrets in public MCP configuration files, and 2,117 of them were valid.\n\nCoding agents add another layer. Many write session context, logs, and tool output to disk by default. A token an agent touched once can stay on a laptop long after the task is done. An [__MCP governance framework__](https://blog.gitguardian.com/mcp-governance-framework/) helps teams decide which servers agents may use and how their credentials are stored.\n\n## **How to secure non-human identities for AI agents**\n\nAgents need more discipline, though, because they move faster and touch more systems. Here are six security controls you can work from right now.\n\n### **Inventory every agent and the credentials it uses**\n\nYou need visibility if you are going to make real change. List the agents running in your cloud and hybrid environments, including the ones teams adopted without approval. Then list every credential each agent uses: API keys, OAuth tokens, service tokens, and MCP server credentials. AI agent credentials hide in more places than other non-human credentials, because agents touch so many tools.\n\nLook outside the vault as well as inside it. The keys that cause incidents are usually the ones that never got registered. They sit hardcoded in a repository, pasted in a ticket, or in a configuration file on a laptop. [__Vault coverage__](https://blog.gitguardian.com/vault-coverage/) is a useful metric here: the share of known credentials stored in your secrets manager.\n\n### **Assign owners and bring agents into access management**\n\nEvery agent and every credential it uses needs a named owner. That person or team is accountable for its permissions, its rotation schedule, and its retirement. Record the owner when the agent is created, not after an incident.\n\nBuild formal processes for each stage of an agent's identity lifecycle: creation, review, and retirement. When someone leaves, or a project ends, review their agents and agent credentials the same way you would review human accounts. Revoke what nobody needs and reassign what is still in use. This is the same lifecycle management discipline you apply to people, adapted to identities that never quit.\n\n### **Move toward zero standing privilege**\n\nGrant each agent only the permissions its current task requires, and review non-human access on a schedule. Where your cloud platforms support it, replace standing privilege with just-in-time access. The agent requests elevated access for a specific task and loses it when the task ends. Zero standing privilege is the end state, where no agent identity holds sensitive access by default.\n\nSplit high-risk capabilities across agents, too. No single agent should combine private data access, untrusted input, and an outbound channel. Our guide to [__least privilege for NHIs__](https://blog.gitguardian.com/principle-of-least-privilege-nhis/) goes deeper on scoping.\n\n### **Prefer short-lived, ephemeral credentials**\n\nLong-lived API keys are the easiest NHI credentials to steal and the hardest to clean up. Where providers support it, use ephemeral credentials such as short-lived OAuth tokens or workload identity federation, which expire on their own. When a static key is unavoidable, store it in a vault, scope it narrowly, and set a rotation policy your team will follow.\n\nShort-lived credentials add operational work, and not every API supports them. Treat this as a direction rather than a switch you flip overnight. The trade-offs are covered in our [__practical guide to short-lived credentials in agentic systems__](https://blog.gitguardian.com/short-lived-credentials-in-agentic-systems-a-practical-trade-off-guide/).\n\n### **Keep secrets out of prompts, logs, and shared tools**\n\nTrain people not to paste credentials into prompts, and back the policy with tooling. Scan prompts before they reach the agent, sanitize logs, and give agents credentials through a vault or environment variables rather than chat. Check Slack, Jira, Confluence, and shared drives for exposed credentials on a regular basis, and revoke what you find. This is where agentic AI hooks really shine, as they can automate a lot of this process as these assets are being created or modified.\n\n### **Monitor agent activity and plan for revocation**\n\nContinuous monitoring matters more for agents than for scripts because their behavior varies by design. Log what each agent identity accesses, alert on unusual patterns, and write access policies for agents the same way you do for human users. Back those policies with policy enforcement in your pipelines and gateways, not only in a document. Decide in advance how you will revoke an agent's credentials quickly if it misbehaves or leaks a key.\n\nDecoy credentials help here. A honeytoken placed where no agent or person should ever look alerts the moment someone uses it, which gives you a high-confidence signal of misuse.\n\n## **How GitGuardian secures the credentials behind AI agents**\n\nGitGuardian is a credential layer security platform. It treats every exposure of a secret as one connected record in a unified platform. That holds whether the secret sits in a vault, a Slack thread, a repository, or an agent's configuration file.\n\nFor AI agents, the work starts with the identity behind each credential. The GitGuardian platform discovers machine identities across the full credential layer, including repositories, CI/CD, cloud, and collaboration tools. The platform automatically attributes ownership and shows risk scores. Each finding arrives with its owner, what it can access, and how far it has spread, so teams know which credential to resolve first. Internal Secrets Monitoring scans the places agents read and write, including Slack, Jira, and Confluence. A key that leaks into agent context is found where it lands. At the source, [__ggshield__](https://www.gitguardian.com/ggshield?ref=blog.gitguardian.com) blocks secrets at pre-commit and in CI, and [__AI Hooks__](https://blog.gitguardian.com/ai-hooks-ai-coding-assistants/) catch credentials in a prompt before it reaches agents such as Claude Code, Cursor, and GitHub Copilot. ggshield already runs on more than 600,000 developer machines.\n\nGitGuardian works alongside your vault, identity and access management (IAM), and privileged access management (PAM) programs rather than replacing them. It finds the credentials those programs never registered and hands them back with context. It detects credential exposure wherever it appears, ties it to the identity behind it, drives remediation at scale, and stops the next leak at the source.\n\n## **Getting your identity governance strategy ready for the speed of AI**\n\nThere are no guarantees about what AI agents will ultimately deliver, but it is clear the change is happening at an unprecedented pace that is only accelerating. Deploying self-guiding AI agents that interact with other systems and agents brings real perils and a lot of promise for working more efficiently.\n\nThe teams that keep up treat agents as identities from day one: inventoried, owned, scoped to their task, and backed by credentials that expire. Managing non-human identities for AI agents extends the non-human identity governance you already run for service accounts, with more automation and less standing access. Strong identity security for agents starts with the credentials, because that is what an attacker uses to get in.\n\nAuditors are starting to ask about this, too. Regulations such as the Digital Operational Resilience Act and the NIS 2 Directive expect documented risk management that auditors increasingly read to include machine identities. The EU AI Act adds logging and cybersecurity obligations for high-risk AI systems. An up-to-date record of agent identities and owners gives you evidence of your security posture when those questions arrive.\n\nAs AI adoption grows, securing non-human identities and the credentials behind your agents belongs on the same roadmap as the agents themselves.\n\n[Govern your AI agent identities](https://www.gitguardian.com/nhi-governance?ref=blog.gitguardian.com)\n\n## FAQ\n\n## What is a non-human identity in the context of AI agents?\n\nA non-human identity is any identity that software uses to authenticate and act without a person present. For AI agents, that means the API keys, OAuth tokens, service accounts, and MCP server credentials the agent uses to call models, tools, and data sources. The agent is an identity too, because it decides which of those credentials to use and when.\n\n## Are AI agents considered non-human identities?\n\nYes. AI agents authenticate to systems, hold permissions, and act without a human approving each step, which makes them non-human identities. They are a more demanding kind than service accounts or scripts. Their behavior varies by design, they often need many credentials at once, and they can act on behalf of a user and inherit that user's permissions. Treat each agent as an identity with an owner, a scope, and an end date.\n\n## What are the biggest non-human identity risks from AI agents?\n\nThe biggest risks come from the credentials agents use. Agents often get broad, standing permissions, so one leaked key exposes far more than intended. Their secrets spread into prompts, logs, tickets, chat threads, MCP configuration files, and AI-generated code. Many keys also outlive their owners and keep working long after a project ends. Attackers who find any of these credentials can log in as the agent instead of breaking in.\n\n## How do enterprises secure non-human identities and AI agents?\n\nEnterprises secure AI agents the same way they secure other non-human identities, with tighter discipline. They inventory every agent and its credentials, inside and outside the vault, and assign each one an owner. They scope permissions to the task and move toward zero standing privilege. They prefer short-lived credentials and keep secrets out of prompts and collaboration tools. They scan code before it is committed and monitor agent activity with a plan for fast revocation.\n\n## How do organizations identify and remediate orphaned AI access?\n\nOrganizations find orphaned AI access by comparing the credentials agents use against a list of current owners. Scan repositories, CI/CD, collaboration tools, and vaults for agent credentials, then map each one to a person or team. Anything without an owner, or tied to someone who has left, gets reviewed. Revoke what nobody needs, reassign what is still in use, and replace long-lived keys with scoped, short-lived credentials.\n\n## What does least privilege mean for AI agents?\n\nLeast privilege for AI agents means each agent holds only the permissions its current task requires, for only as long as it needs them. In practice, that means narrow API scopes, separate credentials per agent and per tool, just-in-time access for sensitive actions, and regular reviews that remove unused permissions. It also means no single agent gets private data access, untrusted input, and an outbound channel at the same time.\n\n## What is non-human identity management for enterprise AI agents?\n\nNon-human identity management for enterprise AI agents is the practice of tracking every agent identity and credential from creation to retirement. It covers discovery, ownership, permission scoping, credential storage and rotation, monitoring, and offboarding when an agent or project ends. It extends the identity governance teams already run for service accounts, adapted for agents that act autonomously and need many credentials at once.\n\n## How do you keep secrets out of AI prompts?\n\nKeep secrets out of AI prompts with a mix of policy and tooling. Tell users never to paste keys or tokens into prompts, and give agents credentials through a vault or environment variables instead of chat. Use hooks or gateways that scan prompts for secrets before they reach the model. Sanitize logs and chat histories too, because prompts are often stored long after the session ends.", "url": "https://wpnews.pro/news/ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them", "canonical_source": "https://blog.gitguardian.com/nhi-security-in-the-age-of-ai/", "published_at": "2026-11-26 14:10:00+00:00", "updated_at": "2026-11-26 15:14:49.289145+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-policy"], "entities": ["GitGuardian", "CrowdStrike", "Palo Alto Networks"], "also_reported_by": [], "takeaway": "Treat each AI agent as a non-human identity: inventory its API keys, OAuth tokens and service accounts, give it a named owner, scope permissions to the task, and use short-lived credentials kept out of prompts, logs and MCP config files.", "recommendation": {"advice": "Inventory every agent credential inside and outside your vault, assign a named owner, scope permissions to the task, and replace standing keys with short-lived tokens kept out of prompts and MCP configs.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them", "markdown": "https://wpnews.pro/news/ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them.md", "text": "https://wpnews.pro/news/ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them.txt", "jsonld": "https://wpnews.pro/news/ai-agents-and-non-human-identities-the-security-risks-and-how-to-reduce-them.jsonld"}}