The increasefunction in the veRAACToken.solcontract adds the increased amount twice while updating the new bias and new slope for the user. A malicious user can lock same amount of token for the same amount of time, and get more voting power than what he should get.
In line 253 of veRAACToken.sol, _lockState.increaseLock(msg.sender, amount)this line already update the locked amount to the previous amount plus newly added amount.
However, in line 258~262, _votingState.calculateAndUpdatePower()function takes userLock.amount + amountas the argument. This means the amountis added again to userLock.amountwhich is already incremented by the amountin line 253.
A malicious user can lock small amount of token to create a lock, and then increase the locked amount to get more voting power.
For example, Let's say locking 100 token from the beginning will generate 100 voting power.
If a user creates lock with 1 token and then increase the lock with 99 token, then the voting power will be near 200 voting power which is double the expected amount.
Add following code to veRAACToken.test.js
Run npx hardhat test --grep "Lock and Increase comparison"
The result is :
The bug disrupts the governance system because a malicious user can get more voting power than normal users. The advantage that a malicious user can get is up to 200% of normal users.
Hardhat
In line 257~262, userLock.amount + amountshould be replaced with userLock.amount.
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.