Mysterious Plum Griffin
Medium
The absence of a check for msg.value
when price == 0
in the _handlePayment
function allows users to send an arbitrary amount of ETH. Consequently, users can spend more than the intended price, creating an opportunity for excessive, unintended payments when adding reviews if the payment price is set to zero.
https://github.com/sherlock-audit/2024-10-ethos-network/blob/main/ethos/packages/contracts/contracts/EthosReview.sol#L481-L493
- In
_handlePayment(address paymentToken)
, there is a missingmsg.value
validation for cases whereprice
is zero andpaymentToken == address(0)
: - In cases where the review price is set to zero, there is no restriction on the amount of ETH that users can send in
msg.value
. - Example:
addReview()
will allow an arbitrary ETH payment ifpaymentToken
isaddress(0)
andprice
is zero.
- The protocol admin sets
reviewPrice[address(0)].price
to zero for the native ETH payment option in theinitialize
function. - Users call
addReview()
and chooseaddress(0)
aspaymentToken
, intending to pay with ETH. msg.value
is allowed to carry any amount since the_handlePayment
function does not checkmsg.value
whenprice == 0
.
- The protocol must allow
address(0)
as a valid token (for native ETH payments). - Users ETH balances need to be sufficient to send arbitrary amounts in
msg.value
.
- The protocol admin sets the price for reviews to zero for the native token (
address(0)
). - A user calls
addReview()
and chooses to pay with ETH, settingpaymentToken
toaddress(0)
and passing any positivemsg.value
. - The review is accepted, even though the user paid more than required, resulting in an unintended overpayment.
The protocol experiences unintended ETH overpayments when users submit reviews with paymentToken
set to address(0)
and price
set to zero. This results in potentially excessive and arbitrary ETH loss for users due to the lack of a strict check on msg.value
when no payment is required.
No response
Add a msg.value == 0
check within _handlePayment to enforce that no ETH is sent if the price for address(0)
is zero.