<?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: Jurgen PWR</title>
    <description>The latest articles on DEV Community by Jurgen PWR (@__ef194fa65).</description>
    <link>https://dev.to/__ef194fa65</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3895661%2F6caa1cbb-dff4-4fb8-a1d0-d53e380a8b7c.png</url>
      <title>DEV Community: Jurgen PWR</title>
      <link>https://dev.to/__ef194fa65</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/__ef194fa65"/>
    <language>en</language>
    <item>
      <title>AI Agent Security: How to Build Agents That Don't Leak Your API Keys</title>
      <dc:creator>Jurgen PWR</dc:creator>
      <pubDate>Fri, 24 Apr 2026 09:04:58 +0000</pubDate>
      <link>https://dev.to/__ef194fa65/ai-agent-security-the-threat-model-every-builder-needs-to-know-5ghm</link>
      <guid>https://dev.to/__ef194fa65/ai-agent-security-the-threat-model-every-builder-needs-to-know-5ghm</guid>
      <description>&lt;p&gt;A practical guide to credential management, secrets handling, and supply chain defense for AI agent builders.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters Right Now
&lt;/h2&gt;

&lt;p&gt;The AI agent ecosystem is exploding. Every week there's a new framework, a new tool, a new way to let LLMs take actions in the real world. But there's a dirty secret no one talks about openly:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Most AI agents are security disasters waiting to happen.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Bitwarden CLI compromise (April 2026) is just the latest example. A popular tool, trusted by thousands, got backdoored through a supply chain attack. &lt;a href="https://github.com/Infisical/agent-vault" rel="noopener noreferrer"&gt;Agent Vault&lt;/a&gt; — an open-source credential proxy — appeared as a direct response.&lt;/p&gt;

&lt;p&gt;These aren't isolated incidents. They're symptoms of a gold rush ignoring security fundamentals.&lt;/p&gt;

&lt;p&gt;If you're building AI agents, you need to understand:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to store secrets without hardcoding them&lt;/li&gt;
&lt;li&gt;How to give agents only the access they need (principle of least privilege)&lt;/li&gt;
&lt;li&gt;How to detect when your dependencies are compromised&lt;/li&gt;
&lt;li&gt;How to rotate credentials when things go wrong&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This guide covers all four.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Threat Model
&lt;/h2&gt;

&lt;p&gt;Before diving into solutions, let's be clear about what you're defending against.&lt;/p&gt;

&lt;h3&gt;
  
  
  Threat Vector 1: Hardcoded Secrets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# DON'T DO THIS — ever
&lt;/span&gt;&lt;span class="n"&gt;openai_api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sk-prod-1234567890abcdef&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anyone with repo access — collaborators, accidentally-public repos, ex-employees — now has your production key. GitHub scans for these automatically. So do attackers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Threat Vector 2: Over-Privileged Agents
&lt;/h3&gt;

&lt;p&gt;Your agent doesn't need full admin access to your AWS account just to read S3 buckets. But most agent configs grant admin because it's &lt;em&gt;easier&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;When that agent gets compromised — and it will — the attacker has the keys to your entire infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Threat Vector 3: Dependency Supply Chain
&lt;/h3&gt;

&lt;p&gt;You &lt;code&gt;pip install&lt;/code&gt; a library. That library updates. The update is compromised. Now your agent is a backdoor into your infrastructure.&lt;/p&gt;

&lt;p&gt;This isn't theoretical. It happened to npm. It happened to PyPI. It happened to RubyGems. And in April 2026 — it happened to the Bitwarden CLI, one of the most trusted password manager CLIs in the ecosystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Threat Vector 4: Credential Persistence
&lt;/h3&gt;

&lt;p&gt;Agents run long tasks. Credentials expire mid-run. The agent panics and — in a worst-case implementation — logs raw auth headers to a file "for debugging."&lt;/p&gt;




