You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
github-actionsbot opened this issue
Jan 27, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
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:
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);
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
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 transferloan.amount
:debt.transferFrom(msg.sender, loan.lender, loan.amount);
Duplicate of #218
The text was updated successfully, but these errors were encountered: