Skip to content
Business logic Audit finding Intermediate

Loans can be rolled an unlimited number of times

The loan roll function allows a borrower to extend the loan term an unlimited number of times without lender consent, because the lender's toggle to disable rolling cannot prevent multiple rolls in a single transaction. An attacker could roll excessively, forcing the lender to wait indefinitely or suffer losses if collateral depreciates.

0x52 Follow with enckrish, IllIllI and 17 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-cooler-judging/issues/215

Found by

0x52, enckrish, IllIllI, cducrest-brainbot, banditx0x, simon135, Allarious, Trumpero, Breeje, neumo, Atarpara, yixxas, libratus, usmannk, ali_shehab, oxcm, thekmj, HollaDieWaldfee, HonorLt, bin2chen

Summary

Loans can be rolled an unlimited number of times, without letting the lender decide if has been done too many times already

Vulnerability Detail

The lender is expected to be able to toggle whether a loan can be rolled or not, but once it's enabled, there is no way to prevent the borrower from rolling an unlimited number of times in the same transaction or in quick succession.

Impact

If the lender is giving an interest-free loan and assumes that allowing a roll will only extend the term by one, they'll potentially be forced to wait until the end of the universe if the borrower chooses to roll an excessive number of times.

If the borrower is using a quickly-depreciating collateral, the lender may be happy to allow one a one-term extension, but will lose money if the term is rolled multiple times and the borrower defaults thereafter.

The initial value of loan.rollable is always true, so unless the lender calls toggleRoll() in the same transaction that they call clear(), a determined attacker will be able to roll as many times as they wish.

Code Snippet

As long as the borrower is willing to pay the interest up front, they can call roll() any number of times, extending the duration of the total loan to however long they wish:

Solidity
// File: src/Cooler.sol : Cooler.roll()   #1

129        function roll (uint256 loanID) external {
130            Loan storage loan = loans[loanID];
131            Request memory req = loan.request;
132    
133            if (block.timestamp > loan.expiry) 
134                revert Default();
135    
136            if (!loan.rollable)
137                revert NotRollable();
138    
139            uint256 newCollateral = collateralFor(loan.amount, req.loanToCollateral) - loan.collateral;
140            uint256 newDebt = interestFor(loan.amount, req.interest, req.duration);
141    
142            loan.amount += newDebt;
143            loan.expiry += req.duration;
144            loan.collateral += newCollateral;
145            
146            collateral.transferFrom(msg.sender, address(this), newCollateral);
147:       }

https://github.com/sherlock-audit/2023-01-cooler/blob/main/src/Cooler.sol#L129-L147

toggleRoll() can't be used to stop rolls if they're all done in a single transaction.

Tool used

Manual Review

Recommendation

Have a variable controlling the number of rolls the lender is allowing, and or only allow a roll if the current block.timestamp is within one req.duration of the current loan.expiry

Discussion

hrishibhat

Sponsor comment:

Will resolve as result of change for #265

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

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 roll function lacks a limit on the number of times a loan can be rolled, and the lender's toggle cannot prevent multiple rolls within the same transaction.

Impact

The lender could be forced to wait indefinitely or lose money if the collateral depreciates and the borrower defaults after multiple rolls.

What the attacker needed

Borrower has an active loan; lender has enabled rolling; borrower can pay interest upfront

The fix

The code should be fixed by adding a variable to control the number of allowed rolls or by restricting rolls to occur only within one duration of the current expiry.

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 system, a borrower can sometimes extend the loan by paying interest upfront, called a 'roll'. The lender can turn off this feature, but if the borrower acts quickly, they can roll many times before the lender's action takes effect. This means the lender might be stuck with a loan that lasts much longer than intended.

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

View all

211 more disclosed reports, best first.

More from Cooler Update

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.