<?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: Deve</title>
    <description>The latest articles on DEV Community by Deve (@fortresschart_dev).</description>
    <link>https://dev.to/fortresschart_dev</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%2F4066482%2F12365600-ccbd-468a-8f53-f7891978fad1.png</url>
      <title>DEV Community: Deve</title>
      <link>https://dev.to/fortresschart_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fortresschart_dev"/>
    <language>en</language>
    <item>
      <title>I blocked XSS attacks and API Key extraction in the browser by monkey-patching `crypto.subtle`. Why isn't everyone doing this?</title>
      <dc:creator>Deve</dc:creator>
      <pubDate>Thu, 06 Aug 2026 21:06:43 +0000</pubDate>
      <link>https://dev.to/fortresschart_dev/i-blocked-xss-attacks-and-api-key-extraction-in-the-browser-by-monkey-patching-28be</link>
      <guid>https://dev.to/fortresschart_dev/i-blocked-xss-attacks-and-api-key-extraction-in-the-browser-by-monkey-patching-28be</guid>
      <description>&lt;p&gt;Here is how I hardened the browser runtime for a Zero-Knowledge, Non-Custodial FinTech trading terminal. 👇 &lt;br&gt;
Client-Side Envelope Encryption:&amp;nbsp;&lt;br&gt;
I derive a KEK from the user's password using PBKDF2-SHA256 (310,000 iterations). Then, a secure random 32-byte DEK (AES-256-GCM) encrypts the data.&amp;nbsp;&lt;br&gt;
The password NEVER touches the server, and the DEK has a strict 15-min TTL in RAM before a wipe.&lt;br&gt;
Secure Enclave Anti-Export Guard:&amp;nbsp;&lt;br&gt;
CryptoKeys are generated via &lt;code&gt;crypto.subtle&lt;/code&gt; with &lt;code&gt;{extractable: false}&lt;/code&gt;. To prevent injected malicious scripts from bypassing the sandbox, I implemented an isolated closure that overrides (monkey-patches) the native browser API:&lt;br&gt;
crypto.subtle.exportKey = async function(format, key) { &lt;/p&gt;

&lt;p&gt;&amp;nbsp; &amp;nbsp; if (isProtectedKey(key)) { &lt;/p&gt;

&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _AuditChain.append('EXPORT_ATTEMPT', 'CRITICAL'); &lt;/p&gt;

&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new Error('Export BLOCKED — unauthorized'); &lt;/p&gt;

&lt;p&gt;&amp;nbsp; &amp;nbsp; } &lt;/p&gt;

&lt;p&gt;&amp;nbsp; &amp;nbsp; return _origExport(format, key); &lt;/p&gt;

&lt;p&gt;};&lt;br&gt;
If our database is breached, hackers find ZERO financial data. If the local session is compromised, runtime gating blocks extraction.&lt;br&gt;
Plus, client-side validation rejects API keys with withdrawal permissions enabled (zero custodial risk under MiCA, built for GDPR).&lt;br&gt;
The entire architecture runs client-side (WebSocket throttled at 100ms + local AI Advisor), keeping server costs near zero.&lt;br&gt;
Where does this runtime isolation logic fail? Why do major SaaS platforms still rely on standard local storage?&amp;nbsp;&lt;br&gt;
Let's discuss. 💬&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>security</category>
      <category>fintech</category>
    </item>
  </channel>
</rss>