&lt;h2&gt;
  
  
  Solution 1: Never Store Secrets in Code
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Option A: Environment Variables (Start Here)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env file — add to .gitignore immediately&lt;/span&gt;
&lt;span class="nv"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk-prod-xxxxx
&lt;span class="nv"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk-ant-api-xxxxx
&lt;span class="nv"&gt;AWS_ACCESS_KEY_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;xxxxx
&lt;span class="nv"&gt;AWS_SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;xxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY not set — refusing to start&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never hardcode. Never log. Never pass in URLs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option B: HashiCorp Vault (Production)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Fetch secret at runtime, not at deploy time&lt;/span&gt;
vault kv get &lt;span class="nt"&gt;-field&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;api_key secret/ai-agents/production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your agent gets credentials on startup from Vault. Rotate without redeploying.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option C: Cloud-Native Secrets Managers
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cloud&lt;/th&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;SDK&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS&lt;/td&gt;
&lt;td&gt;Secrets Manager / Parameter Store&lt;/td&gt;
&lt;td&gt;&lt;code&gt;boto3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GCP&lt;/td&gt;
&lt;td&gt;Secret Manager&lt;/td&gt;
&lt;td&gt;&lt;code&gt;google-cloud-secret-manager&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure&lt;/td&gt;
&lt;td&gt;Key Vault&lt;/td&gt;
&lt;td&gt;&lt;code&gt;azure-keyvault-secrets&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# AWS example — fetch at runtime
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;secretsmanager&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;eu-central-1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_secret_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SecretId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;secret_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SecretString&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prod/ai-agent/openai-key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Solution 2: Principle of Least Privilege
&lt;/h2&gt;

&lt;p&gt;Your AI agent should have exactly the permissions it needs — no more.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS IAM: Scope to the Bucket
&lt;/h3&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;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&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="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Action"&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="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"s3:PutObject"&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;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::my-specific-agent-bucket/*"&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;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="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not &lt;code&gt;s3:*&lt;/code&gt;. Not &lt;code&gt;*&lt;/code&gt;. Only what the agent actually needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Token Scopes
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent Task&lt;/th&gt;
&lt;th&gt;Required Scopes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read issues only&lt;/td&gt;
&lt;td&gt;&lt;code&gt;issues:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comment on PRs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pull_requests:write&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create releases&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;contents:write&lt;/code&gt; + &lt;code&gt;actions:write&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read repo metadata&lt;/td&gt;
&lt;td&gt;&lt;code&gt;metadata:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Create a fine-grained token scoped to the specific repo. Not a classic token with full repo access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rotating Credentials
&lt;/h3&gt;

&lt;p&gt;Build rotation into your agent's startup sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;startup_with_rotation&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;current_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fetch_from_secrets_manager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;openai-key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Verify key works before proceeding
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;verify_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Key may have been rotated already — fetch latest
&lt;/span&gt;        &lt;span class="n"&gt;current_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;refresh_from_secrets_manager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;openai-key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;verify_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;All credentials invalid — stopping agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current_key&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Solution 3: Supply Chain Defense
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pin Dependencies with Hash Verification
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WRONG — auto-updates pull in compromised versions&lt;/span&gt;
requests&amp;gt;&lt;span class="o"&gt;=&lt;/span&gt;2.28.0

&lt;span class="c"&gt;# RIGHT — exact version + hash verification&lt;/span&gt;
&lt;span class="nv"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;2.31.0     &lt;span class="nt"&gt;--hash&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sha256:58cd2187423d85b68bbe7b0f6f5a3e4f4d7ee7d7e1b1e0b1f9a9e5b4c3d2e1f0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate hashes automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip-compile &lt;span class="nt"&gt;--generate-hashes&lt;/span&gt; requirements.in &lt;span class="nt"&gt;-o&lt;/span&gt; requirements.txt
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt &lt;span class="nt"&gt;--require-hashes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if any package is tampered with, installation fails loudly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automate Security Audits
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Python — runs in CI, fails build on known vulnerabilities&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;pip-audit
pip-audit

&lt;span class="c"&gt;# Node.js&lt;/span&gt;
npm audit &lt;span class="nt"&gt;--audit-level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;high

