A critical vulnerability exists in the recordVote function of the veRAACToken contract, allowing any user to record a vote on behalf of another user. This flaw enables malicious actors to manipulate voting outcomes by casting votes for other users without their consent. The issue arises because the function does not validate whether the caller is the same as the voter, making the voting mechanism insecure.
Affected Code: veRAACToken::recordVote
The recordVote function accepts two parameters: voter (the address of the voter) and proposalId (the ID of the proposal being voted on). However, the function does not enforce any access control, allowing any caller to record a vote for any address. This design flaw can be exploited to:
Cast votes on behalf of users without their knowledge or consent.
Manipulate voting outcomes by inflating votes for or against specific proposals.
Undermine the integrity of the governance system.
The voter parameter is not validated against msg.sender, allowing anyone to record a vote for any address.
_hasVotedOnProposal PublicTo verify if a vote has been recorded, modify the veRAACToken.sol file to make the _hasVotedOnProposal mapping public:
Add the following test case to the veRAACToken.test.js file to demonstrate the vulnerability:
Setup:
Deploy the veRAACToken contract and the mock RAAC token.
Mint tokens and approve the veRAACToken contract to spend tokens on behalf of users.
Test Scenario:
User1 creates a lock to gain voting power.
User2 (a different user) calls recordVote on behalf of User1 without User1's consent.
Verify that User1's vote has been recorded, even though User2 initiated the transaction.
Expected Behavior:
The test demonstrates that the recordVote function allows anyone to record a vote for another user, which is a vulnerability.
This vulnerability allows malicious users to manipulate voting outcomes by casting unauthorized votes on behalf of others.
Attackers can influence governance decisions, such as protocol upgrades or fund allocations, by inflating votes for or against specific proposals.
Loss of Trust: The integrity of the governance system is compromised, leading to a loss of trust among users and stakeholders.
Manual Code Review
To fix this vulnerability, modify the recordVote function to ensure that only the voter can record their own vote. Use msg.sender instead of accepting a voter parameter:
recordVote FunctionThe 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.