The voteDirection function in the BaseGauge contract allows users to vote on the direction of gauge weight distribution. According to the protocol design, the vote direction should be specified in basis points, with a valid range from a minimum of 100 to a maximum of 10,000. However, while the function (and its internal helper processVote) verifies that the vote direction does not exceed 10,000, it does not check that the value is at least 100. As a result, users can submit vote directions lower than the minimum threshold, which may lead to inaccurate vote weight processing, misallocation of rewards, and overall governance misrepresentation.
Function Behavior:
The voteDirection function is defined as follows:
Internal Check:
The internal function processVote also checks for an upper bound:
Omission:
Neither function enforces a minimum vote direction of 100. This omission means that values below 100, which are outside the intended specification, can be submitted. Consequently, users might submit vote directions (e.g., 50 basis points) that lead to an inaccurate reflection of their intended influence, potentially distorting reward distribution and governance calculations.
Incorrect Vote Weight Calculation:
A vote direction lower than the minimum may be interpreted incorrectly by the system, causing the applied weight multiplier to be less than intended. This can lead to lower reward multipliers or skewed gauge adjustments.
Reward and Governance Distortion:
The inaccurate vote direction can result in misaligned reward allocation and governance decisions. If vote directions are not enforced within the designed bounds, it can dilute the meaningful participation metrics and distort the true representation of stakeholder preferences.
User Vote with Sub-Minimum Direction:
Suppose a user, Alice, has sufficient voting power and is eligible to vote on gauge direction. Instead of submitting a vote with a valid direction (e.g., 500 basis points), she submits a vote with a direction of 50 (i.e., 0.5%). Since the contract does not check for a minimum value, her vote is accepted.
Internal Vote Processing:
The processVote function accepts the 50 basis point vote because it only checks that the direction is not greater than 10,000. This results in the system processing a vote that is below the expected minimum threshold of 100 basis points, leading to an inaccurate calculation of total vote weight.
Below is a simplified Foundry test case to demonstrate the issue:
Initialize a Foundry project:
Place your contract files in the src directory.
Create a test directory adjacent to src and add the test file (e.g., BaseGaugeVoteDirectionTest.t.sol).
Run the test:
Expected Outcome:
The test will succeed, demonstrating that a vote with a direction below the intended minimum is accepted. In a corrected implementation, the transaction should revert with an error (e.g., InvalidWeight()).
Inaccurate Vote Weighting:
Allowing vote directions below 100 basis points can result in an underrepresentation of a user’s intended voting strength, leading to miscalculated gauge adjustments.
Reward Misallocation:
Since vote direction influences reward multipliers, an erroneously low vote direction can lead to the distribution of fewer rewards than the user is entitled to, distorting incentive mechanisms.
Governance and Decision-Making Distortion:
Over time, the cumulative effect of such sub-minimum votes can skew overall gauge metrics, impacting governance decisions that rely on accurate and fair vote weight calculations.
Reduced System Integrity:
The absence of enforced bounds undermines the protocol’s ability to maintain consistent and predictable state, potentially leading to exploitation or unintentional misconfigurations by users.
Manual Review
Foundry
To address this vulnerability, the voteDirection function (and by extension, the processVote function) should enforce a minimum vote direction of 100 basis points. This can be done by adding a check that reverts the transaction if the direction is less than 100.
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.