Skip to content
Business logic Audit finding Intermediate

Mistake while checking LTV to lender accepted LTV

The contract's LTV check in the lend function is reversed, so a lender who offers a lower accepted LTV than the borrower asks for will still have their loan executed at the borrower's higher LTV. This could strand the lender with a riskier loan than they intended.

catchup Follow

Originally disclosed on Code4rena

Submitted by catchup, also found by WatchPug, gzeon, and hyh

It comments in the \_lend() function that lender accepted conditions must be at least as good as the borrower is asking for. The line which checks the accepted LTV (lender’s LTV) against borrower asking LTV is: params.ltvBPS >= accepted.ltvBPS, This means lender should be offering a lower LTV, which must be the opposite way around. I think this may have the potential to strand the lender, if he enters a lower LTV. For example borrower asking LTV is 86%. However, lender enters his accepted LTV as 80%. lend() will execute with 86% LTV and punish the lender, whereas it should revert and acknowledge the lender that his bid is not good enough.

Proof of Concept

https://github.com/code-423n4/2022-04-abranft/blob/main/contracts/NFTPairWithOracle.sol#L316

Recommended Mitigation Steps

The condition should be changed as: params.ltvBPS <= accepted.ltvBPS,

cryptolyndon (AbraNFT) confirmed and commented:

Confirmed, and the first to note this particular issue.


The original report as published on Code4rena, by catchup. 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 comparison operator in the LTV check is reversed: it uses >= instead of <=, so it accepts a lender LTV that is lower than the borrower's asking LTV.

Impact

A lender could be forced into a loan with a higher LTV than they accepted, potentially stranding them with more risk than intended.

What the attacker needed

Lender submits a bid with lower LTV than borrower asks

The fix

The condition should be changed to use <= instead of >=, so that the lender's accepted LTV must be at least as high as the borrower's asking LTV.

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.

A smart contract is code on a blockchain that runs automatically. Here, a lender sets a maximum loan-to-value (LTV) ratio they are willing to accept, but the code compares it the wrong way, so a loan goes through even when the lender's limit is stricter than the borrower's request. This means the lender ends up in a riskier deal than they agreed to.

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 catchup

View all

1 more disclosed report, best first.

More from AbraNFT 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.