Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

HollaDieWaldfee - Cooler: repay function can be front-run so borrowers transaction reverts #28

Closed
github-actions bot opened this issue Jan 27, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@github-actions
Copy link

github-actions bot commented Jan 27, 2023

HollaDieWaldfee

medium

Cooler: repay function can be front-run so borrowers transaction reverts

Summary

The Cooler.repay function is used to repay a loan.
An attacker can call this function with a very small amount and front-run the borrower's transaction to fully repay the loan.
Thereby the borrower's transaction reverts because loan.amount -= repaid underflows:

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

Vulnerability Detail

The vulnerable function:

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

The line that reverts when an attacker front-runs the victim and the victim tries to repay the full loan:

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

Impact

An attacker can DOS transactions of users that try to repay the full loan.

Code Snippet

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

Tool used

Manual Review

Recommendation

Only allow the borrower to repay his loan or if repaid > loan.amount then only transfer loan.amount: debt.transferFrom(msg.sender, loan.lender, loan.amount);

Duplicate of #218

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue labels Jan 27, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Feb 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant