Skip to content
Business logic Audit finding Intermediate

The lend function for tempus uses the wrong return value of depositAndFix

The lend function for Tempus used the first return value of depositAndFix instead of the second, which represents the number of principal tokens exchanged. This caused the contract to mint an incorrect number of Illuminate tokens to the user.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz, also found by 0x52 and datapunk

The depositAndFix function of the TempusController contract returns two uint256 data, the first is the number of shares exchanged for the underlying token, the second is the number of principalToken exchanged for the shares, the second return value should be used in the lend function for tempus.

This will cause the contract to mint an incorrect number of illuminateTokens to the user.

Proof of Concept

https://github.com/code-423n4/2022-06-illuminate/blob/92cbb0724e594ce025d6b6ed050d3548a38c264b/lender/Lender.sol#L452-L453

https://github.com/tempus-finance/tempus-protocol/blob/master/contracts/TempusController.sol#L52-L76

Recommended Mitigation Steps

interfaces.sol

interface ITempus {
    function maturityTime() external view returns (uint256);

    function yieldBearingToken() external view returns (IERC20Metadata);

    function depositAndFix(
        Any,
        Any,
        uint256,
        bool,
        uint256,
        uint256
    ) external returns (uint256, uint256);
}

Lender.sol

        (,uint256 returned) = ITempus(tempusAddr).depositAndFix(Any(x), Any(t), a - fee, true, r, d);
        returned -= illuminateToken.balanceOf(address(this));

sourabhmarathe (Illuminate) confirmed


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

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 code used the first return value of depositAndFix instead of the second, which is the correct number of principal tokens.

Impact

Users could receive an incorrect number of Illuminate tokens, potentially more or fewer than they should.

What the attacker needed

None

The fix

The code should be changed to use the second return value of depositAndFix and adjust the calculation accordingly.

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.

When a smart contract calls another contract's function, it can get multiple values back. Here, the function returns two numbers: one for shares and one for principal tokens. The code mistakenly used the first number instead of the second, so users got the wrong amount of 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 cccz

View all

104 more disclosed reports, best first.

More from Illuminate contest

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.