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

kiki_dev - If user repays more than what is owed the function will revert. #144

Closed
github-actions bot opened this issue Jan 27, 2023 · 0 comments
Closed
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

kiki_dev

medium

If user repays more than what is owed the function will revert.

Summary

If user repays more than what is owed the function will revert.

Vulnerability Detail

when repay() is called and repaid is greater than loan.amount then the function will go into the else statement. Here loan.amount is deducted the value of repaid. If repaid is greater than loan.value then the the function will revert.

It can be the source of a DOS attack. If the lender wants the borrower to default on their loan they can front run the users transaction and pay a dust amount to force the victims transaction to revert. For example (with nice whole numbers):

Alice owes bob 100 dai on 1 eth collateral on a 1 hour loan.
Alice attempts to pay back the 100 dai in one repayment.
bob frontruns Alice and pays off 0.01 dai of her debt.
Alice's transaction reverts becasue she over paid.
Bob repeats this until the loan defaults.
Bob collects Alices 1 eth.

Any loan with a relatively short duration can be exploited like this.

Also This can be an issue if the user is paying off the loan last second. This could result in the user defaulting on the loan even though they attempted to pay it back with a sufficient amount.

Impact

Code Snippet

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

Tool used

Manual Review

Recommendation

If repaid is greater than loan amount only use the amount needed to pay the loan back in full. This way any excess gets returned to the user and the function wont revert.

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