Skip to content

Latest commit

 

History

History
48 lines (22 loc) · 1.69 KB

File metadata and controls

48 lines (22 loc) · 1.69 KB

Calm Hotpink Sealion

Medium

Improper Validation in updateDonationRecipient function Allows Loss of User Funds

Summary

The updateDonationRecipient function in the reputationMarket.sol lacks proper validation to prevent a user (msg.sender) from setting themselves as the newRecipient. This oversight, combined with hardcoding donationEscrow[msg.sender] = 0, allows for the complete loss of the user’s donation balance.

Root Cause

In updateDonationRecipient, the function lacks a critical validation check to prevent msg.sender from setting themselves as the newRecipient. This leads to the following sequence of issues:

In ReputationMarket.sol:621-644 There is no check to ensure msg.sender != newRecipient.

In RepuationMarket.sol:642, the balance of msg.sender is hardcoded to 0 after the transfer (donationEscrow[msg.sender] = 0), leading to a loss of funds if the newRecipient is the same address as msg.sender.

Internal Pre-conditions

No response

External Pre-conditions

No response

Attack Path

The user intends to change their donation recipient, but due to a lack of validation, they mistakenly set their own address (msg.sender) as the newRecipient. In this case, the contract will not prevent the user from setting themselves as the recipient.

Impact

No response

PoC

https://github.com/sherlock-audit/2024-12-ethos-update/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L621-L644

Mitigation

Prevent users from setting their own msg.sender address as the new recipient