<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: A.T</title>
    <description>The latest articles on DEV Community by A.T (@uid0).</description>
    <link>https://dev.to/uid0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3966738%2F4840c6f0-01ac-45fb-8325-7aef70bbabc2.png</url>
      <title>DEV Community: A.T</title>
      <link>https://dev.to/uid0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uid0"/>
    <language>en</language>
    <item>
      <title>Stop Giving AI Agents Standing API Keys</title>
      <dc:creator>A.T</dc:creator>
      <pubDate>Tue, 07 Jul 2026 19:13:43 +0000</pubDate>
      <link>https://dev.to/uid0/stop-giving-ai-agents-standing-api-keys-33e0</link>
      <guid>https://dev.to/uid0/stop-giving-ai-agents-standing-api-keys-33e0</guid>
      <description>&lt;p&gt;AI agents are starting to do real work against real APIs: filing tickets, moving money, updating records, calling other agents. The fastest way to get there is also the most dangerous one — paste a long-lived API key into the agent's environment and let it run. That key is now a standing liability. It rarely expires, it usually carries far more scope than the task needs, and the moment it leaks from a log, a prompt, or a compromised tool, an attacker inherits everything the agent could ever do.&lt;/p&gt;

&lt;p&gt;The fix is not "be more careful with keys." It is to stop issuing standing keys to agents at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Least privilege, but for non-human identities
&lt;/h2&gt;

&lt;p&gt;We have decades of practice applying least privilege to people. Agents are different in three ways that make standing credentials especially risky:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;They act fast and unattended.&lt;/strong&gt; A misused human credential might do damage for minutes before someone notices. An agent loop can make thousands of calls before anyone looks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Their instructions are attacker-reachable.&lt;/strong&gt; Prompt injection means the thing deciding how to use a credential can be steered by untrusted input.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They fan out.&lt;/strong&gt; One agent calls another, which calls a tool, which calls an API. Scope has to travel with the request, not live in a shared secret.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the unit of access for an agent should be a short-lived, narrowly scoped credential minted for a specific task — not a copy of your production key.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "scoped" actually means
&lt;/h2&gt;

&lt;p&gt;A useful scoped credential pins down several dimensions at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Audience&lt;/strong&gt; — which upstream API or MCP server it is valid for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operations&lt;/strong&gt; — which methods or tools, e.g. read but not write.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt; — which endpoints, paths, or object IDs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lifetime&lt;/strong&gt; — minutes, not months. It expires on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate&lt;/strong&gt; — a ceiling on calls per window, so a runaway loop is contained.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice a grant looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"audience"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"api.github.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"operations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"resources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/repos/acme/billing/issues/*"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expires_in"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"15m"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rate_limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"60/min"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When all five are tight, a leaked credential is worth very little: it stops working almost immediately and only ever opened a small door.&lt;/p&gt;

&lt;h2&gt;
  
  
  The broker pattern
&lt;/h2&gt;

&lt;p&gt;The cleanest way to deliver this is a credential broker that sits between your agents and your secrets. The model never sees a real secret. Instead:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent asks the broker to perform an operation (often via an MCP tool).&lt;/li&gt;
&lt;li&gt;The broker checks policy: is this principal allowed to do this, right now, within limits?&lt;/li&gt;
&lt;li&gt;If allowed, the broker injects the real credential at the edge, makes the call, and returns the result.&lt;/li&gt;
&lt;li&gt;Every step is recorded.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because the secret is resolved at call time and never handed to the model, you can rotate or revoke it without touching a single agent. And because the broker is the one place every agent call flows through, it is also the natural place to enforce scope and capture an audit trail.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical migration path
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inventory&lt;/strong&gt; the keys your agents hold today. Anything long-lived and broad is the priority.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Move secrets behind the broker.&lt;/strong&gt; Replace in-agent keys with a reference the broker resolves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tighten scope per task.&lt;/strong&gt; Start permissive, then ratchet down using what the audit log shows the agent actually needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shorten lifetimes.&lt;/strong&gt; Once issuance is automatic, expiry becomes free.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The end state: agents carry no durable secrets, every credential is minted for a purpose and expires on its own, and you can answer "what could this agent do?" by reading a policy instead of guessing. Least privilege was always the goal — scoped, short-lived credentials are how agents get it by default.&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
