sherlock-audit / 2022-10-astaria-judging

6 stars 1 forks source link

tives - There are no checks or refunds for excessive payments in makePayment #248

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

tives

medium

There are no checks or refunds for excessive payments in makePayment

https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol/#L594

in the _payment function you check if the paymentAmount is higher than the lienAmount and subtract from the active lien amount after that

if (lien.amount > paymentAmount) {
    lien.amount -= paymentAmount;

However, in the else block, you dont check for excessive paymentAmount, and transfer the full amount to the payee

TRANSFER_PROXY.tokenTransferFrom(WETH, payer, payee, paymentAmount);

Impact

Some payers could, by mistake, make a payment with more funds than necessary and lose their tokens.

Mitigation

Revert if the payment is more than the lien.amount, or return the excessive payment back to the msg.sender

Duplicate of #28