<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Kankodu</title>
        <link>https://paragraph.com/@kankodu</link>
        <description>Independent Security Researcher</description>
        <lastBuildDate>Sun, 29 Nov 2026 04:46:46 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Kankodu</title>
            <url>https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/02f0c383ebfaa2a0c8675d2f7a4ff03b0d82e5fc0f66deab1027e75262b5b017.png</url>
            <link>https://paragraph.com/@kankodu</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Million Dollar Bugs And Where to Find Them]]></title>
            <link>https://paragraph.com/@kankodu/million-dollar-bugs-and-where-to-find-them</link>
            <guid>BeWlc1tsakH6jZ3eJEJC</guid>
            <pubDate>Sat, 22 Feb 2025 07:24:50 GMT</pubDate>
            <description><![CDATA[TLDR:)Two years ago I submitted a bug in Balancer V2 that let attackers create infinite token balances by front-running ERC20 deployments. I was paid $250k for this critical bug and it was made public recently.The Curiosity That Led to a Major DiscoveryIt all started with a simple curiosity: what happens when delegatecall is made to an address that doesn’t have any code? While I already knew the answer, I wanted to confirm it. If the call is placed using assembly, it returns success. However,...]]></description>
            <content:encoded><![CDATA[<h2 id="h-tldr" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">TLDR:)</h2><p>Two years ago I submitted a bug in Balancer V2 that let attackers create infinite token balances by front-running ERC20 deployments. I was paid $250k for this critical bug and it was made public recently.</p><h2 id="h-the-curiosity-that-led-to-a-major-discovery" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The Curiosity That Led to a Major Discovery</h2><p>It all started with a simple curiosity: what happens when <code>delegatecall</code> is made to an address that doesn’t have any code? While I already knew the answer, I wanted to confirm it. If the call is placed using assembly, it returns success. However, Solidity adds a check to ensure that the address being <code>delegatecall</code>-ed has code; if not, it fails. This additional Solidity check can lead to incorrect assumptions and potential vulnerabilities.</p><p>This reminded me of another case: when a <code>call</code> is made to an address without code, it also returns success. We use <code>call</code> frequently in helper functions to pull ERC20 tokens, mainly because some tokens don’t return a boolean on <code>transferFrom</code>.</p><h2 id="h-investigating-common-erc20-helper-libraries" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Investigating Common ERC20 Helper Libraries</h2><p>I started by checking the <code>safeTransferFrom</code> function in Solmate’s ERC20 library. It didn’t check whether the ERC20 address has code (at the time), meaning a protocol relying on a successful <code>safeTransferFrom</code> as confirmation of fund transfer could be at risk.</p><p>Next, I looked at other widely used libraries like Uniswap’s <code>SafeTransferLib</code>. It also lacks this check, but Uniswap’s core contracts don’t rely on <code>SafeTransferLib</code> alone—they verify balances after transfers. This means there was no immediate exploitability in Uniswap.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol">OpenZeppelin’s </a><code>SafeERC20</code>, however, does include <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L116">a check</a> to ensure that the ERC20 address has code before proceeding with transfers, making it safe from this specific issue.</p><h2 id="h-the-exploit-concept" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The Exploit Concept</h2><p>I was searching for a permissionless protocol where anyone could create a market or pool for any asset. The attack scenario I envisioned:</p><ol><li><p>An attacker creates a market or pool for an ERC20 that doesn’t exist yet.</p></li><li><p>The deposit function calls <code>safeTransferFrom</code> on the non-existent ERC20, which succeeds.</p></li><li><p>The protocol records that the attacker has deposited an infinite amount.</p></li><li><p>Later, when the ERC20 is actually deployed and real users deposit funds, the attacker withdraws their “phantom” balance.</p></li></ol><h2 id="h-finding-a-target-balancer" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Finding a Target: Balancer</h2><p>After considering Uniswap and Euler, I turned my attention to Balancer. It seemed like a perfect victim because all funds are pulled by the Vault contract, using <code>safeTransferFrom</code>. However, Balancer relied on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/balancer/balancer-v2-monorepo/blob/master/pkg/vault/contracts/AssetTransfersHandler.sol#L24-L25">OpenZeppelin’s </a><code>SafeERC20</code>, which should have been safe.</p><p>But then, I looked deeper. Balancer wasn’t really using the official OpenZeppelin <code>SafeERC20</code>. They had modified it slightly <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/balancer/balancer-v2-monorepo/commit/71403f66996d83fbb54ad5ad2667136f16565144#diff-d94b114e9716c62ccc0385951fa58a5d47723b30fcc14b6fe02b4094215ea2f5L35">to save gas</a>—and in doing so, they had removed the critical check ensuring the ERC20 address had code. This meant the bug was present.</p><h2 id="h-exploitation-strategy" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Exploitation Strategy</h2><p>One challenge was determining where an ERC20 would be deployed before its actual deployment. While some ERC20s are deployed deterministically (e.g., Uniswap V2 pairs, cross-chain token deployments), these make up less than 1% of tokens. However, a more viable method emerged: frontrunning token deployment transactions. If an ERC20’s deployment transaction is in the mempool, an attacker can predict its address and exploit the bug before deployment.</p><p>With this realization, I went to sleep, knowing I might have something significant but not yet fully convinced.</p><h2 id="h-crafting-the-exploit" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Crafting the Exploit</h2><p>The first attack path I explored:</p><ol><li><p>The attacker creates a Balancer pool between a future ERC20 and WETH.</p></li><li><p>They add liquidity, which gets recorded, but only need to provide WETH since the ERC20 doesn’t exist yet.</p></li><li><p>Once the ERC20 is deployed and real users add liquidity, the attacker withdraws it all.</p></li></ol><p>However, Balancer’s pool setup process includes a scaling factor dependent on token decimals, which it fetches via token’s <code>decimals()</code> function. Since the token wasn’t deployed yet, this call would fail, preventing pool creation.</p><p>After trial and error, I found a simpler way. In Balancer V2, the Vault holds funds for both pools and users. Users can deposit funds into the Vault and use them for swaps. Instead of an actual ERC20 transfer, the Vault can deduct a user’s internal balance and increase a pool’s internal balance.</p><p>The exploit:</p><ul><li><p>The attacker manipulates their internal balance using the bug.</p></li><li><p>Once real users start depositing liquidity into any pool they created, the attacker withdraws the funds.</p></li></ul><h2 id="h-reporting-and-reward-negotiation" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Reporting and Reward Negotiation</h2><p>I quickly created a proof-of-concept (PoC), and it worked. At the time, Balancer’s critical bug criteria required more than 1% of the total TVL to be at risk. Balancer had $800M TVL on Ethereum mainnet, meaning an exploit affecting $8M+ was critical.</p><p>In the worst case, if an attacker frontran every token deployed after Balancer’s Vault, they could have extracted $120M. While this was unlikely (as someone might detect an infinite balance in the Vault), there were high-volume <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://help.fjordfoundry.com/fjord-foundry-docs/for-sale-participants/token-sale-types/liquidity-bootstrapping-pools-lbps">Liquidity Bootstrapping Pools</a> (LBPs) at the time, particularly via Fjord Foundry.</p><p>LBPs allow developers to introduce new tokens by pairing them with more liquid assets, attracting traders. A perfect target for this exploit.</p><p>For example:</p><ul><li><p>The attacker frontruns a newly deployed token that gets deployed right before the start of LBP and makes their Vault balance infinite.</p></li><li><p>An LBP usually lasts a set duration (e.g., Merit Circle’s LBP lasted 14 days).</p></li><li><p>At the end of the LBP, users have swapped their ETH for the new token.</p></li><li><p>The attacker, with infinite balance, sell the tokes for all the ETH. (For Merit Circle’s LBP, it was worth $80M at the end)</p></li></ul><p>At the time, multiple high-profile LBPs were happening, and more were expected in the future.</p><p>Negotiating the reward was stressful. Since this was not a straightforward case where I could simply state how much was at risk at that moment, it was more challenging. The reward negotiations lasted for weeks. Ultimately, Balancer classified it as a critical bug and paid me $250K, even though the minimum payout for critical bugs at the time was 250 ETH ($400K).</p><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>This experience reinforced a crucial lesson: seemingly minor changes (like gas optimizations) can introduce catastrophic vulnerabilities. It also highlighted the importance of verifying security assumptions across all dependencies, even those that appear “safe” due to well-known libraries.</p><p>This Balancer bug was one of the most impactful discoveries in my journey so far, and it’s a reminder that curiosity—no matter how simple—can lead to uncovering million-dollar vulnerabilities. Here’s the disclosure post from Balancer:</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forum.balancer.fi/t/balancer-v2-token-frontrun-vulnerability-disclosure/6309">https://forum.balancer.fi/t/balancer-v2-token-frontrun-vulnerability-disclosure/6309</a></p>]]></content:encoded>
            <author>kankodu@newsletter.paragraph.com (Kankodu)</author>
        </item>
    </channel>
</rss>