Skip to content
Business logic Audit finding Intermediate

Use of tokenB’s price instead of tokenA in determining account health will lead to protocol mis-accounting and insolvency

A typo in the lending protocol's code caused the wrong token price to be used when calculating a user's supply balance, leading to incorrect account health assessments. This could result in protocol insolvency because all borrows, withdrawals, transfers, and liquidations rely on this miscalculation.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev, also found by WatchPug.

Impact

In _supplyCreditUni(), the last argument of _convertTokenValues() on L674 being _priceB instead of _priceA in the calculation of supplyB is a typo (should be _priceA) and therefore miscalculates supplyB, creditB, creditUni and therefore totalAccountSupply in function accountHealth() which affects the health of account/protocol determination that is used across all borrows/withdrawals/transfers/liquidations in the protocol. This miscalculation significantly affects all calculations in protocol and could therefore cause protocol insolvency.

Proof of Concept

Tools Used

Manual Analysis

Recommended Mitigation Steps

Change the last argument of \_convertTokenValues() from \_priceB to \_priceA on L674.

talegift (Wild Credit) confirmed

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

This miscalculation could cause protocol insolvency because it affects all borrows, withdrawals, transfers, and liquidations.

What the attacker needed

None

The fix

The last argument of `_convertTokenValues()` should be changed from `_priceB` to `_priceA` on line 674.

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.

In a lending protocol, the system must correctly calculate how much each user has supplied and borrowed to decide if they are safe. Here, a simple mistake used the wrong token's price when valuing a user's supply, so the system could think users are safer or riskier than they really are. This could let people borrow too much or cause the protocol to lose money.

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 0xRajeev

View all

61 more disclosed reports, best first.

More from Wild Credit 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.