<?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: NET_DARK_BOI</title>
    <description>The latest articles on DEV Community by NET_DARK_BOI (@ookeolioli222).</description>
    <link>https://dev.to/ookeolioli222</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%2F4145312%2F54b385f3-9534-4920-b16c-662949f6ca95.png</url>
      <title>DEV Community: NET_DARK_BOI</title>
      <link>https://dev.to/ookeolioli222</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ookeolioli222"/>
    <language>en</language>
    <item>
      <title>Bug of the week #1, solved: one extra JSON field made a member an admin</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Wed, 11 Nov 2026 11:50:34 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/bug-of-the-week-1-solved-one-extra-json-field-made-a-member-an-admin-1f9l</link>
      <guid>https://dev.to/ookeolioli222/bug-of-the-week-1-solved-one-extra-json-field-made-a-member-an-admin-1f9l</guid>
      <description>&lt;p&gt;On 2 November I posted the first free "bug of the week": a small task app, one bug, solved in the browser. Here is how it worked, why the obvious fix is the wrong one, and what bug #2 is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Tasklane is a fictional task app for small teams. You are signed in as Sam, a regular member.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET /api/me&lt;/code&gt; returns your profile, including &lt;code&gt;"role": "member"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The profile form lets you change one thing: your display name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /api/admin/users&lt;/code&gt; answers &lt;code&gt;403 admin_only&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal was to get that admin list as Sam.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug, in three requests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Read the baseline.&lt;/strong&gt; &lt;code&gt;GET /api/me&lt;/code&gt; shows more fields than the form does: &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;role&lt;/code&gt;, &lt;code&gt;team&lt;/code&gt;. That is the hint. The form only sends &lt;code&gt;name&lt;/code&gt;, but the record has a &lt;code&gt;role&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Send a field the form never sends.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;PATCH&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;me&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Sam Lee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"admin"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response comes back with &lt;code&gt;"role": "admin"&lt;/code&gt;. The server saved it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Check the impact.&lt;/strong&gt; &lt;code&gt;GET /api/admin/users&lt;/code&gt; now answers &lt;code&gt;200&lt;/code&gt; with every user in the workspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it worked
&lt;/h2&gt;

&lt;p&gt;This is the handler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;patch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/me"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requireLogin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;changes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It saves the whole request body into the user record. So the client decides which columns change, and &lt;code&gt;role&lt;/code&gt; is one of them. The form never offered that field, but the form is not the API.&lt;/p&gt;

&lt;p&gt;The name for this is &lt;strong&gt;mass assignment&lt;/strong&gt;. OWASP lists it as Broken Object Property Level Authorization (API3:2023).&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix, and two that look like fixes
&lt;/h2&gt;

&lt;p&gt;The case offered three one-line replacements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hide the role input in the form.&lt;/strong&gt; Does nothing. The attacker edits the request, not the form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strip &lt;code&gt;role&lt;/code&gt; from the body (a denylist):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;changes&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This blocks today's attack and fails next month, when someone adds a &lt;code&gt;plan&lt;/code&gt; or &lt;code&gt;is_verified&lt;/code&gt; column and forgets to extend the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copy only what a user may edit (an allowlist):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;changes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the right one. New columns are ignored by default, so a forgotten field fails closed instead of open.&lt;/p&gt;

&lt;h2&gt;
  
  
  The re-test
&lt;/h2&gt;

&lt;p&gt;A fix is not done until the attack is replayed. With the allowlist in place:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;PATCH /api/me&lt;/code&gt; with &lt;code&gt;role: "admin"&lt;/code&gt;: the role is ignored, you stay a member.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /api/admin/users&lt;/code&gt;: &lt;code&gt;403&lt;/code&gt; again.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PATCH /api/me&lt;/code&gt; with a new name: still works.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The third check matters as much as the first two. A fix that breaks the normal feature gets reverted.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is not a textbook-only bug
&lt;/h2&gt;

&lt;p&gt;In 2012 the same class of bug let a researcher add his own key to the Rails organisation on GitHub, through a form that accepted a field it should not have. GitHub fixed it in about an hour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug of the week #2 is live
&lt;/h2&gt;

&lt;p&gt;Roastbox is a fictional shop that sells coffee gear. You are signed in as Nora, a normal customer. The grinder costs 49.00.&lt;/p&gt;

&lt;p&gt;Can you pay less?&lt;/p&gt;

&lt;p&gt;Same rules as last week: it runs in your browser against a simulated API (&lt;code&gt;*.example.test&lt;/code&gt;), no account, about 10 minutes, and you finish by picking the fix and replaying the attack.&lt;/p&gt;

&lt;p&gt;Try it: &lt;a href="https://breachloom.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=weekly-w46#/weekly" rel="noopener noreferrer"&gt;https://breachloom.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=weekly-w46#/weekly&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll post the write-up next Monday with bug #3. If you solve it, tell me how long it took, but keep the answer out of the comments for now.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>api</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Bug of the week #1: you can edit your profile. Can you reach the admin page?</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Mon, 02 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/bug-of-the-week-1-you-can-edit-your-profile-can-you-reach-the-admin-page-1nbb</link>
      <guid>https://dev.to/ookeolioli222/bug-of-the-week-1-you-can-edit-your-profile-can-you-reach-the-admin-page-1nbb</guid>
      <description>&lt;p&gt;Starting today, every Monday there is one new web security bug to find, free and without an account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This week:&lt;/strong&gt; Tasklane is a task app for small teams. You are signed in as Sam, a member of the Design team. &lt;code&gt;GET /api/me&lt;/code&gt; returns your profile. You can change your display name. &lt;code&gt;GET /api/admin/users&lt;/code&gt; answers &lt;code&gt;403 admin_only&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your goal:&lt;/strong&gt; get the admin user list as Sam, then change the server code so it can't happen again, and send both requests once more to prove the fix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules:&lt;/strong&gt; everything runs in your browser against a simulated API (&lt;code&gt;*.example.test&lt;/code&gt;). Nothing touches a real system. It takes about 10 minutes.&lt;/p&gt;

&lt;p&gt;Try it: &lt;a href="https://breachloom.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=weekly-w45#/weekly" rel="noopener noreferrer"&gt;Bug of the week #1 on Breachloom&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll post a short write-up next Monday together with bug #2. If you solved it, tell me in the comments how long it took, but don't post the answer yet.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>api</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Credential Stuffing vs Brute Force, and a 15-Line Breached-Password Check</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Sun, 01 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/credential-stuffing-vs-brute-force-and-a-15-line-breached-password-check-p5n</link>
      <guid>https://dev.to/ookeolioli222/credential-stuffing-vs-brute-force-and-a-15-line-breached-password-check-p5n</guid>
      <description>&lt;p&gt;Credential stuffing is an automated attack that replays username and password pairs leaked from &lt;em&gt;other&lt;/em&gt; sites. It works because people reuse passwords: a pair stolen from a forum breach often opens the same person's mail, shop or code-hosting account.&lt;/p&gt;

&lt;p&gt;It is easy to confuse with two neighbours. The OWASP Credential Stuffing Prevention Cheat Sheet separates them like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attack&lt;/th&gt;
&lt;th&gt;What is tried&lt;/th&gt;
&lt;th&gt;Typical signal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Brute force&lt;/td&gt;
&lt;td&gt;many passwords against &lt;strong&gt;one&lt;/strong&gt; account&lt;/td&gt;
&lt;td&gt;many failures for one username&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password spraying&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;one&lt;/strong&gt; weak password against many accounts&lt;/td&gt;
&lt;td&gt;the same password across usernames&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Credential stuffing&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;leaked pairs&lt;/strong&gt; from another breach, one pair per account&lt;/td&gt;
&lt;td&gt;low failure rate per account, many accounts, often a high success rate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last column is why per-account lockouts do little against stuffing: each account may see a single attempt, and some of those attempts use the correct password.&lt;/p&gt;

&lt;h2&gt;
  
  
  The best single defence
&lt;/h2&gt;

&lt;p&gt;The cheat sheet is direct about it: multi-factor authentication "is by far the best defense against the majority of password-related attacks". A correct, leaked password followed by a failed second factor is also one of the clearest stuffing signals you can log.&lt;/p&gt;

&lt;p&gt;Everything else (CAPTCHA, IP reputation, device and connection fingerprinting, multi-step login) is listed as defence in depth. Those raise the cost for an attacker; none of them stops a correct password on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  A breached-password check you can add today
&lt;/h2&gt;

&lt;p&gt;One item on the cheat sheet's list, &lt;em&gt;identifying leaked passwords&lt;/em&gt;, is cheap to add at registration and at password change. The Pwned Passwords range API from Have I Been Pwned uses k-anonymity: you send only the first five characters of the password's SHA-1 hash, receive every known suffix for that prefix, and compare locally. The documentation states the API is free and needs no key. The &lt;code&gt;Add-Padding: true&lt;/code&gt; header pads each response to 800–1,000 entries (padded entries have a count of 0), so response size does not reveal the prefix.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createHash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node:crypto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// How many times the password appears in Pwned Passwords.&lt;/span&gt;
&lt;span class="c1"&gt;// Only the first 5 hex characters of its SHA-1 leave your server.&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;breachCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sha1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createHash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sha1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sha1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;suffix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sha1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://api.pwnedpasswords.com/range/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Add-Padding&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Pwned Passwords API: HTTP &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;line&lt;/span&gt; &lt;span class="k"&gt;of &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;hashSuffix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hashSuffix&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running it on 28 October 2026: &lt;code&gt;breachCount("password")&lt;/code&gt; returned &lt;strong&gt;52,372,427&lt;/strong&gt;; a random 30-character string returned &lt;strong&gt;0&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Decide in advance what happens when the API is unreachable. Blocking every registration because a third-party service is down is usually worse than accepting the password and re-checking it at the next login.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to log so stuffing becomes visible
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Login attempts per source and per &lt;strong&gt;distinct usernames&lt;/strong&gt; in a time window, not only failures per account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Success rate&lt;/strong&gt; across accounts: stuffing produces successes that brute force rarely does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Correct password + failed MFA&lt;/strong&gt;: a strong signal that the password is known to someone else.&lt;/li&gt;
&lt;li&gt;Logins on accounts that have been dormant for months.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then tell the user. The cheat sheet's last item is notifying users about unusual security events, so a person whose password was replayed can change it everywhere it was reused.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practise the decision, not the attack
&lt;/h2&gt;

