The likeUser
function in the LikeRegistry
contract allows users to send ETH to "like" another user but does not refund excess ETH if the sent amount exceeds the required 1 ETH. But as per the rrequirement of the protocol the user needs to send only 1 ETH to like another user. This results in permanent loss of overpaid funds for users who mistakenly send more than 1 ETH.
Contract: LikeRegistry.sol
Function: likeUser
Inflexible ETH Handling:
The likeUser
function requires msg.value >= 1 ether
, allowing users to send more than 1 ETH. However, the contract does not refund the excess amount.
This violates the principle of least astonishment, as users expect unused ETH to be returned automatically.
Financial Loss: Users who send more than 1 ETH (e.g., 1.5 ETH) lose the excess amount (0.5 ETH) permanently.
User Experience: Accidental overpayments due to UI issues or miscalculations lead to frustration and distrust.
Reputation Risk: The protocol may be perceived as predatory or buggy.
Deploy the LikeRegistry
and SoulboundProfileNFT
contracts.
User1 mints a profile NFT.
User1 calls likeUser
with msg.value = 1.5 ether
.
Observe that:
The transaction succeeds (since msg.value >= 1 ether
).
The contract retains the full 1.5 ETH, and no refund is issued.
Expected: Excess ETH should be refunded, or the transaction should revert if the amount is not exact.
Actual: The contract retains all ETH sent, leading to financial loss.
Enforce that users send exactly 1 ETH:
Calculate and refund the excess amount:
Input Validation: Use msg.value == 1 ether
unless variable payments are explicitly allowed.
Gas Limits: Ensure refunds use call{gas: ...}
to mitigate reentrancy risks (though not critical here).
Documentation: Clearly state the required ETH amount in the UI/UX to prevent user errors.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.