30898 - [SC - Critical] Call the deposit function before the distribute...
Submitted on May 7th 2024 at 19:44:37 UTC by @cryptoticky for Boost | Alchemix
Report ID: #30898
Report type: Smart Contract
Report severity: Critical
Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/Voter.sol
Impacts:
Manipulation of governance voting result deviating from voted outcome and resulting in a direct change from intended effect of original results
Theft of unclaimed yield
Description
Brief/Intro
If an attacker makes a deposit before the Voter.distribute
function is called in a new epoch, the Bribe.totalVoting
becomes smaller than the actual sum of votes. This discrepancy provides the attacker with an opportunity to steal funds from the contract.
Vulnerability Details
Keeper or anyone will call
Voter.distribute
function to initialize the protocol once a new epochBut an attacker can call
Voter.vote
function before theVoter.distribute
function is calledIf the
Voter.distribute
function is called after the attacker callsVoter.vote
function, that updatesBribe.totalVoting
to0
If there is no vote anymore in this epoch, the prevSupply will be 1 when the attacker claims the reward. It means that the attacker can adjust the amount of rewards you will receive. So that the attacker can steal all assets in the Bribe contract.
If there are other votes after calling distribute function, the attacker can get more than the expected reward.
Impact Details
As a result of the vote, it results in a different effect from the expected effect regardless of voting Power.
An attacker can steal all the rewards in the Bribe contract.
Recommendation
It is recommended to confirm that the Voter.distribute function was called when users call Voter.vote function in the new epoch, and if it is false, it is recommended to call the distribute function first.
Proof of Concept
Last updated