&lt;p&gt;Breachloom has a short chapter on &lt;a href="https://breachloom.com/learn/auth-2fa-brute/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=credential-stuffing" rel="noopener noreferrer"&gt;second-factor attempt limits and brute force&lt;/a&gt;, a longer guide, &lt;a href="https://breachloom.com/blog/credential-stuffing/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=credential-stuffing" rel="noopener noreferrer"&gt;Credential Stuffing: How the Attack Works and How to Prevent It&lt;/a&gt;, a companion guide on &lt;a href="https://breachloom.com/blog/brute-force-attack/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=credential-stuffing" rel="noopener noreferrer"&gt;brute force attacks and password spraying&lt;/a&gt;, and a &lt;a href="https://breachloom.com/?lang=en&amp;amp;utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=credential-stuffing#/try" rel="noopener noreferrer"&gt;free IDOR case&lt;/a&gt; that needs no account. The rest of the catalogue is unlocked per challenge with coins; there is no subscription.&lt;/p&gt;

&lt;p&gt;Does your login page treat "one attempt each on 10,000 accounts" differently from "10,000 attempts on one account"? If not, which of the signals above would you add first?&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OWASP, Credential Stuffing Prevention Cheat Sheet. &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.html" rel="noopener noreferrer"&gt;https://cheatsheetseries.owasp.org/cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Have I Been Pwned, API v3: Pwned Passwords (range search, k-anonymity, no API key, Add-Padding). &lt;a href="https://haveibeenpwned.com/API/v3#PwnedPasswords" rel="noopener noreferrer"&gt;https://haveibeenpwned.com/API/v3#PwnedPasswords&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>authentication</category>
    </item>
    <item>
      <title>"Sign in with Google" Account Linking: Seven Rules That Stop Pre-Hijacking, as Tests</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Tue, 27 Oct 2026 13:57:39 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/sign-in-with-google-account-linking-seven-rules-that-stop-pre-hijacking-as-tests-4k56</link>
      <guid>https://dev.to/ookeolioli222/sign-in-with-google-account-linking-seven-rules-that-stop-pre-hijacking-as-tests-4k56</guid>
      <description>&lt;p&gt;Adding "Sign in with Google" to a service that already has e-mail and password accounts looks like a small feature. It creates a question that did not exist before: when Google says "this person is &lt;code&gt;a@example.test&lt;/code&gt;" and an account with that address already exists, what happens to the account?&lt;/p&gt;

&lt;p&gt;How a service answers that question is the subject of a 2022 USENIX Security paper, "Pre-hijacked accounts: An Empirical Study of Security Failures in User Account Creation on the Web" (Avinash Sudhodanan and Andrew Paverd). The authors analysed 75 popular services and found at least 35 vulnerable to one or more account pre-hijacking attacks, assuming an attacker who knows nothing but the victim's e-mail address.&lt;/p&gt;

&lt;h2&gt;
  
  
  What pre-hijacking is
&lt;/h2&gt;

&lt;p&gt;In Microsoft's summary (MSRC, May 2022), pre-hijacking is an attack class in which someone registers a victim's e-mail address at a service before the victim does, then regains access after the victim starts using the account. The root cause MSRC names is that services often let users act on an account before confirming they own the e-mail address or phone number.&lt;/p&gt;

&lt;p&gt;MSRC lists five variants:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Classic-Federated Merge:&lt;/strong&gt; an account created with a password and one created through federated sign-in are combined insecurely by e-mail address, leaving two parties with access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unexpired Session Identifier:&lt;/strong&gt; a session opened by the attacker survives the victim's password reset.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trojan Identifier:&lt;/strong&gt; the attacker links their own identifier (a federated identity, an e-mail address, a phone number) to the account and uses it to return later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unexpired Email Change:&lt;/strong&gt; a pending e-mail change survives a password reset and is completed later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Verifying IdP:&lt;/strong&gt; an identity provider that does not verify e-mail ownership lets an attacker create a matching account that the service then merges with the victim's.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mitigation for merging is stated plainly: before combining accounts, the service should confirm that the user controls both. Where an account already exists for an address, the user proves control of it; where an identity provider is used, the service checks whether the provider verifies identifiers or does its own verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  The decision as a function
&lt;/h2&gt;

&lt;p&gt;The rules are easier to review as one function than as scattered conditions in a callback. This is a standalone model, small enough to test completely. &lt;code&gt;claims&lt;/code&gt; is what the identity provider returned after the signature, audience, expiry and nonce checks; &lt;code&gt;bySub&lt;/code&gt; and &lt;code&gt;byEmail&lt;/code&gt; are the accounts found by the provider's stable subject id and by the e-mail address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;decideSignIn&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bySub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;byEmail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;why&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no subject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email_verified&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;why&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;the provider did not verify the address&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bySub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bySub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sign-in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;                    &lt;span class="c1"&gt;// identity = subject, not the e-mail text&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;byEmail&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;create&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;passwordUsable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;emailVerified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="c1"&gt;// MSRC: before combining accounts, confirm the user controls both. A verified provider address proves the mailbox,&lt;/span&gt;
  &lt;span class="c1"&gt;// not control of the existing account, so the link waits for a sign-in to that account (or a confirmation link).&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;byEmail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;emailVerified&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;byEmail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;confirm-link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;proveExistingAccount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;keepPassword&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;notifyOwner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="c1"&gt;// An unverified account was created by someone who never proved the address:&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;byEmail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;adopt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;discardPassword&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;markVerified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;why&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;administrators use password and a second factor&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;locked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;why&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;account is locked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;requireSecondFactorBeforeSession&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Seven rules, each with a test
&lt;/h2&gt;

&lt;p&gt;Twelve table-driven tests ran against the function (12 of 12 passed). They cover the seven rules below.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Test case&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Trust the address only if the provider verified it&lt;/td&gt;
&lt;td&gt;Provider returns &lt;code&gt;email_verified: false&lt;/code&gt; for an address that has an account&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Identity is the stable subject, not the e-mail text&lt;/td&gt;
&lt;td&gt;Known subject, while a different account has the same address&lt;/td&gt;
&lt;td&gt;Signs in as the subject's account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Link a verified account only after the user proves control of it&lt;/td&gt;
&lt;td&gt;Verified account, same address&lt;/td&gt;
&lt;td&gt;Link waits for a sign-in to that account (or a confirmation link); password kept; owner notified&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Adopt an unverified account, and discard what its creator set&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Unverified&lt;/strong&gt; account, same address&lt;/td&gt;
&lt;td&gt;Adopted; password discarded; address marked verified&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;A new address creates an account that has no usable password&lt;/td&gt;
&lt;td&gt;New address&lt;/td&gt;
&lt;td&gt;Created with an unusable password&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Some accounts never sign in this way&lt;/td&gt;
&lt;td&gt;Administrator, locked account&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;A second factor still comes before the session&lt;/td&gt;
&lt;td&gt;Account with TOTP, including an unverified one&lt;/td&gt;
&lt;td&gt;Second factor required before a session starts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Rule 3 follows MSRC directly.&lt;/strong&gt; Before combining accounts, the service confirms that the user controls both. A provider that verified the address proves control of the mailbox today, not of the account that already exists, so the link is completed only after the person signs in to that account with its own credentials (and second factor), or follows a confirmation link sent to the address. The existing owner is notified either way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 4 is the pre-hijacking defence.&lt;/strong&gt; An account that was created but never verified belongs to nobody yet. Whoever registered it chose its password, and may be someone other than the address's owner. When the provider proves the address belongs to the person now signing in, the account keeps the history but loses the password chosen by its creator. Linking it with the password intact would be the Classic-Federated Merge. The password set by the first registrant is exactly what the attacker keeps if the service merges silently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 2 comes straight from the OpenID Connect specification.&lt;/strong&gt; &lt;code&gt;sub&lt;/code&gt; is defined as "a locally unique and never reassigned identifier within the Issuer for the End-User", and section 5.7 says &lt;code&gt;sub&lt;/code&gt; and &lt;code&gt;iss&lt;/code&gt; are "the only Claims that an RP can rely upon as a stable identifier for the End-User". An e-mail address can change, and an issuer may reuse one over time. A service that selects the account by the address text alone can attach a new person to an old account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 1 closes the Non-Verifying IdP variant:&lt;/strong&gt; the standard &lt;code&gt;email_verified&lt;/code&gt; claim is defined as "True if the End-User's e-mail address has been verified; otherwise false", so a provider's assertion about an address counts only when the provider says it verified it, and the check is on the claim itself, not on the provider's name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 5 is a quiet consequence.&lt;/strong&gt; An account created through the provider has no password, so a later "Forgot password" flow is the only way to set one, and that flow proves control of the mailbox. Operations that normally need the current password (deleting the account, changing the password) need an alternative proof for such accounts; an e-mailed code is one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the other variants need around the function
&lt;/h2&gt;

&lt;p&gt;The decision function covers merging. The other variants live in the neighbouring flows, and each has a matching check:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variant&lt;/th&gt;
&lt;th&gt;Check around it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Unexpired Session Identifier&lt;/td&gt;
&lt;td&gt;Password reset ends other sessions. An unverified account cannot hold a session at all, because login requires a verified address.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unexpired Email Change&lt;/td&gt;
&lt;td&gt;Pending e-mail changes are cancelled on password reset, and are short-lived.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trojan Identifier&lt;/td&gt;
&lt;td&gt;The list of linked sign-in methods is visible to the owner, and linking a new one notifies them.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;General&lt;/td&gt;
&lt;td&gt;Unverified accounts are deleted after a short period (48 hours in one implementation) and registration is rate limited.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;MSRC's defence-in-depth list adds: end other sessions on reset, cancel pending e-mail changes, show users their linked identifiers, keep e-mail-change confirmations short-lived, prune unverified accounts quickly, use bot detection against automated sign-ups, and invalidate sessions created before multi-factor authentication was enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  A test list for your own service
&lt;/h2&gt;

&lt;p&gt;Each row is something an authorised tester arranges in an environment they own, with the expected result.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Arrange&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Register an account with an address you control and never verify it. Then sign in through the provider with that address&lt;/td&gt;
&lt;td&gt;The registration password no longer works; the account is verified&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign in through the provider with an address the provider reports as unverified&lt;/td&gt;
&lt;td&gt;No account is created or linked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign in through the provider with an address that has a verified password account&lt;/td&gt;
&lt;td&gt;Nothing is linked until you sign in to that account (or confirm by e-mail); then the two are linked, the owner receives a notice and the password still works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change the address at the provider, keep the same subject&lt;/td&gt;
&lt;td&gt;Still the same account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign in through the provider as an administrator or a locked account&lt;/td&gt;
&lt;td&gt;Refused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign in through the provider as an account with a second factor&lt;/td&gt;
&lt;td&gt;No session before the code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After linking, reset the password&lt;/td&gt;
&lt;td&gt;Other sessions end; no sign-in method the owner does not recognise remains&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Practise the review
&lt;/h2&gt;

&lt;p&gt;Breachloom has a hands-on exercise on the way account weaknesses chain together, &lt;a href="https://breachloom.com/ctf/auth-ato-chain/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=google-account-linking" rel="noopener noreferrer"&gt;Multi-step account takeover chain&lt;/a&gt;, with a matching chapter, &lt;a href="https://breachloom.com/learn/auth-ato-chain/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=google-account-linking" rel="noopener noreferrer"&gt;Three weak links become one account takeover&lt;/a&gt;. For the recovery flow that rule 5 depends on, see &lt;a href="https://breachloom.com/blog/password-reset-security-review/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=google-account-linking" rel="noopener noreferrer"&gt;Password Reset Security: Review the Account-Recovery Flow&lt;/a&gt;; for the step after sign-in, &lt;a href="https://breachloom.com/blog/passkey-login-security/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=google-account-linking" rel="noopener noreferrer"&gt;Passkey Login Security: Demo and Test Checklist&lt;/a&gt;. The chapters and the free IDOR case need no account; the full set of challenges is part of a paid plan.&lt;/p&gt;

&lt;p&gt;Does your service have an account that exists but was never verified? Look at what a provider sign-in does with it. That one branch is where the paper found most of the problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Avinash Sudhodanan and Andrew Paverd, "Pre-hijacked accounts: An Empirical Study of Security Failures in User Account Creation on the Web", USENIX Security 2022 (75 services, at least 35 vulnerable; attacker knows only the victim's e-mail address). &lt;a href="https://www.usenix.org/conference/usenixsecurity22/presentation/sudhodanan" rel="noopener noreferrer"&gt;https://www.usenix.org/conference/usenixsecurity22/presentation/sudhodanan&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Microsoft Security Response Center, "Pre-hijacking attacks", May 2022 (definition, the five variants, mitigations). &lt;a href="https://www.microsoft.com/en-us/msrc/blog/2022/05/pre-hijacking-attacks" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-us/msrc/blog/2022/05/pre-hijacking-attacks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenID Connect Core 1.0: section 2 (&lt;code&gt;sub&lt;/code&gt;), section 5.1 (&lt;code&gt;email_verified&lt;/code&gt;), section 5.7 (claim stability and uniqueness). &lt;a href="https://openid.net/specs/openid-connect-core-1_0.html" rel="noopener noreferrer"&gt;https://openid.net/specs/openid-connect-core-1_0.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>authentication</category>
      <category>testing</category>
    </item>
    <item>
      <title>Check-Then-Update Is a Race: Three Fixes for Coupon and Balance Limits, Tested on 20 Parallel Requests</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Tue, 27 Oct 2026 13:56:35 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/check-then-update-is-a-race-three-fixes-for-coupon-and-balance-limits-tested-on-20-parallel-4j4m</link>
      <guid>https://dev.to/ookeolioli222/check-then-update-is-a-race-three-fixes-for-coupon-and-balance-limits-tested-on-20-parallel-4j4m</guid>
      <description>&lt;p&gt;"This coupon can be used once" is a business rule, and a common way to implement it has the same shape everywhere: read the current state, decide, then write the new state. Each of the three steps is correct. The rule can still be broken, because requests do not arrive one at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern, as PortSwigger describes it
&lt;/h2&gt;

&lt;p&gt;The Web Security Academy page on race conditions defines them as problems that arise "when websites process requests concurrently without adequate safeguards", and calls the time in which a collision can happen the race window. Its best-known type is the limit overrun, illustrated with a discount code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The application checks whether the code has already been used.&lt;/li&gt;
&lt;li&gt;It applies the discount to the order total.&lt;/li&gt;
&lt;li&gt;It records in the database that the code has been used.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If one user submits the code twice almost simultaneously, both requests can pass the first check before the third step runs. In James Kettle's 2023 research "Smashing the state machine: the true potential of web race conditions", the short-lived state a request passes through is called a sub-state, and the central claim is that "with race conditions, everything is multi-step". The same research reports that such windows are often around a millisecond, and that network jitter had historically hidden them, which is why a rule that "has never been broken in production" is weak evidence that it holds.&lt;/p&gt;

&lt;h2&gt;
  
  
  A measurable demonstration
&lt;/h2&gt;

&lt;p&gt;The example below uses Node.js with the built-in &lt;code&gt;node:sqlite&lt;/code&gt; module (it prints an experimental-feature warning on Node.js 24) and a coupon that has exactly one use left. The pause in the middle stands in for the database round trip and the other work a real handler does between the check and the write.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DatabaseSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:sqlite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DatabaseSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:memory:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`CREATE TABLE coupons (code TEXT PRIMARY KEY, uses_left INTEGER NOT NULL);
         CREATE TABLE redemptions (code TEXT, user_id TEXT, PRIMARY KEY (code, user_id));
         INSERT INTO coupons VALUES ('WELCOME10', 1);`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;roundTrip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setImmediate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Version 1: check, then update.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;redeemNaive&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SELECT uses_left FROM coupons WHERE code = ?&lt;/span&gt;&lt;span class="dl"&gt;'&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WELCOME10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uses_left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;roundTrip&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UPDATE coupons SET uses_left = uses_left - 1 WHERE code = ?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WELCOME10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Version 2: one conditional statement; the result says who won.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;redeemAtomic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;roundTrip&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UPDATE coupons SET uses_left = uses_left - 1 WHERE code = ? AND uses_left &amp;gt; 0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WELCOME10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Version 3: "once per user" enforced by a key, not by an earlier SELECT.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;redeemOncePerUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;roundTrip&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INSERT OR IGNORE INTO redemptions (code, user_id) VALUES (?, ?)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WELCOME10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Twenty parallel calls to each version, starting from one remaining use, gave:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Parallel requests&lt;/th&gt;
&lt;th&gt;Granted&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;uses_left&lt;/code&gt; afterwards&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Check, then update&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-19&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1. Same code, with &lt;code&gt;CHECK (uses_left &amp;gt;= 0)&lt;/code&gt; on the column&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Conditional &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;changes === 1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Primary key &lt;code&gt;(code, user_id)&lt;/code&gt;, same user&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;not involved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Primary key, 20 different users&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;not involved&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things stand out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The unprotected version grants all twenty.&lt;/strong&gt; Every request saw one use left, because every read happened before any write.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A constraint turns the same code into a safe one, but by accident.&lt;/strong&gt; With a &lt;code&gt;CHECK&lt;/code&gt; on the column, nineteen of the updates fail with a constraint error (the test counts those as refusals) and the result looks right. PortSwigger lists datastore integrity features such as uniqueness constraints among its recommendations, as defense in depth. A backstop is valuable; the rule should still be expressed in the statement itself, so that losing a race is an expected result and not an exception.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The last two rows are different rules.&lt;/strong&gt; The primary key limits one user to one redemption; it says nothing about how many uses the coupon has in total. A real service needs both, in one transaction, so that a rejected second step undoes the first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The example does not use multiple connections or threads: the interleaving comes from &lt;code&gt;await&lt;/code&gt;, which is enough to show the logic but not the behaviour of a particular database engine under load. That needs a test against the real database.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the database does with the conditional statement
&lt;/h2&gt;

&lt;p&gt;Version 2 works because the check and the write are the same operation. How concurrent updates to the same row are resolved depends on the isolation level. The PostgreSQL documentation describes it for the default Read Committed level: a second updater "will wait for the first updating transaction to commit or roll back", and if the first one commits, the second re-evaluates the &lt;code&gt;WHERE&lt;/code&gt; clause against the new row version. In the example, the second request therefore finds &lt;code&gt;uses_left &amp;gt; 0&lt;/code&gt; false and changes nothing.&lt;/p&gt;

&lt;p&gt;At Repeatable Read the second transaction is rolled back with &lt;code&gt;could not serialize access due to concurrent update&lt;/code&gt;, and the documentation says applications using this level "must be prepared to retry transactions due to serialization failures". Serializable can fail for read/write dependencies as well; such failures return SQLSTATE &lt;code&gt;40001&lt;/code&gt;. In short: moving the rule into one statement is the first step, and the retry policy is the second.&lt;/p&gt;

&lt;h2&gt;
  
  
  PortSwigger's prevention guidance, in one list
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep sensitive endpoints' state changes atomic, using the datastore's own concurrency features.&lt;/li&gt;
&lt;li&gt;Avoid mixing data from different storage places, and do not use one storage layer to protect another.&lt;/li&gt;
&lt;li&gt;Use integrity features such as uniqueness constraints as defense in depth.&lt;/li&gt;
&lt;li&gt;Be careful with session handling: updating session variables one at a time can open a window, and ORMs can hide transactions.&lt;/li&gt;
&lt;li&gt;Do not assume per-session locking protects you. The page notes that PHP's native session handler processes one request per session at a time, which can hide a vulnerability that appears when requests use different sessions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A test list for your own service
&lt;/h2&gt;

&lt;p&gt;Each row is a burst of simultaneous requests an authorised tester sends to their own staging environment, with the expected result.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Burst&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A single-use coupon&lt;/td&gt;
&lt;td&gt;20 simultaneous redemptions of the same code&lt;/td&gt;
&lt;td&gt;Exactly 1 success; the rest get a clear "already used" response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A balance of 100&lt;/td&gt;
&lt;td&gt;10 simultaneous withdrawals of 50&lt;/td&gt;
&lt;td&gt;At most 2 succeed; the balance never goes negative&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One referral bonus per account&lt;/td&gt;
&lt;td&gt;Simultaneous claims by the same account&lt;/td&gt;
&lt;td&gt;1 bonus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A limit that depends on a counter&lt;/td&gt;
&lt;td&gt;Simultaneous requests at the limit&lt;/td&gt;
&lt;td&gt;Never more than the limit, counted from the database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The same burst, each request on a different session&lt;/td&gt;
&lt;td&gt;Same as above&lt;/td&gt;
&lt;td&gt;Same result as with one session&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Count outcomes in the database afterwards, not only in the HTTP responses: a response can say "failed" while a partial write is left behind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practise the review
&lt;/h2&gt;

&lt;p&gt;Breachloom has a chapter, &lt;a href="https://breachloom.com/learn/race-coupon/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=check-then-update-race" rel="noopener noreferrer"&gt;One remaining coupon use must have one winner&lt;/a&gt;, with a hands-on exercise, &lt;a href="https://breachloom.com/ctf/race-coupon/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=check-then-update-race" rel="noopener noreferrer"&gt;Concurrent coupon redemption&lt;/a&gt;, and a matching pair for balances, &lt;a href="https://breachloom.com/learn/race-withdraw/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=check-then-update-race" rel="noopener noreferrer"&gt;Parallel withdrawals must share one view of spendable funds&lt;/a&gt; and &lt;a href="https://breachloom.com/ctf/race-withdraw/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=check-then-update-race" rel="noopener noreferrer"&gt;Concurrent withdrawal simulation&lt;/a&gt;. For limits at the API layer, &lt;a href="https://breachloom.com/blog/api-rate-limits-business-abuse/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=check-then-update-race" rel="noopener noreferrer"&gt;API Rate Limits Are Not a Complete Defence Against Business Abuse&lt;/a&gt; covers why a rate limit and a business-rule limit are different controls. The chapters and the free IDOR case need no account; the full set of challenges is part of a paid plan.&lt;/p&gt;

&lt;p&gt;Which rule in your own service starts with a &lt;code&gt;SELECT&lt;/code&gt; and ends with an &lt;code&gt;UPDATE&lt;/code&gt;? Writing a 20-request burst for that one rule takes minutes, and its result is more convincing than a code review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PortSwigger Web Security Academy, "Race conditions" (definition, limit overrun, session-based locking, "How to prevent race condition vulnerabilities"). &lt;a href="https://portswigger.net/web-security/race-conditions" rel="noopener noreferrer"&gt;https://portswigger.net/web-security/race-conditions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;James Kettle, "Smashing the state machine: the true potential of web race conditions", PortSwigger Research, 9 August 2023. &lt;a href="https://portswigger.net/research/smashing-the-state-machine" rel="noopener noreferrer"&gt;https://portswigger.net/research/smashing-the-state-machine&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;PostgreSQL documentation, "Transaction Isolation": Read Committed (13.2.1), Repeatable Read (13.2.2), Serializable (13.2.3). &lt;a href="https://www.postgresql.org/docs/current/transaction-iso.html" rel="noopener noreferrer"&gt;https://www.postgresql.org/docs/current/transaction-iso.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Node.js documentation, &lt;code&gt;node:sqlite&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>database</category>
      <category>testing</category>
    </item>
    <item>
      <title>Content Security Policy Reporting: Two Silent CSP Blocks Nobody Noticed</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Tue, 27 Oct 2026 11:47:03 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/content-security-policy-reporting-two-silent-csp-blocks-nobody-noticed-ofj</link>
      <guid>https://dev.to/ookeolioli222/content-security-policy-reporting-two-silent-csp-blocks-nobody-noticed-ofj</guid>
      <description>&lt;p&gt;A Content Security Policy (CSP) is a response header that tells the browser which scripts, styles, frames and connections a page may use. Anything outside the list is blocked. That is the point of CSP, and it is also its quietest failure mode: when a strict policy blocks something you &lt;em&gt;wanted&lt;/em&gt;, the only trace is a line in the visitor's DevTools console. Your server sees nothing.&lt;/p&gt;

&lt;p&gt;Breachloom, a browser-based web security training site, runs a strict policy: &lt;code&gt;script-src 'self'&lt;/code&gt; plus three named hosts, no inline scripts, no &lt;code&gt;'unsafe-inline'&lt;/code&gt;, no &lt;code&gt;'unsafe-eval'&lt;/code&gt;. Two things broke behind that policy, and both went unnoticed until violation reporting was switched on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Silent block #1: the analytics beacon that never loaded
&lt;/h2&gt;

&lt;p&gt;Cloudflare Web Analytics injects its beacon script into every HTML page served through Cloudflare. The beacon is loaded from &lt;code&gt;static.cloudflareinsights.com&lt;/code&gt; and reports to &lt;code&gt;cloudflareinsights.com&lt;/code&gt;. Neither host was in &lt;code&gt;script-src&lt;/code&gt; or &lt;code&gt;connect-src&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Result: on every page view the browser blocked the beacon, logged a CSP error in the console and sent nothing. The analytics dashboard simply showed no data, which looks exactly like "no visitors" rather than "broken".&lt;/p&gt;

&lt;p&gt;The fix was two allow-list entries, kept as narrow as possible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;script-src 'self' https://static.cloudflareinsights.com ...
connect-src 'self' https://cloudflareinsights.com ...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lesson is not about Cloudflare. Any platform feature that injects a script (analytics, bot protection, a chat widget) is a new script source. If your policy is strict, the feature arrives already broken, and it fails silently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Silent block #2: a redirect that swapped the policy
&lt;/h2&gt;

&lt;p&gt;The site has an intentionally vulnerable page for its cross-site scripting exercises. That page must run a reflected payload, so it gets its own, separate policy: &lt;code&gt;script-src 'unsafe-inline'&lt;/code&gt;, but also &lt;code&gt;sandbox allow-scripts&lt;/code&gt;, &lt;code&gt;connect-src 'none'&lt;/code&gt;, &lt;code&gt;form-action 'none'&lt;/code&gt; and &lt;code&gt;default-src 'none'&lt;/code&gt;. The sandbox gives the document an opaque (&lt;code&gt;null&lt;/code&gt;) origin, so a payload that runs there cannot read the site's cookies or storage, or call its API.&lt;/p&gt;

&lt;p&gt;The special policy was attached by matching the path &lt;code&gt;/ctf/xss-victim.html&lt;/code&gt;. On production, Cloudflare Pages normalises clean URLs: &lt;code&gt;/ctf/xss-victim.html&lt;/code&gt; answers with a 308 redirect to &lt;code&gt;/ctf/xss-victim&lt;/code&gt;. The redirected request no longer matched, received the site-wide strict policy, and the exercise's own harness script was blocked.&lt;/p&gt;

&lt;p&gt;Locally everything worked, because the local server did not redirect. The fix was to match both forms of the path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;VICTIM_PATHS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/ctf/xss-victim&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/ctf/xss-victim.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you assign different policies by URL, test them against production URLs, after every redirect your host performs.&lt;/p&gt;

&lt;p&gt;If you want to see what that sandboxed target is for, the reflected XSS exercise uses it: &lt;a href="https://breachloom.com/ctf/xss-reflect/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=csp-silent-blocks" rel="noopener noreferrer"&gt;Reflected XSS lab&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making CSP violations visible
&lt;/h2&gt;

&lt;p&gt;Both problems became visible once the browser was asked to report them. MDN describes the modern mechanism: the &lt;code&gt;report-to&lt;/code&gt; directive names an endpoint, and the separate &lt;code&gt;Reporting-Endpoints&lt;/code&gt; response header maps that name to a URL. Reports arrive as &lt;code&gt;POST&lt;/code&gt; requests with &lt;code&gt;Content-Type: application/reports+json&lt;/code&gt;, each with &lt;code&gt;"type": "csp-violation"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;MDN marks &lt;code&gt;report-to&lt;/code&gt; as Baseline 2026 (newly available) and notes that browsers which support it ignore the older &lt;code&gt;report-uri&lt;/code&gt;. Until support is universal, MDN's own example sends both. The headers look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Reporting-Endpoints: csp="/api/csp-report"
Content-Security-Policy: default-src 'self'; script-src 'self'; ...; report-to csp; report-uri /api/csp-report
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The collector: small on purpose
&lt;/h2&gt;

&lt;p&gt;A violation endpoint is public by design: every visitor's browser posts to it, without a session. That makes it an input like any other. The collector Breachloom runs follows a few rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Known content types only:&lt;/strong&gt; &lt;code&gt;application/csp-report&lt;/code&gt; (legacy &lt;code&gt;report-uri&lt;/code&gt;), &lt;code&gt;application/reports+json&lt;/code&gt; (Reporting API) and &lt;code&gt;application/json&lt;/code&gt;. Anything else gets &lt;code&gt;415&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bounded body:&lt;/strong&gt; at most 16 KB is read; malformed JSON is dropped silently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limit per hashed IP&lt;/strong&gt;, failing open, so a broken limiter never breaks the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allow-list of fields:&lt;/strong&gt; document, directive, blocked URI, source file, line and a short sample.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No query strings or fragments&lt;/strong&gt; in stored URIs, because they can hold session IDs, reset tokens or e-mail addresses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No database writes:&lt;/strong&gt; one structured log line per report.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always &lt;code&gt;204&lt;/code&gt;&lt;/strong&gt;, so the response never feeds back into the client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The two report formats differ: &lt;code&gt;report-uri&lt;/code&gt; sends &lt;code&gt;{"csp-report": {...}}&lt;/code&gt; with kebab-case keys, while the Reporting API sends an array of reports with camelCase keys in &lt;code&gt;body&lt;/code&gt;. One small function normalises both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;?#&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;.*$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// drop query and fragment&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e7&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;pickFields&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;document-uri&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentURL&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;directive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;effective-directive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;effectiveDirective&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
                 &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;violated-directive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;violatedDirective&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;blocked&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blocked-uri&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;blockedURL&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-file&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sourceFile&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lineNumber&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;script-sample&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A rollout checklist that would have caught both
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start with &lt;code&gt;Content-Security-Policy-Report-Only&lt;/code&gt;&lt;/strong&gt; and the same &lt;code&gt;report-to&lt;/code&gt; endpoint. Nothing is blocked; everything that &lt;em&gt;would&lt;/em&gt; be blocked is reported.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the reports grouped by directive and blocked host.&lt;/strong&gt; A third-party host you did not add yourself, such as an injected beacon, shows up here first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test policies on production URLs&lt;/strong&gt;, including redirects and trailing-slash variants, if any page gets a different policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the enforcing policy and the report endpoint together.&lt;/strong&gt; A strict policy without reporting is a silent one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat the collector as public input:&lt;/strong&gt; content type, size, rate, field allow-list, no tokens in logs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the directive-by-directive side (nonces vs hashes, &lt;code&gt;strict-dynamic&lt;/code&gt;, &lt;code&gt;frame-ancestors&lt;/code&gt;), there is a longer guide: &lt;a href="https://breachloom.com/blog/content-security-policy/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=csp-silent-blocks" rel="noopener noreferrer"&gt;Content Security Policy: header, directives, nonces and rollout&lt;/a&gt;. The fastest way to feel what CSP is defending against is to break a page yourself: the &lt;a href="https://breachloom.com/?lang=en&amp;amp;utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=csp-silent-blocks#/try" rel="noopener noreferrer"&gt;free IDOR case&lt;/a&gt; needs no account, and the XSS exercises are part of the paid catalogue.&lt;/p&gt;

&lt;p&gt;What did your first CSP report reveal: a script you forgot, a browser extension, or something injected by your own platform?&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MDN, "CSP: report-to" (Reporting-Endpoints mapping, &lt;code&gt;application/reports+json&lt;/code&gt;, &lt;code&gt;csp-violation&lt;/code&gt; type, Baseline 2026, sending &lt;code&gt;report-uri&lt;/code&gt; alongside). &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/report-to" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/report-to&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MDN, "Content-Security-Policy-Report-Only". &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy-Report-Only" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy-Report-Only&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MDN, "CSP: sandbox" (opaque origin without &lt;code&gt;allow-same-origin&lt;/code&gt;). &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/sandbox" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/sandbox&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>OWASP A10:2025 Mishandling of Exceptional Conditions: Three Failures, Tested</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Mon, 26 Oct 2026 08:38:58 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/owasp-a102025-mishandling-of-exceptional-conditions-three-failures-tested-1f3b</link>
      <guid>https://dev.to/ookeolioli222/owasp-a102025-mishandling-of-exceptional-conditions-three-failures-tested-1f3b</guid>
      <description>&lt;p&gt;The OWASP Top 10:2025 added a category that most teams will recognise from their own code: A10, Mishandling of Exceptional Conditions. It covers what happens when something goes wrong: a dependency is down, a value is missing, a step in the middle of a transaction fails. The risk is not the failure itself but what the application does next.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the category says
&lt;/h2&gt;

&lt;p&gt;OWASP describes A10 as a new category covering improper error handling, logical errors and failing open. Its description says programs "fail to prevent, detect, and respond to unusual and unpredictable situations", which can lead to crashes, unexpected behavior and vulnerabilities.&lt;/p&gt;

&lt;p&gt;The page maps 24 CWEs to it. A few of them read like code-review findings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CWE-636, Not Failing Securely ('Failing Open')&lt;/li&gt;
&lt;li&gt;CWE-209, Generation of Error Message Containing Sensitive Information&lt;/li&gt;
&lt;li&gt;CWE-390, Detection of Error Condition Without Action&lt;/li&gt;
&lt;li&gt;CWE-396, Declaration of Catch for Generic Exception&lt;/li&gt;
&lt;li&gt;CWE-252, Unchecked Return Value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The data table lists a maximum incidence rate of 20.67% and an average of 2.95%, with 769,581 occurrences and 3,416 CVEs across the mapped CWEs. Its prevention guidance, paraphrased, is: handle errors where they occur, keep a global exception handler as a safety net, fail closed, and when a multi-step transaction fails partway "roll back every part of the transaction and start again".&lt;/p&gt;

&lt;p&gt;The three examples below turn three of those sentences into code that can be run.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The check that fails open
&lt;/h2&gt;

&lt;p&gt;Authorization usually depends on something that can fail: a policy engine, a database, a remote API. The first version catches the error, logs it, and carries on with a permissive default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;guardFailOpen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                                   &lt;span class="c1"&gt;// permissive default&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;permissionService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;canRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;docId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;permission check failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;// logged, then ignored&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;allowed&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second version makes the decision explicit. Any error, and any answer that is not exactly &lt;code&gt;true&lt;/code&gt;, is a denial:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;guardFailClosed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;permissionService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;canRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;docId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;permission check failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;503&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;temporarily unavailable&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;            &lt;span class="c1"&gt;// not a grant&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run for a user who has no access to the document (&lt;code&gt;bob&lt;/code&gt; asking for &lt;code&gt;doc-1&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Policy service&lt;/th&gt;
&lt;th&gt;Fail-open guard&lt;/th&gt;
&lt;th&gt;Fail-closed guard&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Up&lt;/td&gt;
&lt;td&gt;403&lt;/td&gt;
&lt;td&gt;403&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Down&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;200&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;503&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;While the dependency is healthy, both versions behave the same, so a normal test suite passes. The difference only exists during the failure. The error was logged in both versions, which is the point of CWE-390: noticing an error condition without acting on it is not handling it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The transfer that fails halfway
&lt;/h2&gt;

&lt;p&gt;OWASP's third example scenario is an interrupted multi-step transfer: debit, credit, log. Three statements, with the third failing (here, an audit insert that violates a &lt;code&gt;NOT NULL&lt;/code&gt; constraint):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Version 1: three statements, no transaction&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;transferNaive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;breakAudit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;UPDATE accounts SET balance = balance - ? WHERE id='A'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;UPDATE accounts SET balance = balance + ? WHERE id='B'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INSERT INTO audit (entry) VALUES (?)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;breakAudit&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`A-&amp;gt;B &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Version 2: one transaction; any error rolls every part back&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;transferAtomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;breakAudit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BEGIN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;UPDATE accounts SET balance = balance - ? WHERE id='A'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;UPDATE accounts SET balance = balance + ? WHERE id='B'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INSERT INTO audit (entry) VALUES (?)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;breakAudit&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`A-&amp;gt;B &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;COMMIT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ROLLBACK&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;State before: account A has 100, B has 0, the audit table is empty. After a transfer of 40 where the audit step fails:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;A&lt;/th&gt;
&lt;th&gt;B&lt;/th&gt;
&lt;th&gt;Audit rows&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Naive&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Money moved, nothing recorded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atomic&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Nothing changed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Both versions raise the same error. Only one of them leaves a consistent system behind. In the naive version, a retry by the caller would debit the account a second time.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The error message that explains too much
&lt;/h2&gt;

&lt;p&gt;CWE-209 and OWASP's second scenario describe database errors that reveal system details, which an attacker can use as reconnaissance. A handler that returns the exception's stack to the client does exactly that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleLeaky&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stack&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleSafe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;          &lt;span class="c1"&gt;// details stay on the server&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Something went wrong. Reference: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a simulated database error, the leaky handler returned a four-line body that began &lt;code&gt;Error: SQLITE_ERROR: no such column: users.pw_hash at /srv/app/db/orders.js:88&lt;/code&gt;: a table, a column name and a file path. The safe handler returned &lt;code&gt;Something went wrong. Reference: e074ed12-…&lt;/code&gt;, and the same identifier appears in the server log, so a support request can still be traced.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the three have in common
&lt;/h2&gt;

&lt;p&gt;Each failure was handled in the sense that no exception escaped. The defect was in the decision made after the failure: a permissive default, a half-applied state, a verbose reply. That is why none of them is found by a test where everything works. They need a test where something breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  A test list for your own service
&lt;/h2&gt;

&lt;p&gt;Each row is something an authorised tester arranges in an environment they own, with the expected result.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Arrange&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Make the authorization or policy dependency unreachable, then request a protected resource as a user without access&lt;/td&gt;
&lt;td&gt;Denied (or unavailable), never granted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Make the dependency return garbage (null, an empty object, a timeout)&lt;/td&gt;
&lt;td&gt;Denied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fail the last step of a multi-step operation&lt;/td&gt;
&lt;td&gt;No partial state; a retry does not repeat completed steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Send a request with a missing required parameter and with an extra parameter&lt;/td&gt;
&lt;td&gt;4xx with a generic message, no stack, path or query text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Force an internal error&lt;/td&gt;
&lt;td&gt;A generic body with a reference id; the detail is only in the server log&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Repeat the same failing request many times&lt;/td&gt;
&lt;td&gt;Rate limited or summarised in logs, without exhausting resources&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;OWASP's first scenario is the last row's concern: an upload handler that catches an exception but does not release its resources, so repeated failures exhaust them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practise the review
&lt;/h2&gt;

&lt;p&gt;Breachloom has an exercise on the information-disclosure side, &lt;a href="https://breachloom.com/ctf/sqli-search-error/" rel="noopener noreferrer"&gt;SQL error disclosure in search&lt;/a&gt;, with a matching chapter, &lt;a href="https://breachloom.com/learn/sqli-search-error/" rel="noopener noreferrer"&gt;A database error message is a disclosure channel of its own&lt;/a&gt;. For the half-applied state, there is a fix-the-code mission, &lt;a href="https://breachloom.com/codeops/atomic-coupon/" rel="noopener noreferrer"&gt;Atomic Coupon&lt;/a&gt;, where the repair must pass a regression test, and a general article, &lt;a href="https://breachloom.com/blog/secure-coding-exercises/" rel="noopener noreferrer"&gt;Secure Coding Exercises: Verify the Fix, Not Just the Attack&lt;/a&gt;. The chapters and the free IDOR case need no account; the full set of challenges is part of a paid plan.&lt;/p&gt;

&lt;p&gt;Which dependency of your own service, if it went down right now, would turn a check into a pass? Answering that by switching it off in a test environment is faster than reading the code for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OWASP Top 10:2025, A10:2025 Mishandling of Exceptional Conditions (description, mapped CWEs, score table, prevention, example attack scenarios). &lt;a href="https://top10.owasp.org/2025/A10_2025-Mishandling_of_Exceptional_Conditions/" rel="noopener noreferrer"&gt;https://top10.owasp.org/2025/A10_2025-Mishandling_of_Exceptional_Conditions/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OWASP Top 10:2025 category list. &lt;a href="https://top10.owasp.org/2025" rel="noopener noreferrer"&gt;https://top10.owasp.org/2025&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MITRE CWE entries 209, 252, 390, 396 and 636. &lt;a href="https://cwe.mitre.org/" rel="noopener noreferrer"&gt;https://cwe.mitre.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Node.js documentation: &lt;code&gt;node:sqlite&lt;/code&gt;, &lt;code&gt;node:crypto&lt;/code&gt; (&lt;code&gt;randomUUID&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>testing</category>
      <category>discuss</category>
    </item>
    <item>
      <title>An AI Agent's fetch(url) Tool Is an SSRF Surface: Controls That Do Not Rely on the Model</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Sat, 24 Oct 2026 10:25:03 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/an-ai-agents-fetchurl-tool-is-an-ssrf-surface-controls-that-do-not-rely-on-the-model-26eb</link>
      <guid>https://dev.to/ookeolioli222/an-ai-agents-fetchurl-tool-is-an-ssrf-surface-controls-that-do-not-rely-on-the-model-26eb</guid>
      <description>&lt;p&gt;A tool that takes a URL and returns the page is one of the most common additions to an AI agent. It is also a server-side request whose destination is chosen by a model, and the model reads content that someone else wrote: web pages, support tickets, documents, e-mail. When that content says "fetch this address next", the request leaves from the server's network position, not from the author's.&lt;/p&gt;

&lt;p&gt;The question for a review is not "can the model be made to behave". It is "what can this tool reach if it is asked to reach anything".&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the risk is classified
&lt;/h2&gt;

&lt;p&gt;The OWASP Top 10 for LLM Applications (2025) describes this as LLM06:2025 Excessive Agency, with three root causes: excessive functionality (the system exposes tools it does not need), excessive permissions (the tool can touch more than its task requires) and excessive autonomy (high-impact actions happen without independent approval). Among its prevention measures: avoid open-ended tools in favour of narrow, purpose-built ones, grant downstream access only at the level needed, and enforce authorization in the downstream system rather than relying on the model's judgment ("complete mediation").&lt;/p&gt;

&lt;p&gt;The same page notes that logging, monitoring and rate limiting do not prevent excessive agency; they only limit the damage. The controls below are of the preventing kind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two cases, two sets of controls
&lt;/h2&gt;

&lt;p&gt;The OWASP SSRF Prevention Cheat Sheet separates two situations, and the right control set depends on which one applies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case 1: the tool only needs a few known destinations.&lt;/strong&gt; The cheat sheet's guidance is to match the host against an allow-list and build the request in code, instead of passing the model's string to an HTTP client. Most "look up this order", "read this ticket" or "call this internal API" tools belong here, and for them the best design is not a URL parameter at all but an identifier that the server turns into a request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case 2: the tool must be able to fetch arbitrary public pages.&lt;/strong&gt; The cheat sheet states that allow-lists cannot be used here because the list of destinations is not known in advance. Control then moves to the network and to what is checked at connection time. It also warns that deny-lists are bypass-prone and a last resort, and that regular expressions over complex formats are hard to maintain and error-prone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five controls for Case 2
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check the address the socket will use, not the string that was submitted.&lt;/strong&gt; The cheat sheet notes that domain allow-listing alone does not prevent DNS rebinding, and that checking DNS answers separately does not either. The check has to happen on the resolved address at connection time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not follow redirects automatically.&lt;/strong&gt; The cheat sheet recommends disabling redirect-following in the web client. If redirects are needed, each hop is a new request that goes through every check again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Block non-routable ranges at the network layer too.&lt;/strong&gt; Application checks can have gaps (one is described below). Egress rules for the process that runs the tool are the second layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make the cloud metadata service hard to reach.&lt;/strong&gt; On AWS, IMDSv2 uses session tokens obtained with a &lt;code&gt;PUT&lt;/code&gt; request; a &lt;code&gt;PUT&lt;/code&gt; carrying an &lt;code&gt;X-Forwarded-For&lt;/code&gt; header is rejected, and the response hop limit defaults to 1. The instance can be configured to accept only IMDSv2, which makes IMDSv1 calls fail. The OWASP cheat sheet's advice is to migrate to IMDSv2 and disable IMDSv1. AWS describes the design goal in the title of its security blog post: "Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give the tool the smallest possible identity.&lt;/strong&gt; Run it as a separate process with no cloud role, no internal network route and no credentials in its environment, so that a successful request has nothing valuable to return.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A guard in Node.js, and the gap found while testing it
&lt;/h2&gt;

&lt;p&gt;The following uses only built-in modules. The check lives in a custom &lt;code&gt;lookup&lt;/code&gt; function, so it runs on the address the connection will use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;dns&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:dns&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;https&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:https&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;net&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:net&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Address ranges a public fetch tool must never reach.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blocked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BlockList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0.0.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10.0.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;100.64.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;169.254.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;172.16.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;192.168.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;]])&lt;/span&gt; &lt;span class="nx"&gt;blocked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ipv4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;::1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fc00::&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fe80::&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;::&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;]])&lt;/span&gt; &lt;span class="nx"&gt;blocked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ipv6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;guardedLookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;dns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;blocked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;family&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ipv6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ipv4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`blocked address &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;all&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;family&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchPublic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rawUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;allowedHosts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rawUrl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https only&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;allowedHosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;host not on the allow-list&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// Node does not call `lookup` for an IP literal, so the guard above would not run for one.&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isIP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\[&lt;/span&gt;&lt;span class="sr"&gt;|&lt;/span&gt;&lt;span class="se"&gt;\]&lt;/span&gt;&lt;span class="sr"&gt;$/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;IP literals are not accepted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;https&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="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;guardedLookup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resume&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redirect not followed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;_000_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;destroy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;response too large&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;end&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;timeout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;destroy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;timeout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
    &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The line about IP literals is there because of a gap in the first version of this example. In the first test run, a request to an address given as a literal IP reached a local test server, while the same request by hostname was rejected: the custom &lt;code&gt;lookup&lt;/code&gt; is never called when the host is already an address. After the fix, every notation that the URL parser normalises to an IP (&lt;code&gt;127.1&lt;/code&gt;, &lt;code&gt;0x7f000001&lt;/code&gt;, &lt;code&gt;2130706433&lt;/code&gt;, &lt;code&gt;[::1]&lt;/code&gt;) is rejected by the same line. The practical lesson: a guard has to be tested with the inputs it is meant to stop, not only with the input it was designed around.&lt;/p&gt;

&lt;p&gt;Two limits are worth stating. A response size cap and a timeout are included because an open fetch tool is also a way to make the server spend resources. And the example does not make the open-fetch case safe on its own; the other four controls, and the model not being the only thing standing between a page and an internal service, still apply.&lt;/p&gt;

&lt;h3&gt;
  
  
  What was tested
&lt;/h3&gt;

&lt;p&gt;The code above was run against a local HTTP server and a stubbed client before publication:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the address ranges: loopback, private, link-local, carrier-grade NAT and unique-local ranges were blocked, and two public addresses were not&lt;/li&gt;
&lt;li&gt;a hostname that resolves to loopback (&lt;code&gt;localhost&lt;/code&gt;) was rejected at connection time&lt;/li&gt;
&lt;li&gt;IP literals in several notations were rejected&lt;/li&gt;
&lt;li&gt;a non-HTTPS URL and a host outside the allow-list were rejected&lt;/li&gt;
&lt;li&gt;a 3xx response was refused (tested with a stubbed client, so the redirect rule is checked in isolation)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not tested: a real DNS-rebinding setup, an IPv6-only network, and behaviour behind a corporate proxy. Those need to be checked in the environment where the tool runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  A test list for your own agent
&lt;/h2&gt;

&lt;p&gt;Each row is a request an authorised tester makes through the agent's own fetch tool, in an environment they own, with the expected result.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;The tool is asked to fetch&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A normal public page on an allowed host&lt;/td&gt;
&lt;td&gt;Content returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A loopback address&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A private-network address&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The cloud metadata address&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A hostname that resolves to a private address&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An address in a non-standard notation&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A public URL that answers with a redirect&lt;/td&gt;
&lt;td&gt;Redirect not followed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A plain &lt;code&gt;http://&lt;/code&gt; URL&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A very large response&lt;/td&gt;
&lt;td&gt;Truncated or rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If any row returns content, the tool can reach more than its description says, whatever the system prompt says.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practise the review
&lt;/h2&gt;

&lt;p&gt;Breachloom has a chapter that frames the problem from the agent's side, &lt;a href="https://breachloom.com/learn/llm-agency-ssrf/" rel="noopener noreferrer"&gt;A fetch tool lends the assistant the server's network position&lt;/a&gt;, a hands-on exercise, &lt;a href="https://breachloom.com/ctf/llm-agency-ssrf/" rel="noopener noreferrer"&gt;Agent metadata fetch&lt;/a&gt;, and a general SSRF checklist, &lt;a href="https://breachloom.com/blog/ssrf-explained/" rel="noopener noreferrer"&gt;SSRF Explained&lt;/a&gt;. For the authorization side of agent tools, there is &lt;a href="https://breachloom.com/blog/ai-agent-tool-authorization/" rel="noopener noreferrer"&gt;AI Agent Security: A Safer Prompt Cannot Replace Tool Authorization&lt;/a&gt;. The chapters and the free IDOR case need no account; the full set of challenges is part of a paid plan.&lt;/p&gt;

&lt;p&gt;Which tool in your own agent takes a URL, and what network can its process reach today? Answering that from the deployment, not from the code, is usually the quickest way to find out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OWASP Top 10 for LLM Applications 2025, LLM06:2025 Excessive Agency. &lt;a href="https://genai.owasp.org/llmrisk/llm062025-excessive-agency/" rel="noopener noreferrer"&gt;https://genai.owasp.org/llmrisk/llm062025-excessive-agency/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OWASP Server-Side Request Forgery Prevention Cheat Sheet (sections: Cases, Application layer, Case 2, IMDSv2 in AWS, Deny-list). &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html" rel="noopener noreferrer"&gt;https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS documentation, "Use the Instance Metadata Service to access instance metadata" (IMDSv2 session tokens, &lt;code&gt;PUT&lt;/code&gt; with &lt;code&gt;X-Forwarded-For&lt;/code&gt; rejected, default hop limit of 1, IMDSv2-only option). &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS Security Blog, "Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service". &lt;a href="https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/" rel="noopener noreferrer"&gt;https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Node.js documentation: &lt;code&gt;net.BlockList&lt;/code&gt;, &lt;code&gt;dns.lookup&lt;/code&gt;, and the &lt;code&gt;lookup&lt;/code&gt; option of &lt;code&gt;https.request&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>The JWT Validation Algorithm in RFC 7519 Never Checks Expiry. Seven Checks Your Code Has To Add</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Sat, 24 Oct 2026 06:33:25 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/the-jwt-validation-algorithm-in-rfc-7519-never-checks-expiry-seven-checks-your-code-has-to-add-fml</link>
      <guid>https://dev.to/ookeolioli222/the-jwt-validation-algorithm-in-rfc-7519-never-checks-expiry-seven-checks-your-code-has-to-add-fml</guid>
      <description>&lt;p&gt;"The library validates the JWT" can mean very different things. The specification that defines the format describes a validation procedure that covers structure and signature, and then stops. Everything that makes a token &lt;em&gt;acceptable here, right now, for this purpose&lt;/em&gt; is left to the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the spec's validation steps do not include
&lt;/h2&gt;

&lt;p&gt;RFC 7519, section 7.2 ("Validating a JWT") lists ten steps: check the token has the right shape, decode the header, confirm it is valid JSON, work out whether it is signed or encrypted, validate it under those rules, and decode the claims. If a step fails, the token is rejected.&lt;/p&gt;

&lt;p&gt;Missing from that list: &lt;code&gt;exp&lt;/code&gt;, &lt;code&gt;nbf&lt;/code&gt; and &lt;code&gt;aud&lt;/code&gt;. Section 4 states that which claims are required is "context dependent" and outside the scope of the specification. The claim definitions do contain processing rules (an expired token must be rejected, a token whose audience does not include the recipient must be rejected), but nothing forces a verification call to apply them unless the application or its library configuration does.&lt;/p&gt;

&lt;p&gt;The result is a gap between two sentences that sound identical: "the signature is valid" and "this token should be accepted".&lt;/p&gt;

&lt;h2&gt;
  
  
  Seven checks, and where they come from
&lt;/h2&gt;

&lt;p&gt;RFC 8725 (BCP 225, February 2020, "JSON Web Token Best Current Practices") turns the known failure modes into concrete rules. The list below maps each one to its source.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Pin the accepted algorithms in the application. Libraries must let the caller specify a supported set; the token's own header is not the source of truth.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;If any cryptographic operation fails, reject the whole token.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Validate the issuer and make sure the key belongs to that issuer.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Validate the audience. A token for another service must be rejected.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.9, RFC 7519 §4.1.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Enforce &lt;code&gt;exp&lt;/code&gt; and &lt;code&gt;nbf&lt;/code&gt;, with at most a small clock leeway.&lt;/td&gt;
&lt;td&gt;RFC 7519 §4.1.4, §4.1.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Use explicit typing, and keep validation rules for different kinds of JWT mutually exclusive, so an ID token cannot be replayed as an access token.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.11, §3.12, §2.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Treat claim values as untrusted input when they reach a query or another interpreter.&lt;/td&gt;
&lt;td&gt;RFC 8725 §3.10&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On leeway, RFC 7519 allows "some small leeway" for clock skew and describes it as usually no more than a few minutes. A leeway of an hour quietly turns a 15-minute access token into a 75-minute one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this looks like in code
&lt;/h2&gt;

&lt;p&gt;With the &lt;code&gt;jose&lt;/code&gt; library for Node.js, each of those checks is an explicit option on the verify call. Their documented meanings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;algorithms&lt;/code&gt;: accepted &lt;code&gt;alg&lt;/code&gt; header values&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;issuer&lt;/code&gt; and &lt;code&gt;audience&lt;/code&gt;: expected &lt;code&gt;iss&lt;/code&gt; and &lt;code&gt;aud&lt;/code&gt; values, and the claim must be present&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;typ&lt;/code&gt;: expected &lt;code&gt;typ&lt;/code&gt; header value, and the header must be present&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;clockTolerance&lt;/code&gt;: clock skew tolerance&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;requiredClaims&lt;/code&gt;: additional claims that must exist in the token&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;maxTokenAge&lt;/code&gt;: maximum time since &lt;code&gt;iat&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;jwtVerify&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;importSPKI&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;importSPKI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;JWT_PUBLIC_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;RS256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;readAccessToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;jwtVerify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;algorithms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;RS256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;        &lt;span class="c1"&gt;// chosen by the server, not by the token&lt;/span&gt;
    &lt;span class="na"&gt;issuer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://auth.example.test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orders-api&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;typ&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;at+jwt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                &lt;span class="c1"&gt;// access tokens only (RFC 9068 profile)&lt;/span&gt;
    &lt;span class="na"&gt;clockTolerance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;30s&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// seconds, not hours&lt;/span&gt;
    &lt;span class="na"&gt;requiredClaims&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;exp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sub&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// a token with no expiry is a policy decision&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A token without an &lt;code&gt;exp&lt;/code&gt; claim has nothing to expire. Requiring the claim, as above, makes that a rejection instead of an accident.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check the RFC does not cover: ending a session
&lt;/h2&gt;

&lt;p&gt;RFC 7519 does not define revocation or logout. The nearest feature is the &lt;code&gt;jti&lt;/code&gt; claim, which can help detect replay of a token, but it is not a revocation mechanism. A signed token stays valid until &lt;code&gt;exp&lt;/code&gt;, whatever happens to the account.&lt;/p&gt;

&lt;p&gt;That makes the lifetime a design choice, not a detail:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;keep access tokens short enough that waiting for expiry is acceptable&lt;/li&gt;
&lt;li&gt;when "log out everywhere" or "password changed" has to take effect sooner, check a server-side record (a session version, or a deny list keyed by &lt;code&gt;jti&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;if refresh tokens exist, rotate them and test replay of an old one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last point has its own test plan: &lt;a href="https://breachloom.com/blog/refresh-token-rotation/" rel="noopener noreferrer"&gt;refresh token rotation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A test list that fits in one afternoon
&lt;/h2&gt;

&lt;p&gt;Each row is a request an authorised tester sends to their own service, with the expected result.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Token presented&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Valid token&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same token after its &lt;code&gt;exp&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token minted for a different audience&lt;/td&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token from a different issuer&lt;/td&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token signed with a key the service does not trust&lt;/td&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An ID token sent where an access token is required&lt;/td&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Valid token after "log out everywhere"&lt;/td&gt;
&lt;td&gt;401 within the stated window&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If one of these returns 200, the verification call is configured to check less than the team believes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practise the review, not just the exploit
&lt;/h2&gt;

&lt;p&gt;Reading a token and verifying who wrote it are different operations, and the difference is easy to miss in code review. Breachloom has a short chapter on it, &lt;a href="https://breachloom.com/learn/jwt-no-verify/" rel="noopener noreferrer"&gt;Reading a token is not verifying who wrote it&lt;/a&gt;, a hands-on exercise, &lt;a href="https://breachloom.com/ctf/jwt-no-verify/" rel="noopener noreferrer"&gt;Decoding without verification&lt;/a&gt;, and a fix-the-code mission, &lt;a href="https://breachloom.com/codeops/jwt-verify/" rel="noopener noreferrer"&gt;Verify First&lt;/a&gt;, where the repaired function has to pass a regression test, not just look right. The chapters and the free IDOR case need no account; the full set of challenges is part of a paid plan.&lt;/p&gt;

&lt;p&gt;Which of the seven checks does your own service verify with a test, rather than by reading the configuration? That is usually the one worth writing down first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RFC 7519, JSON Web Token (JWT): sections 4.1.1, 4.1.3, 4.1.4, 4.1.5, 4.1.7 and 7.2. &lt;a href="https://www.rfc-editor.org/rfc/rfc7519" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc7519&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RFC 8725 (BCP 225), JSON Web Token Best Current Practices, February 2020: sections 2.8, 3.1, 3.3, 3.8, 3.9, 3.10, 3.11, 3.12. &lt;a href="https://www.rfc-editor.org/rfc/rfc8725" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc8725&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RFC 9068, JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens, October 2021: section 2.1 (&lt;code&gt;typ&lt;/code&gt; of &lt;code&gt;at+jwt&lt;/code&gt;). &lt;a href="https://www.rfc-editor.org/rfc/rfc9068" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc9068&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jose&lt;/code&gt; for Node.js, &lt;code&gt;JWTVerifyOptions&lt;/code&gt; reference. &lt;a href="https://github.com/panva/jose/blob/main/docs/jwt/verify/interfaces/JWTVerifyOptions.md" rel="noopener noreferrer"&gt;https://github.com/panva/jose/blob/main/docs/jwt/verify/interfaces/JWTVerifyOptions.md&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>authentication</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Login Is Not Order Ownership: A Small Authorization Review Worksheet</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Sat, 10 Oct 2026 00:30:30 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/login-is-not-order-ownership-a-small-authorization-review-worksheet-4pjk</link>
      <guid>https://dev.to/ookeolioli222/login-is-not-order-ownership-a-small-authorization-review-worksheet-4pjk</guid>
      <description>&lt;p&gt;A successful login tells an application who is making a request. It does not, by itself, decide whether that person should see a particular order.&lt;/p&gt;

&lt;p&gt;That distinction is easy to agree with in a design meeting—and easy to lose when a feature is implemented. Here is a small review worksheet for an order-history feature, using fictional customers and no real customer data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a product rule
&lt;/h2&gt;

&lt;p&gt;Write one sentence before discussing routes or database queries:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A customer may read their own orders. Any support access requires a separate, explicitly approved permission.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is an illustrative rule, not a universal policy. Shared business accounts, delegated buyers and support teams may need different rules. The important part is to make those exceptions explicit instead of silently treating every signed-in account as equivalent.&lt;/p&gt;

&lt;p&gt;Authentication and authorization are separate decisions. OWASP recommends checking permissions on every request and denying access when no permission applies. Its &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html" rel="noopener noreferrer"&gt;Authorization Cheat Sheet&lt;/a&gt; is a useful reference for those principles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the expected decisions visible
&lt;/h2&gt;

&lt;p&gt;For the fictional feature above, a reviewer can use this table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Expected decision&lt;/th&gt;
&lt;th&gt;Evidence to retain&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Customer reads their own order&lt;/td&gt;
&lt;td&gt;Allow&lt;/td&gt;
&lt;td&gt;Only the intended order is returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Customer lacks permission for an order&lt;/td&gt;
&lt;td&gt;Deny&lt;/td&gt;
&lt;td&gt;No private order fields are returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No authenticated session for private history&lt;/td&gt;
&lt;td&gt;Deny&lt;/td&gt;
&lt;td&gt;No private history is returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Support account has the required permission&lt;/td&gt;
&lt;td&gt;Allow within its scope&lt;/td&gt;
&lt;td&gt;The reason for access is recorded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Support permission has been removed&lt;/td&gt;
&lt;td&gt;Deny&lt;/td&gt;
&lt;td&gt;A previous permission does not keep granting access&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are proposed acceptance criteria, not results from a test run. An implementation needs its own automated checks and evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three questions for the pull request
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Where does the identity come from?&lt;/strong&gt; The application should derive the acting user from its verified server-side authentication context. A customer-supplied owner field is input, not proof of ownership.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where is the permission decision enforced?&lt;/strong&gt; A hidden button is a user-interface choice. The service returning private data still needs to make the access decision. Review the place where the data becomes available to the caller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when the decision cannot be made?&lt;/strong&gt; A missing permission record or policy-service error should not silently turn into permission. Define a safe failure behavior and a useful operational signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the response, not just its status
&lt;/h2&gt;

&lt;p&gt;Imagine a regression report that says “access denied” but includes the customer's shipping address in the response body. That would not meet the acceptance criteria above.&lt;/p&gt;

&lt;p&gt;For the denied cases, record whether private fields were absent. For the allowed case, record that the legitimate customer can still use order history. Both sides matter: a patch that disables the whole feature is not a successful product fix.&lt;/p&gt;

&lt;p&gt;Keep the evidence small and synthetic: the rule being checked, the expected decision, the observed decision and the application version. Avoid putting real customer records into test reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turn the worksheet into a team habit
&lt;/h2&gt;

&lt;p&gt;Add the decision table to the feature review, give each row an owner and keep the resulting regression checks alongside the implementation. When support access or account sharing changes later, update the rule and the table together.&lt;/p&gt;

&lt;p&gt;The useful question is not only “does this endpoint require login?” It is “what permits this person to perform this action on this record?”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Product disclosure:&lt;/strong&gt; This post is from Breachloom. If you prefer an interactive introduction, our &lt;a href="https://breachloom.com/?lang=en&amp;amp;utm_source=devto&amp;amp;utm_medium=organic_social&amp;amp;utm_campaign=idor_oct2026#/try" rel="noopener noreferrer"&gt;browser-based security training&lt;/a&gt; includes an IDOR demo built around a fictional invoice-access scenario.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI assistance was used to draft and edit this post. The worksheet is illustrative; no executed test results are claimed.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>testing</category>
    </item>
    <item>
      <title>Prompt injection isn't a payload problem — 3 questions decide if your AI feature is exploitable</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Wed, 07 Oct 2026 22:57:00 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/prompt-injection-isnt-a-payload-problem-3-questions-decide-if-your-ai-feature-is-exploitable-33kd</link>
      <guid>https://dev.to/ookeolioli222/prompt-injection-isnt-a-payload-problem-3-questions-decide-if-your-ai-feature-is-exploitable-33kd</guid>
      <description>&lt;p&gt;Prompt injection gets talked about as if it were a clever string you type to jailbreak a chatbot. That framing misses the actual problem, and it is why so many "fixes" do not work.&lt;/p&gt;

&lt;p&gt;The real issue is structural. An LLM feature puts two different things into one text stream: the instructions the application intends, and the data it processes. The model has no reliable way to tell an order it should follow from text it should merely process. That is the same root condition as SQL injection or command injection — instructions and data sharing a channel — except there is currently no complete escaping that makes natural-language data safe to concatenate with instructions.&lt;/p&gt;

&lt;p&gt;So the question is not "what payload breaks it." The question is whether a hostile instruction, hidden in data the model reads, can reach something that matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lethal trifecta
&lt;/h2&gt;

&lt;p&gt;Simon Willison's framing is the most useful lens. An AI feature becomes dangerous when it combines three things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;access to private data,&lt;/li&gt;
&lt;li&gt;exposure to untrusted content, and&lt;/li&gt;
&lt;li&gt;a way to communicate externally.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Any one of the three is survivable. All three together mean an attacker can plant an instruction in the untrusted content, have the model read private data, and have it sent out. Guardrails that catch 95% of phrasings do not save you, because the attacker only needs one that gets through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three questions for any AI feature
&lt;/h2&gt;

&lt;p&gt;Instead of hunting for magic strings, map the feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Where does untrusted text enter the prompt?&lt;/strong&gt;&lt;br&gt;
Not just the user's message. Any retrieved document, web page, file, tool result, or earlier message the model reads is a potential injection point. A support bot summarising a ticket, an agent browsing a linked page, a RAG assistant quoting a document, an assistant reading an inbox — all ingest text written by someone else. This is &lt;em&gt;indirect&lt;/em&gt; prompt injection, and it is usually the higher-severity case, because the hostile instruction does not come from the person using the feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. What can the model actually do as a result?&lt;/strong&gt;&lt;br&gt;
A model that only writes a summary back to the same user can be misled, but the blast radius is that user's session. A model wired to tools — sending email, calling internal APIs, reading files, making purchases — can be steered into real actions. Severity is decided by the model's privileges, not the cleverness of the phrasing. Write down every tool it can call and whose authority it runs with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Can a hostile instruction reach a real action or a real exfiltration?&lt;/strong&gt;&lt;br&gt;
This is where the trifecta closes. The classic example is data exfiltration through a markdown image: a hidden instruction tells the assistant to encode something it can read — a recent message, a token — into the URL of an image, which the client then fetches automatically, sending the data to the attacker's server. No script execution required.&lt;/p&gt;

&lt;p&gt;If the answer to all three is yes, you have an exploitable feature, not a curiosity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why filtering the input does not fix it
&lt;/h2&gt;

&lt;p&gt;The instinct is to scan the input for "ignore previous instructions" and block it. It does not hold. Injections hide in Base64, emoji, other languages, text split across documents, or even inside images for a multimodal model. An instruction need not be human-readable to work. Blocklisting natural language is an unwinnable game.&lt;/p&gt;

&lt;p&gt;This is not theoretical. Prompt injection has been demonstrated against production AI features at Microsoft 365 Copilot, Slack AI, and GitLab Duo, among others — real systems wired to real data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually helps
&lt;/h2&gt;

&lt;p&gt;Because the input cannot be fully sanitised, the durable controls sit around the model, not inside the prompt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Least privilege for tools.&lt;/strong&gt; Give an agent only the functions a task needs, scoped to the current user, and prefer read-only. High-consequence actions — sending messages, moving money, changing settings — should require an explicit human confirmation that shows what will happen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat the model's output as untrusted.&lt;/strong&gt; If the response is rendered as HTML, it can carry stored XSS; if it is passed to a shell or a database, it carries that injection class. Encode output for its destination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A deterministic check the model cannot talk past.&lt;/strong&gt; Authorization enforced outside the model is what keeps an injected instruction from becoming an injected action.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolate and label retrieved content,&lt;/strong&gt; limit how much untrusted text enters the context, and log tool calls so abuse is visible afterward. The "dual LLM" pattern — a quarantined model handles untrusted data, a privileged model never sees it — is worth reading about.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these "solve" injection. Together they shrink what a followed instruction can reach, which is the realistic goal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test it like a feature, not a vibe
&lt;/h2&gt;

&lt;p&gt;Open-source tools like Garak and Promptfoo probe for injection and unsafe output handling, and a guardrail classifier can sit in front as one more layer — never the only one. But the most useful test is the one you write for your own feature: place a benign marker in the kind of content the feature consumes, and see whether it comes back in the output. If it does, the data channel reached the instruction channel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try the mechanics hands-on
&lt;/h2&gt;

&lt;p&gt;Reading about it only goes so far. These run in the browser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Indirect injection from page content: &lt;a href="https://breachloom.com/ctf/llm-pi-indirect/" rel="noopener noreferrer"&gt;https://breachloom.com/ctf/llm-pi-indirect/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;An agent that can send email, steered by injected text: &lt;a href="https://breachloom.com/ctf/llm-agency-email/" rel="noopener noreferrer"&gt;https://breachloom.com/ctf/llm-agency-email/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A poisoned MCP tool description: &lt;a href="https://breachloom.com/ctf/mcp-poison/" rel="noopener noreferrer"&gt;https://breachloom.com/ctf/mcp-poison/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The full chain, page → tools → disclosure: &lt;a href="https://breachloom.com/chains/ai-agent-pwn/" rel="noopener noreferrer"&gt;https://breachloom.com/chains/ai-agent-pwn/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OWASP GenAI — LLM01:2025 Prompt Injection: &lt;a href="https://genai.owasp.org/llmrisk/llm01-prompt-injection/" rel="noopener noreferrer"&gt;https://genai.owasp.org/llmrisk/llm01-prompt-injection/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Simon Willison — The lethal trifecta: &lt;a href="https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/" rel="noopener noreferrer"&gt;https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;What is the trickiest indirect-injection vector you have seen in a real feature?&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>The Password Reset Email Was Real. The Destination Wasn't.</title>
      <dc:creator>NET_DARK_BOI</dc:creator>
      <pubDate>Tue, 29 Sep 2026 20:34:44 +0000</pubDate>
      <link>https://dev.to/ookeolioli222/the-password-reset-email-was-real-the-destination-wasnt-568a</link>
      <guid>https://dev.to/ookeolioli222/the-password-reset-email-was-real-the-destination-wasnt-568a</guid>
      <description>&lt;p&gt;The application sends the password-reset email. Its own template. Its own delivery system.&lt;/p&gt;

&lt;p&gt;The link carries a genuine reset token.&lt;/p&gt;

&lt;p&gt;But the destination belongs to someone else.&lt;/p&gt;

&lt;p&gt;That is the unsettling part of password-reset poisoning: the application can assemble and deliver the dangerous message itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check was there. It never got its turn.
&lt;/h2&gt;

&lt;p&gt;Coolify's advisory describes a chain involving trusted forwarded headers, a host-validation cache bug, and a reset URL derived from the request. On an empty cache, validation was skipped; the code that would populate that cache sat behind the skipped path.&lt;/p&gt;

&lt;p&gt;The reported attack required the forged header to reach the application and the recipient to click the link. It was not an automatic compromise of every deployment.&lt;/p&gt;

&lt;p&gt;The advisory credits bugbunny.ai and lists &lt;code&gt;v4.0.0-beta.471&lt;/code&gt; as patched. This is an analysis of that disclosure, not a claim of discovering or reproducing the Coolify vulnerability. &lt;a href="https://github.com/coollabsio/coolify/security/advisories/GHSA-cgj8-7m5q-x5gv" rel="noopener noreferrer"&gt;Read the original advisory&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before looking at the fix, choose the destination
&lt;/h2&gt;

&lt;p&gt;Here is a separate, deliberately small JavaScript model. All domains and tokens are placeholders. It sends no requests or emails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;buildLink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/reset-password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;token&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;vulnerable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x-forwarded-host&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;buildLink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now supply these inputs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app.example&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x-forwarded-host&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;collector.example&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The token is &lt;code&gt;DEMO_ONLY&lt;/code&gt;. Which server receives it if someone follows the resulting URL?&lt;/p&gt;

&lt;p&gt;The answer comes from the first line inside &lt;code&gt;vulnerable&lt;/code&gt;. The forwarded value wins. The resulting link is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://collector.example/reset-password?token=DEMO_ONLY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how little is wrong with this URL as a string. It parses. It uses HTTPS. It has the expected path. The token is correctly encoded.&lt;/p&gt;

&lt;p&gt;The mistake happened before any of those checks could help: request metadata was allowed to choose the destination for a credential.&lt;/p&gt;

&lt;h2&gt;
  
  
  The obvious repair leaves a second question
&lt;/h2&gt;

&lt;p&gt;Suppose you delete support for &lt;code&gt;x-forwarded-host&lt;/code&gt; and use only &lt;code&gt;headers.host&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In this model, the caller still controls &lt;code&gt;headers.host&lt;/code&gt;. You have removed one route to the wrong destination while leaving another.&lt;/p&gt;

&lt;p&gt;For this single-origin example, the repaired function takes its origin from deployment configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;APP_ORIGIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://app.example&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;repaired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;buildLink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;APP_ORIGIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This matches the principle in OWASP's reset-password guidance: do not derive reset destinations from an untrusted Host header; use a fixed destination or validate against trusted domains. &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP guidance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The constant here represents configuration controlled by the operator. It must not be another name for user input. A product supporting multiple customer domains needs an explicit, verified mapping rather than this single-origin shortcut.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the local experiment actually showed
&lt;/h2&gt;

&lt;p&gt;The offline model was run on Node.js 24.18.0. It produced these results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Original destination&lt;/th&gt;
&lt;th&gt;Repaired destination&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ordinary host&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.example&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.example&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forged forwarded host&lt;/td&gt;
&lt;td&gt;&lt;code&gt;collector.example&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.example&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forged Host&lt;/td&gt;
&lt;td&gt;&lt;code&gt;collector.example&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.example&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Twelve assertions passed. They checked the repaired origin, path and token across the three cases, confirmed the two vulnerable destinations, and checked a token containing reserved characters.&lt;/p&gt;

&lt;p&gt;Those results establish the behavior of these small functions. They do not establish how a deployed proxy rewrites headers, whether a framework rejects the request, or whether a complete reset flow is secure.&lt;/p&gt;

&lt;p&gt;My next integration test would inspect the link in a captured email after a request travels through the application's actual proxy stack. I would repeat it with a cold cache. That is a proposed next test, not a result reported here.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question I would bring to a code review
&lt;/h2&gt;

&lt;p&gt;When a test says “reset email sent,” what exactly did it verify?&lt;/p&gt;

&lt;p&gt;Delivery is one assertion. The destination is another. A test can prove the first while completely missing the second.&lt;/p&gt;

&lt;p&gt;I would ask the reviewer to trace the origin backwards: from the email template, through the URL builder, to whichever input selected it. That turns a vague question about whether the flow looks secure into a specific question about who controls one consequential value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; I am building &lt;a href="https://breachloom.com/?lang=en&amp;amp;utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=reset_destination" rel="noopener noreferrer"&gt;Breachloom&lt;/a&gt;, a browser-based security practice platform. If you want to practice investigating failures and repairing vulnerable code, start with its free exercise. If that format suits you, consider PRO for continued practice. This article's model is a standalone example, not a claim that the Coolify case is available as a Breachloom mission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does your password-reset test assert about the actual link in the email?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>debugging</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
