<?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>Obsidian Audits</title>
        <link>https://paragraph.com/@obsidian-audits</link>
        <description>undefined</description>
        <lastBuildDate>Sat, 28 Nov 2026 23:34:04 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Obsidian Audits</title>
            <url>https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/c2bf6321b03b56dfb7add400746d44b6d94ac299f3b96d2b656367411ee7c3d9.jpg</url>
            <link>https://paragraph.com/@obsidian-audits</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[The Exponential Inflation Bug Hiding In Fraxlend]]></title>
            <link>https://paragraph.com/@obsidian-audits/the-exponential-inflation-bug-hiding-in-fraxlend</link>
            <guid>dj0pGsqbod9tLyqTx1FI</guid>
            <pubDate>Thu, 26 Jun 2025 14:21:26 GMT</pubDate>
            <description><![CDATA[Fraxlend is a lending platform that provides lending markets between a pair of assets. Each pair is an isolated market which allows anyone to lend and borrow tokens. Lenders deposit assets into the pair and receive yield-bearing fTokens. Last November we found a high severity vulnerability in the protocol that would allow an attacker to completely steal a deposit to an empty pool.BackgroundFrom a lender&apos;s perspective, the protocol functions as an ERC-4626 vault. They can deposit assets t...]]></description>
            <content:encoded><![CDATA[<p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.frax.finance/fraxlend/available-pairs">Fraxlend</a> is a lending platform that provides lending markets between a pair of assets. Each pair is an isolated market which allows anyone to lend and borrow tokens. Lenders deposit assets into the pair and receive yield-bearing fTokens.</p><p>Last November we found a high severity vulnerability in the protocol that would allow an attacker to completely steal a deposit to an empty pool.</p><h2 id="h-background" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Background</h2><p>From a lender&apos;s perspective, the protocol functions as an ERC-4626 vault. They can deposit assets to mint fTokens (shares), that can be burned to redeem the corresponding underlying assets.</p><p>The contract <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/FraxFinance/fraxlend/blob/3314bd6ee3c1cbe03349c5e5f700d181d7dba407/src/contracts/FraxlendPairCore.sol#L118">tracks</a> the total assets and fTokens supply in the <code>VaultAccount</code> struct, where <code>amount</code> represents the total assets and <code>shares</code> represents the fTokens supply.</p><pre data-type="codeBlock" text="VaultAccount public totalAsset;

struct VaultAccount {
    uint128 amount; 
    uint128 shares; 
}
"><code>VaultAccount <span class="hljs-keyword">public</span> totalAsset;

<span class="hljs-keyword">struct</span> <span class="hljs-title">VaultAccount</span> {
    <span class="hljs-keyword">uint128</span> amount; 
    <span class="hljs-keyword">uint128</span> shares; 
}
</code></pre><p>The following is a simplified version of how the contract calculates how many fTokens to mint a user for their deposit amount. (<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/FraxFinance/fraxlend/blob/3314bd6ee3c1cbe03349c5e5f700d181d7dba407/src/contracts/libraries/VaultAccount.sol#L15-L25">Here</a> is a link to the original)</p><pre data-type="codeBlock" text="function toShares(VaultAccount memory total, uint256 amount) internal pure returns (uint256 shares) {
    shares = (amount * total.shares) / total.amount;
}
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">toShares</span>(<span class="hljs-params">VaultAccount <span class="hljs-keyword">memory</span> total, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> shares</span>) </span>{
    shares <span class="hljs-operator">=</span> (amount <span class="hljs-operator">*</span> total.shares) <span class="hljs-operator">/</span> total.amount;
}
</code></pre><p>Assuming there is only one existing share (<code>total.shares=1</code>), we can see that if the <code>total.amount</code> (total assets deposited) is larger than the deposit <code>amount</code>, the number of <code>shares</code> minted to a user will round down to zero.</p><p>This would allow an attacker to steal a user’s deposit, if they can sufficiently increase <code>total.amount</code> while keeping <code>total.shares</code> equal to 1 wei.</p><p>Now onto the hard part, actually inflating this share ratio (<code>total.amount</code> : <code>total.shares</code>).</p><h2 id="h-inflating-the-share-price" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Inflating the share price</h2><p>Lets try and apply the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://solidity-by-example.org/hacks/vault-inflation/">classic inflation attack</a> which in this case would involve minting a single wei of fTokens, then directly transferring assets to the pair contract to inflate the total assets value.</p><p>if only it was that simple...</p><p>The classic attack will not work because the contract doesn’t track total assets using <code>asset.balanceOf(address(this))</code>. Instead, it tracks the total assets through the <code>VaultAccount</code> struct, which is only updated by the deposited/withdrawn amount during calls to deposit/withdraw. This means that simply transferring assets into the contract won&apos;t have an effect on the <code>total.amount</code> field.</p><p>This method of tracking total assets internally is actually a common recommendation from security firms, as a means of preventing inflation attacks, since they do indeed prevent the classic inflation attack.</p><h2 id="h-the-vulnerability" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The vulnerability</h2><p>To inflate the share value, we need to somehow increase the value of <code>total.amount</code> without increasing <code>total.supply</code>.</p><p>Since we can’t do this by simply transferring tokens in, we have to find another way.</p><p>What if we could exploit the rounding direction upon deposits?</p><p>When depositing assets, the contract rounds down the number of shares to mint to the user (in favour of the protocol). While this is the correct rounding direction (the alternative would allow minting of free shares), this technically causes a minor degree of vault inflation upon every deposit- because the increase in <code>total.supply</code> will be truncated, while the increase in <code>total.assets</code> is not.</p><p>For example, consider the following initial state:</p><ul><li><p>total.shares = 1</p></li><li><p>total.amount = 2</p></li></ul><p>If we deposit 1 token, the <code>toShares</code> function will return 0 shares (floor(1 * 1 / 2)). The new state is:</p><ul><li><p>total.shares = 1</p></li><li><p>total.amount = 3</p></li></ul><p>We’ve technically inflated the share value, because <code>total.amount</code> has increased while <code>total.shares</code> remains unchanged. While the magnitude of it may seem insignificant (this inflation can only steal a deposit of less than 3 wei), let’s repeat the process and see what happens:</p><p>We can now deposit 2 tokens, and <code>toShares</code> will still return 0 shares. The new state is:</p><ul><li><p>total.shares = 1</p></li><li><p>total.amount = 5</p></li></ul><p>Now we can deposit 4 tokens, and <code>toShares</code> will still return 0 shares. The new state is:</p><ul><li><p>total.shares = 1</p></li><li><p>total.amount = 9</p></li></ul><p>Now we can deposit 8 tokens, and <code>toShares</code> will still return 0 shares. The new state is:</p><ul><li><p>total.shares = 1</p></li><li><p>total.amount = 17</p></li></ul><p>Notice something? Each deposit allows us to increase the deposit size exponentially following a $$2^n$$ pattern, where $$n$$ is the number of deposits. This means the deposit size doubles with each successive deposit, inflating the share value very significantly after a few iterations. This inflation method is referred to as a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.euler.finance/blog/exchange-rate-manipulation-in-erc4626-vaults">stealth donation</a>.</p><p>With only 40 atomic iterations, we can inflate the share value to over 1e12 which is enough to steal a 1 million USDC deposit.</p><p>With 70 iterations, we can inflate the share value to over 1e21 which is enough to steal 1000 ETH.</p><p>To calculate the number of iterations (𝑛) required to steal 𝑥 assets, we can use the formula: $$n = \log_2(x)$$. The deposit size of the $$i^{\text{th}}$$ deposit is equal to $$2^i$$</p><h3 id="h-attack-path" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Attack path</h3><p>This is what the attack path would look like:</p><ol><li><p>Attacker deposits 1 wei of assets to an empty pair to mint 1 fToken</p></li><li><p>Attacker deposits some collateral to borrow the 1 wei of assets, then repays it at least one block later, with an extra 1 wei of interest. This is all to achieve the required initial state of <code>total.shares</code> = 1 and <code>total.amount</code> = 2</p></li><li><p>Now the attacker waits patiently, observing the mempool for a victim that wants to deposit into the pair</p></li><li><p>The victim sends a transaction to deposit $$x$$ assets into the pair</p></li><li><p>The attacker frontruns the victim by performing $$n$$ deposits to inflate the share value, such that the victim gets 0 shares and essentially donated the deposit to the attacker</p></li><li><p>Now the attacker can redeem their single share, profiting the full deposit amount of the victim</p></li></ol><h2 id="h-impact" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Impact</h2><p>In the past, there had been multiple pools with initial deposits valued up to $100k USD, with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/tokentxns?a=0x8c9db7a9329f221ed1ffe56bf4bd073aa320eed9">this pool</a> as an example. Via this attack, the entire $100k could have been stolen by a malicious actor.</p><p>At the time of reporting there were 10 empty pairs that were vulnerable to the attack.</p><h2 id="h-remediation" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Remediation</h2><p>Upon confirmation of the vulnerability, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://x.com/samkazemian">@samkazemian</a> immediately mitigated it by making a small deposit to the 10 vulnerable pools, ensuring that the share value can no longer be inflated. Subsequently the <code>FraxlendPairDeployer</code> contract was <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/FraxFinance/fraxlend/commit/f1eae68d5a4a5877d379d61654a16e42d6591fe5">updated</a> to include a small initial deposit after deploying new pool, fixing the vulnerability.</p><h2 id="h-closing-thoughts" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Closing thoughts</h2><p>This was an elusive attack vector that was missed by a tier 1 audit and a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://code4rena.com/audits/2022-08-fraxlend-frax-finance-contest">Code4rena audit contest</a> with 136 participants.</p><p>At Obsidian Audits we consistently uncover vulnerabilities that others miss. If you&apos;re serious about the security of your DeFi protocol, and want it to be audited by publicly proven researchers, reach out to us <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://obsidianaudits.com">here</a>.</p>]]></content:encoded>
            <author>obsidian-audits@newsletter.paragraph.com (Obsidian Audits)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/9d33eface122382ad813ca960654e46c7b45671911e18acc22ea2525e429cc78.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>