Skip to content
Business logic Audit finding Intermediate

Lender#lend for Sense has mismatched decimals

The Lender#lend function for Sense principal tokens assumes the decimals of the Sense principal token match the decimals of the ERC5095 vault, but they differ (e.g., USDC Sense token has 8 decimals while the vault has 6). An attacker can exploit this to mint roughly 100 times more vault shares than intended, stealing yield from other users.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-illuminate-judging/issues/164

Found by

0x52

Summary

The decimals of the Sense principal token don't match the decimals of the ERC5095 vault it mints shares to. This can be abused on the USDC market to mint a large number of shares to steal yield from all other users.

Vulnerability Detail

    uint256 received;
    {
        // Get the starting balance of the principal token
        uint256 starting = token.balanceOf(address(this));

        // Swap those tokens for the principal tokens
        ISensePeriphery(x).swapUnderlyingForPTs(adapter, s, lent, r);

        // Calculate number of principal tokens received in the swap
        received = token.balanceOf(address(this)) - starting;

        // Verify that we received the principal tokens
        if (received < r) {
            revert Exception(11, 0, 0, address(0), address(0));
        }
    }

    // Mint the Illuminate tokens based on the returned amount
    IERC5095(principalToken(u, m)).authMint(msg.sender, received);

Sense principal tokens for DIA and USDC are 8 decimals to match the decimals of the underlying cTokens, cUSDC and cDAI. The decimals of the ERC5095 vault matches the underlying of the vault. This creates a disparity in decimals that aren't adjusted for in Lender#lend for Sense, which assumes that the vault and Sense principal tokens match in decimals. In the example of USDC the ERC5095 will be 6 decimals but the sense token will be 8 decimals. Each 1e6 USDC token will result in ~1e8 Sense tokens being received. Since the contract mints based on the difference in the number of sense tokens before and after the call, it will mint ~100x the number of vault shares than it should. Since the final yield is distributed pro-rata to the number of shares, the user who minted with sense will be entitled to much more yield than they should be and everyone else will get substantially less.

Impact

User can mint large number of shares to steal funds from other users

Code Snippet

Lender.sol#L693-L741

Tool used

Manual Review

Recommendation

Query the decimals of the Sense principal and use that to adjust the decimals to match the decimals of the vault.

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract does not adjust for the difference in decimals between the Sense principal token and the ERC5095 vault, assuming they are the same.

Impact

A user can mint a large number of shares and steal yield from other users.

What the attacker needed

Access to the vulnerable lend function; USDC market with Sense principal token

The fix

The contract should query the decimals of the Sense principal token and adjust the amount to match the vault's decimals before minting shares.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This bug is about mismatched decimal places between two types of tokens. When the contract calculates how many shares to give you, it uses the wrong number of decimal places, so you get far more shares than you should. Those extra shares let you take a larger portion of the yield that belongs to everyone else.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0x52

View all

211 more disclosed reports, best first.

More from Illuminate Round 2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.