ERC20ConvictionScore._updateConvictionScore uses stale credit score for governanceDelta
The conviction score update logic used a stale snapshot from the previous block when a user lost governance status, allowing the total governance score to be inflated. An attacker could increase their score and then transfer their balance in the same block, leaving the total governance score artificially high and potentially breaking the voting mechanism.
FairSide contest
Originally disclosed on Code4rena
In ERC20ConvictionScore._updateConvictionScore, when the user does not fulfill the governance criteria anymore, the governanceDelta is the old conviction score of the previous block.
isGovernance[user] = false;
governanceDelta = getPriorConvictionScore(
user,
block.number - 1
);
The user could increase their conviction/governance score first (in the same block) and then lose their status in a second transaction. After which, the total governance conviction score would only be reduced by the previous score.
** Example:** Block n - 10000: User is a governor and has a credit score of 1000, which was also contributed to the TOTAL_GOVERNANCE_SCORE Block n:
- User updates their own conviction score using the public
updateConvictionScorefunction, which increases the credit score by 5000 based on the accumulated time. The total governance credit score increased by 5000, making the user contribute 6000 credit score to governance in total. - User transfers their whole balance away, the balance drops below
governanceMinimumBalance, and the user is not a governor anymore. ThegovernanceDeltaupdate of the transfer should be 6000 (user’s whole credit score), but it’s only1000because it takes the snapshot of block n - 1.
In this way, the TOTAL_GOVERNANCE_SCORE score can be inflated and, in the worst case, break the voting mechanism, as no proposals can reach the quorum (percentage of totalVotes) anymore.
Recommend using the current conviction store which should be governanceDelta = checkpoints[user][userCheckpointsLength - 1].convictionScore.
fairside-core (FairSide) confirmed but disagreed with severity:
As with the other governance-related issues, this would once again cause dilution of all users and would not really be a viable attack vector. As such, I believe it is better suited for a medium severity (2) label.
fairside-core (FairSide) disputed:
This issue is actually quite deeper. When a transaction occurs in the same block, the logic paths within the
ifblock will not execute (due to time elapsed being 0), meaning that the conviction score will not be properly accounted for if I have a single normal transaction where I am still governance and consequently lose my governance in a second transaction. As such, the code needs to be adjusted to check governance eligibility outside of the if block as well (if no time has passed -> same block transaction).The code highlighted in the finding is actually correct. The conviction score should be reduced by the previous blocks as the newly accrued conviction score was never accounted for in governance. The proposed solution would lead to more conviction being reduced than it should. However, the finding did point out something wrong, so not sure whether it should be nullified or not.
I believe it should be awarded as it was on the right track to find the underlying issue!
fairside-core (FairSide) re-confirmed:
Fixed in PR#13.
Labeling this issue as valid because although it wasn’t 100% right on suggesting where the code was problematic, it did point out that the users could wrongfully transfer their whole balance and update their conviction score in the same block to keep their conviction score high, and then potentially do harmful things to the protocol by using their wrong conviction scores.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code used a previous block's conviction score instead of the current score when updating the total governance score after a user lost governance eligibility.
Impact
The total governance score could be inflated, potentially breaking the voting mechanism so that no proposals can reach quorum.
What the attacker needed
User is a governor; user can call updateConvictionScore; user can transfer tokens
The fix
The code was fixed in PR#13, which adjusted the logic to check governance eligibility outside the time-elapsed condition.
How it was found
- User updates their own conviction score using the public updateConvictionScore function, increasing the score by 5000.
- User transfers their whole balance away, dropping below governanceMinimumBalance and losing governor status.
- The governanceDelta update subtracts only the previous block's score (1000) instead of the full score (6000), inflating the total governance score.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract tracks users' 'conviction scores' to decide who can vote. When a user's balance drops below a threshold, the contract should subtract their full score from the total. Instead, it subtracted an old, smaller score, so the total stayed too high. This could let someone mess up voting so that no proposal gets enough votes to pass.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.