Skip to content
Business logic Audit finding Intermediate

Loan is rollable by default

The loan contract sets the rollable flag to true by default when a new loan is created, allowing a borrower to extend the loan before the lender can disable it. This gives the borrower an unfair advantage if the lender did not intend to allow rolling.

hansfriese Follow with Nyx, enckrish and 10 others

Originally disclosed on Sherlock

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

Found by

hansfriese, Nyx, enckrish, wagmi, yixxas, HollaDieWaldfee, HonorLt, Tricko, Zarf, libratus, simon135, usmannk, Trumpero

Summary

Making the loan rollable by default gives an unfair early advantage to the borrowers.

Vulnerability Detail

When clearing a new loan, the flag of rollable is set to true by default:

Solidity
    loans.push(
        Loan(req, req.amount + interest, collat, expiration, true, msg.sender)
    );

This means a borrower can extend the loan anytime before the expiry:

Solidity
    function roll (uint256 loanID) external {
        Loan storage loan = loans[loanID];
        Request memory req = loan.request;

        if (block.timestamp > loan.expiry) 
            revert Default();

        if (!loan.rollable)
            revert NotRollable();

If the lenders do not intend to allow rollable loans, they should separately toggle the status to prevent that:

Solidity
    function toggleRoll(uint256 loanID) external returns (bool) {
        ...
        loan.rollable = !loan.rollable;
        ...
    }

I believe it gives an unfair advantage to the borrower because they can re-roll the loan before the lender's transaction forbids this action.

Impact

Lenders who do not want the loans to be used more than once, have to bundle their transactions. Otherwise, it is possible that someone might roll their loan, especially if the capital requirements are not huge because anyone can roll any loan.

Code Snippet

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

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

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

Tool used

Manual Review

Recommendation

I believe rollable should be set to false by default or at least add an extra function parameter to determine the initial value of this status.

Discussion

hrishibhat

Sponsor comment:

Valid. Will default to false.

sherlock-admin

Retracted since https://github.com/sherlock-audit/2023-01-cooler-judging/issues/215 shows that there can be circumstances where funds lose value over the life of the loan

You've deleted an escalation for this issue.

The original report as published on Sherlock, by hansfriese. 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 loan creation function sets the rollable flag to true by default instead of false.

Impact

Lenders who do not want loans to be rolled must bundle transactions to prevent it; otherwise, anyone can roll the loan, especially if capital requirements are low.

What the attacker needed

A loan is created; lender does not disable rollable

The fix

The rollable flag should be set to false by default, or an extra parameter should determine its initial value.

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 a loan is created, a setting called 'rollable' is automatically turned on. This means the borrower can choose to extend the loan later, even if the lender didn't want that. The lender would have to take extra steps to turn it off, but the borrower might act first.

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 hansfriese

View all

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