Skip to content
Business logic Audit finding Intermediate

User can accidentally burn their iPT tokens during redemption

The redeem function burns a user's iPT tokens even when the holdings mapping is empty, so the user receives zero underlying tokens. A user who calls this function before the other redeem function (which burns external PT tokens) will lose their iPT tokens without compensation.

Jeiwan Follow

Originally disclosed on Sherlock

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

Found by

Jeiwan

Summary

User can accidentally burn their iPT tokens during redemption

Vulnerability Detail

The redeem function that redeems iPT tokens burns iPT tokens even when the holdings mapping is empty and the redeemed amount is 0 (Redeemer.sol#L403-L434).

Impact

A user can accidentally call the redeem function after maturity but before the other redeem function is called (the one that burns external PT tokens–they have identical names). User's iPT tokens will be burned and no underlying tokens will be sent in exchange.

Code Snippet

Redeemer.sol#L403:

Solidity
function redeem(address u, uint256 m) external unpaused(u, m) {
    // Get Illuminate's principal token for this market
    IERC5095 token = IERC5095(
        IMarketPlace(marketPlace).token(
            u,
            m,
            uint8(MarketPlace.Principals.Illuminate)
        )
    );

    // Verify the token has matured
    if (block.timestamp < token.maturity()) {
        revert Exception(7, block.timestamp, m, address(0), address(0));
    }

    // Get the amount of tokens to be redeemed from the sender
    uint256 amount = token.balanceOf(msg.sender);

    // Calculate how many tokens the user should receive
    uint256 redeemed = (amount * holdings[u][m]) / token.totalSupply();

    // Update holdings of underlying
    holdings[u][m] = holdings[u][m] - redeemed;

    // Burn the user's principal tokens
    // @audit burns iPT tokens even if  the holdings mapping is empty
    token.authBurn(msg.sender, amount);

    // Transfer the original underlying token back to the user
    Safe.transfer(IERC20(u), msg.sender, redeemed);

    emit Redeem(0, u, m, redeemed, msg.sender);
}

Tool used

Manual Review

Recommendation

Consider disallowing calling the second redeem function (the one that redeems iPT tokens) before the first redeem function (the one that redeems external PT tokens) is called.

Discussion

sourabhmarathe

Input validation is not within the scope of the audit. We expect to use other resources to ensure that users are executing the redemptions properly outside of the smart contract.

JTraversa

Duplicate of #239

Evert0x

Not a duplicate of #239 but of #81

The original report as published on Sherlock, by Jeiwan. 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

Likely the redeem function lacks a check to ensure that the holdings mapping is not empty before burning the user's iPT tokens.

What the attacker needed

User has iPT tokens; user calls redeem before external PT redeem

The fix

The second redeem function (which redeems iPT tokens) should be disallowed from being called before the first redeem function (which redeems external PT tokens) is called.

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 is a smart contract bug where a function that is supposed to exchange tokens for underlying assets instead destroys the user's tokens without giving anything back. The problem happens because the function does not check whether there are any underlying tokens available to redeem before burning the user's tokens.

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 Jeiwan

View all

69 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.