Conviction totals not updated during tokenization
The tokenizeConviction function ignores the return values from _updateConvictionScore, so the network-wide conviction and governance totals are not updated. This leads to incorrect tribute calculations because the totals are used as denominators.
FairSide contest
Originally disclosed on Code4rena
_updateConvictionScore() function returns convictionDelta and governanceDelta which need to be used immediately in a call to _updateConvictionTotals (convictionDelta, governanceDelta) for updating the conviction totals of conviction and governance-enabled conviction for the entire FairSide network.
This updating of totals after a call to _updateConvictionScore() is done on Line70 in _beforeTokenTransfer() and on Line367 in updateConvictionScore() of ERC20ConvictionScore.sol.
However, the return values of _updateConvictionScore() are ignored on Line284 in tokenizeConviction() and are not used to update the totals using _updateConvictionTotals(convictionDelta, governanceDelta).
The impact of this is that when a user tokenizes their conviction score, their conviction deltas are updated and recorded (only if the funds locked are zero, which is incorrect and reported separately in a different finding), but the totals are not updated. This leads to incorrect accounting of TOTAL_CONVICTION_SCORE and TOTAL_GOVERNANCE_SCORE, which are used to calculate tributes, and therefore will lead to incorrect tribute calculations.
EXAMPLE:
Alice calls
tokenizeConviction()to convert her conviction score into an NFT. Her conviction deltas (as returned by_updateConvictionScore()) are ignored. Furthermore,TOTAL_CONVICTION_SCOREandTOTAL_GOVERNANCE_SCOREvalues are not updated. As a result, the tributes rewarded are proportionally more than what they should have been. This is because the conviction score totals are used as the denominator inavailableTribute()andavailableGovernanceTribute().
Recommend using the return values of the _updateConvictionScore() function (i.e. convictionDelta and governanceDelta) on Line284 of ERC20ConvictionScore.sol, and then use them in a call to _updateConvictionTotals(convictionDelta, governanceDelta).
fairside-core (FairSide) confirmed:
Fixed in PR#17.
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
The tokenizeConviction function fails to use the return values of _updateConvictionScore to call _updateConvictionTotals, unlike other functions that do.
Impact
Incorrect accounting of TOTAL_CONVICTION_SCORE and TOTAL_GOVERNANCE_SCORE could lead to tributes being proportionally higher than they should be.
What the attacker needed
User has a conviction score; user calls tokenizeConviction
The fix
The fix was to use the return values of _updateConvictionScore and call _updateConvictionTotals with them.
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.
When a user converts their conviction score into a token, the system should update the overall totals for the whole network. Here, it forgot to do that, so the totals become wrong. Those totals are used to decide how much reward (tribute) each person gets, so some people may get too much.
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.