<?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: Fazalu Rahman</title>
    <description>The latest articles on DEV Community by Fazalu Rahman (@fazalu_rahman_41075c71a18).</description>
    <link>https://dev.to/fazalu_rahman_41075c71a18</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%2F4042315%2F9543d07c-640e-4b72-a5e6-f0ac0b48c425.png</url>
      <title>DEV Community: Fazalu Rahman</title>
      <link>https://dev.to/fazalu_rahman_41075c71a18</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fazalu_rahman_41075c71a18"/>
    <language>en</language>
    <item>
      <title>How to Prevent API Keys and Secrets from Leaking into LLMs</title>
      <dc:creator>Fazalu Rahman</dc:creator>
      <pubDate>Wed, 22 Jul 2026 15:50:05 +0000</pubDate>
      <link>https://dev.to/fazalu_rahman_41075c71a18/how-to-prevent-api-keys-and-secrets-from-leaking-into-llms-1l92</link>
      <guid>https://dev.to/fazalu_rahman_41075c71a18/how-to-prevent-api-keys-and-secrets-from-leaking-into-llms-1l92</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note: This article was originally published on the &lt;a href="https://community.leaksnitch.com/post/sabHJIvHR-/leaksnitch-is-live-on-the-chrome-web-store" rel="noopener noreferrer"&gt;LeakSnitch Developer Community&lt;/a&gt;. Join the discussion there for raw telemetry and browser-level security benchmarks.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Developers use AI tools like ChatGPT, Claude, Cursor, and Gemini to ship code faster than ever. However, this productivity surge has introduced a massive data leak vector: &lt;strong&gt;accidental secret exfiltration via prompt inputs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When an engineer copies a multi-line config block or debug log to troubleshoot an error, sensitive data, such as live database URIs, AWS credentials, JWT tokens, and SSH keys often gets transmitted directly to external LLM servers.&lt;/p&gt;

&lt;p&gt;In this guide, we will break down why traditional network level security fails, explore the mechanics of detecting secrets locally inside the browser, and look at how to implement real-time DOM-level detection.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Traditional Network DLP Fails against LLM Leaks
&lt;/h2&gt;

&lt;p&gt;Most enterprise security strategies rely on Data Loss Prevention (DLP) tools placed at the network layer or API gateway. While effective for standard file transfers, network DLP falls short when protecting against AI prompt leaks for two core reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Payload Construction Happens at the Client:&lt;/strong&gt; By the time an HTTP request reaches a network gateway, the browser DOM has already constructed the payload. Inspecting HTTPS traffic at the gateway often requires invasive TLS decryption, introducing noticeable latency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer Experience &amp;amp; Blanket Bans:&lt;/strong&gt; Blocking access to domain endpoints like &lt;code&gt;api.openai.com&lt;/code&gt; or &lt;code&gt;claude.ai&lt;/code&gt; at the firewall level creates friction. Developers often bypass blanket bans by switching to personal hotspots or unmonitored devices, introducing unmonitored "shadow IT."&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To catch secrets without disrupting developer workflow, inspection must happen at the &lt;strong&gt;point of intent&lt;/strong&gt; -inside the browser DOM &lt;strong&gt;before&lt;/strong&gt; the request payload is generated.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Technical Mechanics of Secret Detection
&lt;/h2&gt;

&lt;p&gt;Detecting secrets in prompt payloads requires balancing accuracy with execution speed. If evaluation takes longer than 50ms, it degrades the user experience.&lt;/p&gt;

&lt;p&gt;Two primary techniques are used in tandem: &lt;strong&gt;Regex Pattern Matching&lt;/strong&gt; and &lt;strong&gt;Shannon Entropy Analysis&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. High-Confidence Regex Matching
&lt;/h3&gt;

&lt;p&gt;Structured credentials (like AWS Access Keys or GitHub Personal Access Tokens) follow predictable patterns with clear prefixes.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
// Examples of high-confidence structured secret patterns
const SECRET_PATTERNS = {
  awsAccessKey: /^AKIA[0-9A-Z]{16}$/,
  githubPat: /^ghp_[a-zA-Z0-9]{36}$/,
  slackToken: /^xox[baprs]-[0-9a-zA-Z]{10,48}$/,
  stripeKey: /^sk_live_[0-9a-zA-Z]{24,}$/
};

function checkStructuredSecret(input) {
  for (const [provider, pattern] of Object.entries(SECRET_PATTERNS)) {
    if (pattern.test(input)) {
      return { detected: true, type: provider };
    }
  }
  return { detected: false };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>security</category>
      <category>appsec</category>
      <category>chatgpt</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