&lt;span class="c"&gt;# Container images (check what's inside your Docker image)&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;syft
syft packages python:3.11-slim &lt;span class="nt"&gt;-o&lt;/span&gt; table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this to your CI/CD pipeline. Every PR. Every deploy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Subscribe to Alerts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/advisories" rel="noopener noreferrer"&gt;GitHub Advisory Database&lt;/a&gt; — subscribe by ecosystem&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://socket.dev/" rel="noopener noreferrer"&gt;Socket.dev&lt;/a&gt; — real-time analysis of npm/PyPI packages&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scorecard.dev/" rel="noopener noreferrer"&gt;OpenSSF Scorecard&lt;/a&gt; — rates your dependencies' security posture&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Solution 4: The Agent Vault Pattern
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Infisical/agent-vault" rel="noopener noreferrer"&gt;Agent Vault&lt;/a&gt; (by Infisical) represents a new architectural pattern emerging directly from incidents like the Bitwarden compromise.&lt;/p&gt;

&lt;p&gt;The idea: &lt;strong&gt;never give your agent direct access to secrets&lt;/strong&gt;. Instead, the agent talks to a local proxy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traditional:
agent ──────────────────────────► Cloud Secrets Manager
         (direct, persistent creds)

Agent Vault pattern:
agent → Agent Vault (local proxy) → Cloud Secrets Manager
              │
              ├── audit log (every credential access)
              ├── rate limiting (prevent bulk exfil)
              ├── scope enforcement (agent can't request secrets outside its scope)
              └── instant revocation (kill switch without redeploying agent)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you kill the proxy, the agent loses access immediately. No waiting for token expiry. No hunting down where credentials are cached.&lt;/p&gt;

&lt;p&gt;Setup is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Agent Vault&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;agent-vault

&lt;span class="c"&gt;# Start the proxy (runs locally on a port your agent can reach)&lt;/span&gt;
agent-vault serve &lt;span class="nt"&gt;--config&lt;/span&gt; agent-vault.yaml

&lt;span class="c"&gt;# Your agent now talks to localhost instead of directly to Vault/AWS&lt;/span&gt;
&lt;span class="nv"&gt;SECRETS_PROXY_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://localhost:8200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pattern is worth adopting if you're building anything production-facing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Deployment Checklist
&lt;/h2&gt;

&lt;p&gt;Before shipping any AI agent to production, run through this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secrets &amp;amp; Credentials&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Zero hardcoded secrets in code or config files&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;.env&lt;/code&gt; files added to &lt;code&gt;.gitignore&lt;/code&gt; before first commit&lt;/li&gt;
&lt;li&gt;[ ] Secrets loaded from env vars or secrets manager at runtime&lt;/li&gt;
&lt;li&gt;[ ] Credential rotation documented and tested at least once&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Permissions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Agent uses scoped IAM role / fine-grained token&lt;/li&gt;
&lt;li&gt;[ ] No admin-level access anywhere unless explicitly required&lt;/li&gt;
&lt;li&gt;[ ] Token scopes reviewed and minimized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] All dependencies pinned to exact versions&lt;/li&gt;
&lt;li&gt;[ ] Hash verification enabled (&lt;code&gt;--require-hashes&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;pip-audit&lt;/code&gt; or &lt;code&gt;npm audit&lt;/code&gt; running in CI&lt;/li&gt;
&lt;li&gt;[ ] Alert subscription active for used packages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Runtime&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Agent Vault or equivalent proxy in place (or on roadmap)&lt;/li&gt;
&lt;li&gt;[ ] Access logs being collected&lt;/li&gt;
&lt;li&gt;[ ] Credential expiry handled gracefully in code&lt;/li&gt;
&lt;li&gt;[ ] Incident response plan exists (who do you call when a key leaks?)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Threat&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hardcoded secrets&lt;/td&gt;
&lt;td&gt;Env vars → Vault → Cloud secrets manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Over-privileged agents&lt;/td&gt;
&lt;td&gt;Scoped IAM + fine-grained tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supply chain&lt;/td&gt;
&lt;td&gt;Pin + hash + audit in CI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Credential drift&lt;/td&gt;
&lt;td&gt;Agent Vault proxy + rotation logic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The AI agent gold rush isn't slowing down. The security incidents aren't either. Build this in from the start — retrofitting security onto a running agent in production is significantly harder.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Found this useful? Follow for more practical AI agent guides.&lt;/em&gt;&lt;/p&gt;

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