Lender can front-run `rollLoan` and call `provideNewTermsForRoll` with unfavorable terms
A lender could front-run a borrower's transaction to accept new loan terms, replacing the proposed terms with an extremely high interest rate. The borrower would then unknowingly accept the unfavourable terms and overpay interest.
0xbepresent Follow with Breeje, banditx0x and 10 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-08-cooler-judging/issues/243
Found by
0xbepresent, Breeje, banditx0x, cats, deadrxsezzz, detectiveking, evilakela, harisnabeel, james_wu, pep7siup, radevauditor, sandy, ubl4nk
Lender can front-run rollLoan and result in borrower accepting unfavorable terms.
Vulnerability Detail
After a loan is created, the lender can provide new loan terms via provideNewTermsForRoll. If they are reasonable, the user can then accept them. However this opens up a risky scenario:
- User A borrows from lender B
- Lender B proposes new suitable terms
- User A sees them and calls
rollLoanto accept them - Lender B is waiting for this and sees the pending transaction in the mempool
- Lender B front-runs user A's transaction and makes a new call to
provideNewTermsForRollwill an extremely high interest rate - User A's transaction now executes and they've accepted unfavorable terms with extremely high interest rate
Impact
User may get mislead in to accepting unfavorable terms and overpaying interest
Code Snippet
https://github.com/sherlock-audit/2023-08-cooler/blob/main/Cooler/src/Cooler.sol#L192 https://github.com/sherlock-audit/2023-08-cooler/blob/main/Cooler/src/Cooler.sol#L282
Tool used
Manual Review
Recommendation
When calling rollLoan let the user pass a parameter consisting of the max interest rate they are willing to accept to prevent from such incidents.
Discussion
0xRusowsky
jkoppel
This is moot because rollLoan no longer exists.
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
Likely the `rollLoan` function does not let the borrower specify a maximum acceptable interest rate, so the terms can be changed after the borrower decides to accept.
Impact
The borrower may be misled into accepting unfavourable terms and overpaying interest.
What the attacker needed
An existing loan; lender proposes new terms; borrower submits rollLoan transaction; lender can front-run
The fix
The `rollLoan` function should allow the borrower to specify a maximum acceptable interest rate, so that any change to worse terms would cause the transaction to revert.
How it was found
- User A borrows from lender B.
- Lender B proposes new suitable terms.
- User A sees them and calls `rollLoan` to accept them.
- Lender B sees the pending transaction in the mempool.
- Lender B front-runs user A's transaction and calls `provideNewTermsForRoll` with an extremely high interest rate.
- User A's transaction executes and accepts the unfavourable terms.
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 you take a loan, the lender can offer new terms. If you agree, you send a transaction to accept them. But the lender can see your pending transaction and quickly change the terms to a much higher interest rate before your transaction is processed. You end up accepting the bad terms without realising.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.