Skip to content
Access control Audit finding Intermediate

Lender is able to seize the collateral by changing the loan parameters

The lender could change the loan parameters of an active loan, including setting the loan-to-value ratio to zero. This made a check in the collateral removal function always pass, allowing the lender to seize the borrower's collateral at any time.

Ruhum Follow

Originally disclosed on Code4rena

Submitted by Ruhum, also found by IllIllI, WatchPug, BowTiedWardens, gzeon, plotchy, and scaraven

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

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

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

The lender should only be able to seize the collateral if:

  • the borrower didn’t repay in time
  • the collateral loses too much of its value

But, the lender is able to seize the collateral at any time by modifying the loan parameters.

Proof of Concept

The updateLoanParams() allows the lender to modify the parameters of an active loan in favor of the borrower. But, by setting the ltvBPS value to 0 they are able to seize the collateral.

If ltvBPS is 0 the following require statement in removeCollateral() will always be true:

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

rate * 0 / BPS < amount is always true.

That allows the lender to seize the collateral although its value didn’t decrease nor did the time to repay the loan come.

So the required steps are:

  1. lend the funds to the borrower
  2. call updateLoanParams() to set the ltvBPS value to 0
  3. call removeCollateral() to steal the collateral from the contract

Recommended Mitigation Steps

Don’t allow updateLoanParams() to change the ltvBPS value.

cryptolyndon (AbraNFT) confirmed and commented:

Confirmed, and the first to report this particular exploit.


The original report as published on Code4rena, by Ruhum. 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 function that updates loan parameters allowed the lender to set the loan-to-value ratio to zero, which made a required check in the collateral removal function always true.

Impact

The lender could seize the borrower's collateral at any time, even if the borrower repaid on time and the collateral value did not decrease.

What the attacker needed

Lender role on an active loan

The fix

The updateLoanParams() function should not be allowed to change the ltvBPS value.

How it was found

  1. Lend funds to the borrower.
  2. Call updateLoanParams() to set ltvBPS to 0.
  3. Call removeCollateral() to take the collateral.

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 contract, a borrower puts up collateral and the lender provides funds. The lender should only be able to take the collateral if the borrower fails to repay or the collateral's value drops too much. Here, the lender could change a setting to zero, which made a safety check always pass, so they could take the collateral whenever they wanted.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by Ruhum

View all

55 more disclosed reports, 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.