Token owners can double their voting power only once through self-delegation in the TempleGoldStaking contract.
In the TempleGoldStaking contract, token owners can delegate their voting power by calling the delegate
function, which makes a call to the internal _delegate
function:
In the call to the internal _delegate
function, with both delegator and delegatee being the token owner's address:
currentDelegate will be address(0) due to the first delegation of the token owner and the default value of the delegates mapping. Then the _moveDelegates
function is called to transfer voting power. The _moveDelegates
function is invoked with the following parameters: srcRep (currentDelegate) = address(0), dstRep=delegatee and amount = delegatorBalance.
The first if condition will return true, but the second if will be skipped due to srcRep being address(0). The third if block will be executed, and the voting power of dstRep (which is the token owner's address) will be increased. As a result, the token owner’s voting power has been increased by an amount equal to their total number of tokens, without a corresponding decrease.
It is important to note that the exploit only works once per address. If a token owner subsequently delegates to themselves after their initial self-delegation, currentDelegate will be set to a non-default value in the delegates mapping, and the delegation logic will work correctly.
Malicious token owners gain more voting power than they deserve. They could secretly accumulate multiple tokens and then exploit this vulnerability to double their voting power. This could also undermine the DAO’s mission and lead to a loss of trust in the protocol
Manual Review, VS Code
Make delegate Function Public:
Then, use this function inside the internal _delegate
function instead of accessing the delegates mapping directly:
or as a second option,
Adjust for Initial Delegation from address(0):
Modify the _moveDelegates
function to adjust for the initial delegation from address(0):
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.