Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep Ruby Troll - Re-Updating Market Votes #721

Open
sherlock-admin2 opened this issue Dec 5, 2024 · 0 comments
Open

Deep Ruby Troll - Re-Updating Market Votes #721

sherlock-admin2 opened this issue Dec 5, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link
Contributor

Deep Ruby Troll

Medium

Re-Updating Market Votes

Summary

This issue is seen in both buyVotes and sellVotes once it updates the market.votes inside _calculateBuy then it updates it again in _calculateBuy

Root Cause

https://github.com/sherlock-audit/2024-11-ethos-network-ii/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L442-L534

https://github.com/sherlock-audit/2024-11-ethos-network-ii/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L942-L983

Exact Line of code where the re update occurs:
https://github.com/sherlock-audit/2024-11-ethos-network-ii/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L467

https://github.com/sherlock-audit/2024-11-ethos-network-ii/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L975

Basically we update it once inside _calculateBuy by getting exact market by getting the exact profileId by calling the _calculateBuy inside the buyVotes and sellVotes functions

(
      uint256 votesBought,
      uint256 fundsPaid,
      ,
      uint256 protocolFee,
      uint256 donation,
      uint256 minVotePrice,
      uint256 maxVotePrice
    ) = _calculateBuy(markets[profileId], isPositive, msg.value);

and when we update the market inside _calculateBuy

We re-Update it in both buyVotes and sellVotes

markets[profileId].votes[isPositive ? TRUST : DISTRUST] += votesBought;

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

causes re Updating and x2 of the actual amount of votesBought or votesSold

markets[profileId].votes[isPositive ? TRUST : DISTRUST] += votesBought;

PoC

No response

Mitigation

Update it just once after buyVouches or after sellVouches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant