<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Moatasem bellah Muhammed on Medium]]></title>
        <description><![CDATA[Stories by Moatasem bellah Muhammed on Medium]]></description>
        <link>https://medium.com/@moatasem20052002?source=rss-15e10b4ec0e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CTf8EDUe3ZjaJWy6</url>
            <title>Stories by Moatasem bellah Muhammed on Medium</title>
            <link>https://medium.com/@moatasem20052002?source=rss-15e10b4ec0e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:34:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moatasem20052002/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Second Factor That Forgot to Count]]></title>
            <link>https://medium.com/@moatasem20052002/the-second-factor-that-forgot-to-count-bdfee44503e2?source=rss-15e10b4ec0e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdfee44503e2</guid>
            <dc:creator><![CDATA[Moatasem bellah Muhammed]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 06:37:48 GMT</pubDate>
            <atom:updated>2026-07-13T06:37:49.496Z</atom:updated>
            <content:encoded><![CDATA[<h3>A six-digit code rotating every 30 seconds feels unbreakable. It isn’t — if the server never counts how many times you guess.</h3><p>Multi-factor authentication sells a feeling: even with the password, an attacker is stuck at a second wall. A 6-digit code. A million possibilities. Rotating every 30 seconds. What are the odds?</p><p>Turns out the odds are entirely a function of one thing the marketing never mentions: <strong>how many guesses the server lets you make.</strong> On a production payments-and-rewards platform, the answer was <em>all of them</em>. No rate limit, no lockout, no backoff, no anomaly detection on the MFA verification endpoint. With unlimited attempts, that “million-to-one” wall comes down to arithmetic — and the arithmetic loses.</p><p>This is a writeup of brute-forcing TOTP into a full account takeover, why the math works, and the one number that actually decides whether it’s possible.</p><p>Program, hostnames, and the session-cookie name are redacted throughout.</p><h3>The setup</h3><p>The target was the MFA verification step:</p><pre>POST /v1/user_mfa_session/ HTTP/2<br>Host: api.platform.example<br>Content-Type: application/json</pre><pre>{&quot;code&quot;: &quot;000000&quot;}</pre><p>You reach this <em>after</em> a valid password — TOTP is the second factor, not the first. A correct code returns 200 and a fully authenticated session cookie. A wrong code returns an error. Simple.</p><p>One detail made it sharper. On this platform, accounts <strong>with</strong> MFA enabled skipped the email-link confirmation that non-MFA accounts went through. So for an MFA user, the TOTP code wasn’t <em>a</em> gate on top of others — it was <em>the</em> gate. Defeat it and you’re in. The very feature meant to harden the account had quietly become its single point of failure, because the thing guarding it could be guessed an unlimited number of times.</p><h3>The bug, stated plainly</h3><p>The verification endpoint had <strong>no anti-automation of any kind</strong>:</p><ul><li>No rate limiting (per-account or per-IP)</li><li>No account lockout after repeated failures</li><li>No progressive / increasing delay on wrong guesses</li><li>No detection of obviously sequential, high-frequency attempts</li><li>The current OTP was <em>not</em> invalidated after a burst of failures</li></ul><p>RFC 6238 — the TOTP spec itself — is explicit that a verifier <strong>MUST</strong> limit the number of authentication attempts. That requirement is the entire reason a 6-digit code is considered safe. Remove it, and you’ve kept the lock but thrown away the part that makes it a lock.</p><h3>Why six digits stops being enough</h3><p>Here’s where I want to correct a tempting-but-wrong way to think about this, because it’s the part people get backwards.</p><p>A 6-digit code is 000000–999999 → <strong>1,000,000</strong> possibilities. The instinct is to look for a clever trick to &quot;shrink the search space&quot; — fix the first digit, fix the first two, narrow it down. That instinct is a trap. <strong>You can&#39;t shrink the search space.</strong> The entropy lives in the <em>server&#39;s</em> secret current code, which you don&#39;t control and can&#39;t constrain. Picking which numbers you guess doesn&#39;t make the real code any more likely to be one of them.</p><p>The only lever that actually exists is <strong>throughput</strong>: how many distinct codes you can land in the server before the code rotates.</p><p>So the honest model is just a counting argument. Let:</p><ul><li>S = size of the code space = <strong>1,000,000</strong></li><li>V = number of codes valid <em>at the same instant</em></li><li>R = how many distinct guesses you can land <strong>per 30-second window</strong></li></ul><p>Then the chance of cracking it in a single window is:</p><pre>P(window) ≈ (V × R) / S</pre><p>And because the code refreshes every window — effectively a brand-new random target each time — your shots are independent. Over n windows:</p><pre>P(success) = 1 − (1 − P(window))^n</pre><p>That’s the whole thing. No prefix tricks, no probability sleight of hand. Just <em>valid codes × your throughput, over the space, repeated until it hits.</em></p><p>Notice what controls R: <strong>the absence of rate limiting.</strong> With throttling, R is small — a handful per minute — and P(window) rounds to zero. Without it, R is whatever your network can push. That single missing control is the entire vulnerability. Everything else is consequence.</p><h3>The grace period quietly doubles your odds</h3><p>TOTP intentionally tolerates clock drift by accepting more than one code at a time — typically the current step <em>and</em> the previous one. So in practice V = 2, not 1. That&#39;s not a flaw in TOTP; it&#39;s a usability necessity. But it doubles P(window) for free, and when there&#39;s no rate limiting to keep R low, &quot;free doubling&quot; is a gift to the attacker.</p><h3>Running the numbers</h3><p>Plug in the observed values. Two codes valid at once (V = 2), and with no throttling I could comfortably land ~10,000 distinct codes inside a 30-second window (R = 10,000):</p><pre>P(window) = (2 × 10,000) / 1,000,000 = 0.02   → 2% per window</pre><p>Two percent sounds tiny. Repeat it every 30 seconds and it stops being tiny:</p><p>Time Windows P(success) 10 min 20 ~33% 20 min 40 ~55% 30 min 60 ~70% 50 min 100 ~87% ~75 min 150 ~95%</p><p>A coin that lands heads 2% of the time becomes a near-certainty if you’re allowed to flip it 150 times. The server let me flip it as many times as I wanted.</p><p>The strategy follows directly: each window, fire a fixed band of 10,000 codes (say 000000–009999) and move on. There&#39;s no point chasing the target around — it&#39;s re-randomized every window anyway — so a fixed band you can iterate cleanly is as good as any. Conceptually:</p><pre>each 30s window:<br>    for code in 0 .. 9999:<br>        try f&quot;{code:06d}&quot;</pre><p>The reason this works is, again, only that nothing stops you from sending those 10,000 requests in time.</p><h3>Doing it for real</h3><p>I ran it. No throttling kicked in, no lockout, no slowdown, no challenge — the server happily processed the flood. After roughly an hour of continuous attempts, a guess landed inside the valid window and the response came back:</p><pre>HTTP/2 200<br>Set-Cookie: _platform_session=...   (redacted)</pre><p>A valid, fully authenticated session for the victim account. I stopped the moment real-world feasibility was confirmed — the point was to prove the bypass is <em>practically</em> achievable, not theoretically possible, and the 200 plus a live session cookie is that proof.</p><h3>Impact, honestly framed</h3><p>This is a complete defeat of the second factor, leading to account takeover. I want to be precise about what it does and doesn’t require, because that precision is what makes it credible:</p><ul><li><strong>Prerequisite:</strong> the attacker already has the victim’s password. TOTP is the <em>second</em> factor — this attack defeats the thing standing between a compromised password and a live session. Given the scale of credential reuse and password-dump availability, “attacker has the password” is not an exotic assumption.</li><li><strong>No victim interaction:</strong> beyond that, nothing. No phishing the code, no malware, no clicking. Pure server-side brute force.</li><li><strong>The payoff:</strong> on a platform that moves money and distributes rewards, a valid session is high-value — unauthorized transactions, payment-detail changes, and access to financial and personal data all sit behind it.</li></ul><p>The headline isn’t “MFA is broken.” It’s narrower and more damning: <em>this</em> MFA implementation reduced a million-to-one second factor to an hour of patience, because it never counted the guesses.</p><h3>Root cause</h3><p>An OTP verification endpoint is <strong>password-equivalent</strong> — getting it right grants a session — and it must be defended exactly like a login endpoint. The mistake here was treating the <em>strength of the code</em> (entropy, rotation) as the security control, when the real control is <em>enforcement</em> (counting and capping attempts). Rotation and 6-digit entropy are necessary; they are nowhere near sufficient on their own. Without enforcement, all that careful cryptographic design just sets the per-window odds, and the attacker buys the rest with time.</p><h3>Takeaways</h3><ul><li><strong>Throughput is the only lever — so throttling is the only real defense.</strong> There’s no clever entropy trick on the attacker’s side and no entropy trick on the defender’s side either. The fight is entirely over how many guesses per unit time. Win that and the math never gets a chance.</li><li><strong>Don’t dress up a counting argument as a probability hack.</strong> You can’t shrink someone else’s secret. Be honest about <em>why</em> it works: valid-codes × guesses-per-window ÷ space. Clean math survives scrutiny; clever-sounding math gets picked apart.</li><li><strong>OTP endpoints are login endpoints.</strong> If a request can hand back a session, it deserves every anti-automation control your password form has — and people routinely forget to give it any.</li><li><strong>“MFA enabled” can paradoxically narrow the attack surface.</strong> When enabling MFA removes another check (here, the email-link step), the brute-forceable factor becomes the <em>only</em> gate. Worth checking how the flows differ between MFA and non-MFA accounts.</li></ul><p>A six-digit code is only as strong as the server’s willingness to say “that’s enough.” This one never did.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHCU2eqm3KGeVIS943CMLQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdfee44503e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Proxy That Snitched on Itself]]></title>
            <link>https://medium.com/@moatasem20052002/the-proxy-that-snitched-on-itself-1964b68b1aa7?source=rss-15e10b4ec0e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1964b68b1aa7</guid>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Moatasem bellah Muhammed]]></dc:creator>
            <pubDate>Sat, 20 Jun 2026 04:55:02 GMT</pubDate>
            <atom:updated>2026-06-20T05:10:42.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>How a single echoed header turned a default merchant account into admin on an internal Apache Airflow — and handed over the keys to production.</h3><p>Some of the best bugs aren’t clever. There’s no polyglot payload, no race window measured in milliseconds, no fifteen-step gadget chain. Sometimes a service just <em>tells you the secret</em> — you only have to be paying attention when it does.</p><p>This is a writeup of one of those. A production e-commerce platform exposed an internal data-pipeline orchestrator (Apache Airflow) through a public API proxy. The proxy did its job correctly: it injected the credentials needed to reach the internal system, so the merchant’s browser never had to. The problem was that it then <strong>echoed its own outbound request back in the response</strong> — credentials included.</p><p>From a default, no-privilege store-owner account, that was enough to read the keys, walk past a Zero-Trust gateway, and authenticate as admin to an internal Airflow that ran the migration pipelines — and held the secrets — for the entire platform.</p><p>All identifying details below (program, hostnames, credentials, IDs) are redacted.</p><h3>The setup</h3><p>The platform had a “store importer” — the feature that pulls a merchant’s catalog over from another e-commerce platform (Shopify, Magento, WooCommerce, and so on) when they migrate in. That import work doesn’t happen in the web app; it’s orchestrated by <strong>Apache Airflow</strong> running on internal infrastructure.</p><p>Internal infrastructure that, sensibly, was not directly reachable. It sat behind a Cloudflare Access (Zero-Trust) gateway, and Airflow itself required HTTP Basic authentication on top of that. Two independent locks on the front door.</p><p>To let the merchant dashboard trigger and inspect migrations, the public API exposed a thin proxy:</p><pre>/admin/v2/importer/airflow/...</pre><p>A merchant request hit the public API; the API attached the two secrets needed to get through both locks — a <strong>Cloudflare Access service token</strong> to pass the gateway, and <strong>Basic credentials</strong> to satisfy Airflow — and forwarded the call to the internal host. This is a textbook <strong>deputy</strong>: the proxy holds powerful credentials and acts on behalf of a much-less-privileged caller. Done right, that’s a perfectly good pattern. The merchant never sees the secrets; they only see the result.</p><p>Done wrong, the deputy gets <em>confused</em>.</p><h3>The bug</h3><p>I sent a perfectly boring request to one of the proxy endpoints with my normal dashboard token:</p><pre>DELETE /admin/v2/importer/airflow/migrations/webhook/product/delete HTTP/2<br>Host: api.platform.example<br>Authorization: Bearer &lt;merchant-dashboard-token&gt;<br>Content-Type: application/json</pre><pre>{}</pre><p>And the response handed me this:</p><pre>{<br>  &quot;request&quot;: {<br>    &quot;source&quot;: &quot;airflow&quot;,<br>    &quot;method&quot;: &quot;DELETE&quot;,<br>    &quot;url&quot;: &quot;https://airflow.internal.platform.example/migrations/webhook/product/delete&quot;,<br>    &quot;headers&quot;: {<br>      &quot;authorization&quot;: &quot;Basic &lt;redacted&gt;&quot;,<br>      &quot;cf-access-client-id&quot;: &quot;&lt;redacted&gt;.access&quot;,<br>      &quot;cf-access-client-secret&quot;: &quot;&lt;redacted&gt;&quot;<br>    }<br>  }<br>}</pre><p>Read that again. The proxy wrapped its <strong>outbound</strong> request to the internal host in a request envelope and returned it to me — the caller. Method, full internal URL, and every header it injects. Including both secrets it uses to defeat both locks.</p><p>The authorization: Basic &lt;redacted&gt; value base64-decodes to a plain admin:&lt;password&gt; pair. The two cf-access-* values are the Cloudflare Access service token. The deputy had just shown me the contents of its own wallet.</p><p>This kind of behavior usually starts life as a debugging convenience — “echo the upstream request so we can troubleshoot the proxy.” It’s harmless in a notebook and catastrophic in production. The caller was never supposed to see anything but the <em>result</em> of the upstream call; instead they got the <em>credentials</em> for it.</p><p>A note on methodology, because this is the part that matters more than the bug: an echoed request object in a JSON response is the kind of thing it&#39;s easy to skim past. Reading the <em>whole</em> response — not just the field you came for — is where this entire chain lived.</p><h3>Proving it actually works</h3><p>Leaked-looking credentials are a <em>note</em>, not a finding. They’re worth nothing until you’ve shown they unlock something with real impact. So the goal was to demonstrate the full path end to end, and — just as important — to prove that <strong>each control fails for the reason I think it does</strong>, by isolating them one at a time.</p><p>The target was the internal Airflow admin API, /api/v1/dags. Three requests, removing one excuse at a time.</p><p><strong>Step 1 — nothing.</strong> Hit the internal host directly with no token. The Zero-Trust gate should stop me cold:</p><pre>GET /api/v1/dags HTTP/2<br>Host: airflow.internal.platform.example</pre><pre>HTTP/2 403<br>&lt;title&gt;Error ・ Cloudflare Access&lt;/title&gt;</pre><p>Good — the gateway is real and doing its job. I’m not even reaching Airflow yet.</p><p><strong>Step 2 — the Cloudflare token only.</strong> Add the leaked CF Access service token, but no Airflow credentials. This should get me <em>through the gate</em> but Airflow itself should reject me:</p><pre>GET /api/v1/dags HTTP/2<br>Host: airflow.internal.platform.example<br>CF-Access-Client-Id: &lt;redacted&gt;.access<br>CF-Access-Client-Secret: &lt;redacted&gt;</pre><pre>HTTP/2 401<br>{&quot;status&quot;:401,&quot;title&quot;:&quot;Unauthorized&quot;}</pre><p>The status changed from 403 to 401. That single digit is the whole story: I&#39;m now <em>past</em> the Zero-Trust gateway (no more Cloudflare block page), and I&#39;m being challenged by Airflow itself. The leaked service token works.</p><p><strong>Step 3 — both secrets.</strong> Add the leaked Basic credentials on top:</p><pre>GET /api/v1/dags HTTP/2<br>Host: airflow.internal.platform.example<br>CF-Access-Client-Id: &lt;redacted&gt;.access<br>CF-Access-Client-Secret: &lt;redacted&gt;<br>Authorization: Basic &lt;redacted&gt;</pre><pre>HTTP/2 200<br>{&quot;total_entries&quot;:17,&quot;dags&quot;:[{&quot;dag_id&quot;:&quot;clean_&lt;source&gt;_dag&quot;,&quot;owners&quot;:[&quot;airflow&quot;], ...}]}</pre><p>200. Authenticated. I&#39;m reading the internal migration pipelines of the platform from a default merchant account.</p><p>The 401 → 200 flip when — and only when — the Basic credentials are added is the proof that those credentials are valid and load-bearing. No hand-waving, no &quot;this <em>could</em> be exploitable.&quot; Each lock was shown to be a real lock, and each leaked key was shown to open it.</p><h3>How bad is admin on Airflow?</h3><p>Very. Two reasons.</p><p><strong>1. Airflow admin is remote code execution.</strong> Airflow’s whole purpose is to run code — DAGs are Python, and an admin can author and trigger them. Admin access to Airflow means arbitrary Python execution on the platform’s pipeline workers. Not “RCE-adjacent,” not “theoretical given the right gadget” — running tasks <em>is</em> the product.</p><p><strong>2. The admin API hands out the backend’s secrets for free.</strong> Before touching code execution, the read-only admin API already leaks the credentials Airflow stores to do its job:</p><ul><li>GET /api/v1/dags — the full set of migration pipelines, one per source platform (Shopify, Magento, WooCommerce, OpenCart, …), plus the platform&#39;s own internal migration and rerun jobs.</li><li>GET /api/v1/connections — a stored cloud-provider connection.</li><li>GET /api/v1/variables — dozens of variables holding production secrets. The <em>keys</em> alone tell the story:</li><li><strong>Production database:</strong> DB_HOST, DB_NAME, DB_USER, DB_PASSWORD, DB_PORT, DB_SSLMODE</li><li><strong>Object storage:</strong> S3_ID, S3_SECRET, S3_URL, BUCKET_NAME (plus the cloud connection above)</li><li><strong>Third-party services:</strong> AIRBYTE_CLIENT_ID/AIRBYTE_CLIENT_SECRET, analytics write keys, internal API URLs</li></ul><p>(I pulled keys and identifiers only — actual secret values stay out of the report and out of this post.)</p><p>So from one echoed header, the blast radius is: code execution on internal infrastructure → the <strong>production database</strong> → <strong>object storage</strong> → connected <strong>third-party services</strong>. And because this same Airflow runs the migration pipelines for <em>every</em> supported source platform, the cross-tenant reach extends to the migration data of every merchant moving onto the platform — over 20,000 migration records were exposed through the proxy alone.</p><p>Attacker profile, for the impact statement: a <strong>standard merchant account</strong>. Default user role, owner of a single store, no platform/staff/cross-tenant privileges. No victim interaction. No social engineering. Just read the response.</p><h3>Root cause</h3><p>It’s worth separating the two failures, because they’re different lessons.</p><p>The <strong>confused deputy</strong> isn’t the bug. Injecting credentials so a low-privilege caller can reach a high-privilege system, without ever exposing those credentials to the caller, is a legitimate and common design. The deputy is <em>supposed</em> to hold secrets the client can’t see.</p><p>The bug is that the deputy <strong>returned its own request</strong>. A debug/echo convenience leaked exactly the thing the proxy existed to keep hidden. Defense in depth made it worse in an instructive way: there were two independent locks on that internal host, and the single response leaked the keys to <em>both</em>. All the Zero-Trust architecture in the world doesn’t help when the application politely mails you the service token.</p><h3>Takeaways</h3><ul><li><strong>Read the entire response.</strong> The chain didn’t live in the field I requested — it lived in a request object I almost scrolled past. Echo/debug/diagnostic envelopes are a recurring goldmine; train yourself to notice them.</li><li><strong>Confused deputies that inject auth are worth poking.</strong> Any proxy that reaches an internal system on your behalf is holding credentials you’re not supposed to see. Ask whether it ever leaks them — in the body, in an error, in a verbose mode, in a header.</li><li><strong>Isolate every control before you claim a chain.</strong> The 403 → 401 → 200 ladder turned &quot;I think these creds are real&quot; into proof. Don&#39;t report a leaked secret; report what it <em>unlocks</em>, demonstrated end to end.</li><li><strong>Airflow admin = RCE.</strong> If you reach an orchestration platform’s admin surface, that’s not a footnote. It’s code execution plus a credential vault, almost every time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74Ojm64FKrX4LA7SjgkVgA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1964b68b1aa7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>