Key Takeaways
- Long-lived API keys are vulnerable like static passwords: they don’t prove who holds them, have broad permissions and lack MFA compatibility.
- According to their 2026 report, GitGuardian discovered 24,000+ unique secrets in public MCP configuration files.
- Replacing API keys with short-lived, scoped OAuth tokens for identity-verified agents can limit damage from credential theft attacks.
AI agents are more prevalent than ever, but authentication and permissions management isn’t keeping pace. All too often, static API keys with broad permissions are just pasted into config files. Agents read the file and get unscoped access to tools and data.
Despite being a common practice, it’s a dangerous one. Long-lived API keys are like passwords (or any other static credential), meaning they’re susceptible to theft and misuse.
GitGuardian’s The State of Secrets Sprawl 2026 report found that MCP configuration files regularly expose secrets. Specifically, they found over 24,000 unique secrets exposed. Organizations are constantly putting themselves at risk, and it’s standard practice.
What Is an API Key?
Think of an API key as a username and password for software. It’s a code that identifies and authenticates a user or application, and it grants access based on the possession of a static key.
API keys are highly appealing because they’re simple and offer immediate proof of concept. However, compared to tokens, they are severely lacking in security.
Just like static passwords, whoever obtains an API key gets access without the need to prove their identity. Consider how device authentication has moved well beyond static credentials; certificates rule the world of enterprise network security. But with agentic AI, vulnerable, outdated methods are the norm.
AI Agents and API Keys
When you connect your AI agent to many application programming interfaces (APIs), the number of API keys you’ve input, as well as their various locations, can get fuzzy. API keys are a convenient way to give AI agents access to data and applications, so it’s easy to see why they’re frequently copied and pasted around. But before you know it, you’re managing a slew of static keys and losing track of their whereabouts; that’s an overwhelming security headache that poses real risk to your organization.
If even one key falls into the wrong hands, bad actors can cause considerable harm. Exposed API keys (such as via public code repositories or logs) are easily discoverable and, because they don’t identify the bearer, can be used anonymously.
The danger doesn’t always come from outside, though. Compared to human users, Large Language Models (LLMs) can be more unpredictable when granted over-permissioned access to apps and data. Since API keys typically have broad permissions, unexpected behavior from your own agent can cause considerable damage.
Next, let’s look at a safer and more secure alternative to API keys.
What Is an OAuth Token?
Open Authorization (OAuth) tokens are vastly more secure than API keys. Many organizations use OAuth tokens as an authentication mechanism. They delegate access to external apps or third parties without unnecessarily exposing credentials.
Types of OAuth tokens include access tokens, ID tokens and refresh tokens. Although OAuth tokens are more secure than API keys, they are not a magic bullet on their own. They require proper monitoring and management.
These conditions demand token revocation:
- When a token is no longer needed
- When an anomaly is detected
With the right policies and practices, organizations can reduce the risk of security threats. Token replay attacks, where an attacker uses a stolen token to gain unauthorized access, can be mitigated through short-lived tokens, automatic token revocation and behavioral detection, among other practices.
See your security gap before attackers do.
See continuous trust in action on a platform that includes RADIUS, PKI and AI security.
API Keys: Similarities to Passwords + Unique Problems
API keys and passwords share several problems, as explained in the following table:
|
Characteristic |
Passwords |
API Keys |
|---|---|---|
|
Proves Who's Holding It |
No |
No |
|
Lifespan |
Long-lived and static; often usable for years; often requires manual rotation |
Long-lived and static; often usable for years; often requires manual rotation |
|
Where It Can Be Used |
From anywhere |
From anywhere |
|
Username Required |
Yes |
No |
|
Multi-Factor Authentication (MFA) |
Can be paired with MFA |
Doesn't mesh with MFA |
|
Permissions |
Generally not a problem |
Often broad and general |
For one thing, neither passwords nor API keys proves who is holding them.
API keys and passwords act like a door key, which anybody can use to turn the lock. Both can be used from anywhere, and as long-lived, static credentials, they often remain usable for years.
But API keys also introduce problems that passwords don’t. Permissions are often broad and general. Unlike passwords, API keys don’t require a username to gain access. And while passwords can be paired with multi-factor authentication (MFA), API keys don’t mesh with MFA.
API Keys: The Stats
We’ve broken down what API keys are, including their weaknesses. Next, we’ll share some startling figures that should make you think twice about relying on API keys for AI agents.
API Keys Leak
AI is accelerating the creation of new credentials, which means more attack surface area. But governance isn’t keeping up. GitGuardian found that in 2025, AI service secrets increased 81% year over year. That figure includes over 110,000 leaked DeepSeek API keys.
API Keys Are Frequently Found in MCP Configuration Files
Unique secrets are routinely stored in MCP configuration files, and it’s because setup documentation frequently recommends users do just that. GitGuardian identified over 24,000 unique secrets in MCP config files across public GitHub. Within those 24,000 were over 2,000 unique valid credentials.
Additionally, out of the top five valid unique secrets in MCP config files, four were API keys, the most exposed being Google API keys.
Secrets Live for Too Long
Linking back to a problem passwords and API keys share: they are valid for far too long.
Why is this a problem? GitGuardian found that long-lived secrets account for 60% of policy breaches. Due to their long lives, they are copied and distributed, evading governance.
Short-lived tokens are one answer to this problem, as they expire quickly, limiting how long bad actors can use them to gain access.
More Security Incidents, Lower Visibility, Big Costs
Akamai’s 2026 API Security Impact Study found that in the past 12 months, 87% of organizations globally experienced a security incident related to APIs.
In addition, Akamai asked organizations if they have a full inventory of APIs and if they know which APIs return sensitive data. Of those surveyed, only 23% said yes to both questions, meaning that a lack of visibility into data flows is highly prevalent.
Akamai also found that APIs linked to AI were the most commonly cited incident type, and incidents cost an average of $700,000 annually.
Short-Lived OAuth Tokens: The Alternative to API Keys
It’s clear that, despite being common practice, pasting API keys into config files for AI agents is a dangerous game.
Secret sprawl continues to increase alongside the integration of agentic AI and an unhealthy reliance on static, long-lived credentials. Organizations need a smarter, safer means of granting access to agents to protect sensitive systems and data.
The SecureW2 JoinNow Platform helps you replace vulnerable API keys with fully configurable OAuth tokens, strengthening agent identity and access management.
Unlike API keys and passwords, an OAuth token from the JoinNow Platform is issued only to an agent that has proven its identity, significantly reducing the risk of unauthorized access by malicious actors. Each agent must prove its identity before it’s granted access, and tokens are scoped to only allow access to necessary systems, applications and data, and nothing else.
You can also set OAuth tokens to expire in just minutes, shrinking the window attackers have to replay them in the event of theft.
The security plan that scales with you.
Our solutions can scale from mid-market to global enterprises. Compare options and see how our solutions protect you from costly breaches and ensure peace of mind.
Here’s how the JoinNow Platform grants secure access to autonomous workloads and manages risk, step by step:
- Workload attestation: First, SPIRE verifies the workload’s origin. Once verified, it issues an SVID.
- SVID presentation: Next, SecureW2 inspects the workload’s SVID, checking for authenticity.
- Token issuance: After verifying the SVID, SecureW2 distributes a narrowly scoped OAuth token.
- MCP server access: Finally, the MCP server validates the token and grants the workload appropriate access.
The JoinNow Platform also flags risks and even responds automatically. Here’s the workflow:
- SecureW2 flags an anomaly: risk signals indicate anomalous behavior.
- Risk score is updated: Once Adaptive Defense receives the risk signal, it marks the workload as high-risk.
- Denying token requests: Once the current token expires, the next request for access is automatically denied.
- MCP server access denial: Lacking a valid token, the MCP server is no longer able to reach the target system.
If you’re interested in learning more about how the JoinNow Platform can help your organization reduce machine identity risks and protect sensitive data, schedule a demo.
