Skip to content
Business logic Audit finding Intermediate

Tempus lend method wrongly calculates amount of iPT tokens to mint

The Tempus lend method incorrectly calculates the amount of iPT tokens to mint by subtracting the contract's iPT balance from the return value of depositAndFix, which returns nothing. This causes the function to revert if the contract holds iPT, or mint zero iPT otherwise.

kenzo Follow

Originally disclosed on Code4rena

Submitted by kenzo, also found by cccz, Metatron, unforgiven, and WatchPug

The Tempus lend method calculates the amount of tokens to mint as amountReturnedFromTempus - lenderBalanceOfMetaPrincipalToken. This seems wrong as there’s no connection between the two items. Tempus has no relation to the iPT token.

Impact

Wrong amount of iPT will be minted to the user. If the Lender contract has iPT balance, the function will revert, otherwise, user will get minted 0 iPT tokes.

Proof of Concept

This is how the lend method calculates the amount of iPT tokens to mint:

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

The Tempus depositAndFix method does not return anything. Therefore this calculation will revert if illuminateToken.balanceOf(address(this)) > 0, or will return 0 if the balance is 0.

[Note: there’s another issue here where the depositAndFix sends wrong parameters - I will submit it in another issue.]

Recommended Mitigation Steps

I believe that what you intended to do is to check how many Tempus principal tokens the contract received.

So you need to check Lender’s x.tempusPool().principalShare() before and after the swap, and the delta is the amount received.

sourabhmarathe (Illuminate) confirmed


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

Impact

Users receive zero iPT tokens, or the transaction reverts if the contract already holds iPT, so lending through Tempus is broken.

What the attacker needed

None

The fix

The contract should measure the change in Tempus principal share before and after the swap to determine how many iPT tokens to mint.

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 you lend tokens through a smart contract, the contract should give you a receipt token representing your deposit. Here, the code tried to work out how many receipt tokens to give by subtracting the contract's existing balance from a value that the lending pool never actually returns, so the maths is meaningless. As a result, users either get zero receipt tokens or the transaction fails.

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 kenzo

View all

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