You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The buyVotes function fails to validate that the final adjusted vote count (currentVotesToBuy) remains above the specified minVotesToBuy after the dynamic adjustment loop. This allows a purchase to complete with fewer votes than the user expects, violating the slippage protection intended by the minVotesToBuy parameter.
However, this does not ensure that the final adjusted vote count (currentVotesToBuy) after the loop still satisfies minVotesToBuy. If the buyer initially specifies a high maxVotesToBuy, the dynamic adjustment loop may decrement the votes to a value below minVotesToBuy due to insufficient funds.
Here, no validation after loop if currentVotesToBuy >= minVotesToBuy.
Without a subsequent check, it’s possible for currentVotesToBuy to fall below minVotesToBuy, contradicting the user's expectation of receiving at least minVotesToBuy votes.
Jolly Denim Mouse
Medium
Missing Slippage checks in
buyVotes
functionSummary
The
buyVotes
function fails to validate that the final adjusted vote count (currentVotesToBuy
) remains above the specifiedminVotesToBuy
after the dynamic adjustment loop. This allows a purchase to complete with fewer votes than the user expects, violating the slippage protection intended by theminVotesToBuy
parameter.Root Cause
In the
buyVotes
function, while there is aminVotesToBuy
parameter, it only validates that the ETH provided (msg.value
) is sufficient to cover the cost ofminVotesToBuy
votes::https://github.com/sherlock-audit/2024-12-ethos-update/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L440
However, this does not ensure that the final adjusted vote count (
currentVotesToBuy
) after the loop still satisfiesminVotesToBuy
. If the buyer initially specifies a highmaxVotesToBuy
, the dynamic adjustment loop may decrement the votes to a value belowminVotesToBuy
due to insufficient funds.Here, no validation after loop if
currentVotesToBuy >= minVotesToBuy
.Without a subsequent check, it’s possible for
currentVotesToBuy
to fall belowminVotesToBuy
, contradicting the user's expectation of receiving at leastminVotesToBuy
votes.Internal Pre-conditions
No response
External Pre-conditions
No response
Attack Path
No response
Impact
Users may receive fewer votes than expected
PoC
No response
Mitigation
Add a post-loop validation:
The text was updated successfully, but these errors were encountered: