ERC20ConvictionScore.acquireConviction implements wrong governance checks
The acquireConviction function in ERC20ConvictionScore omitted the balance check required to become a governor, allowing a user to gain governance rights without meeting the minimum balance. Additionally, the wasGovernance flag could be outdated, letting a user bypass governance parameter changes by front-running them with an NFT creation.
FairSide contest
Originally disclosed on Code4rena
There are two issues with the governance checks when acquiring them from an NFT:
(Issue 1) Missing balance check
The governance checks in _updateConvictionScore are:
!isGovernance[user]
&& userConvictionScore >= governanceThreshold
&& balanceOf(user) >= governanceMinimumBalance;
Whereas in acquireConviction, only userConvictionScore >= governanceThreshold is checked but not && balanceOf(user) >= governanceMinimumBalance.
else if (
!isGovernance[msg.sender] && userNew >= governanceThreshold
) {
isGovernance[msg.sender] = true;
}
(Issue 2) the wasGovernance might be outdated
The second issue is that at the time of NFT creation, the governanceThreshold or governanceMinimumBalance was different and would not qualify for a governor now. The NFT’s governance state is blindly appplied to the new user:
if (wasGovernance && !isGovernance[msg.sender]) {
isGovernance[msg.sender] = true;
}
This allows a user to circumvent any governance parameter changes by front-running the change with an NFT creation. It’s easy to circumvent the balance check to become a governor by minting and redeeming your own NFT. One can also circumvent any governance parameter increases by front-running these actions with an NFT creation and then backrunning with a redemption.
Recommend adding the missing balance check-in acquireConviction, removing the wasGovernance governance transfer from the NFT, and recomputing it based solely on the current governanceThreshold / governanceMinimumBalance settings.
fairside-core (FairSide) confirmed:
The latter of the two issue “types” is actually desired behavior. If a user was historically a governance member, the NFT should boast the exact same rights, and new thresholds should not retroactively apply. The former, however, is a valid issue as it allows circumventing the balance check!
fairside-core (FairSide) resolved:
Fixed in PR#12.
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
Impact
A user could become a governor without meeting the minimum balance, and could circumvent governance parameter increases by front-running with an NFT creation and backrunning with a redemption.
What the attacker needed
Access to acquireConviction function; ability to mint and redeem NFT
The fix
The missing balance check was fixed in PR#12, but the wasGovernance issue was considered desired behaviour and not changed.
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.
This is a smart contract bug where a function that gives governance power forgot to check that the user actually holds enough tokens. So someone could become a governor without meeting the balance requirement. Also, an old flag could let someone keep governance rights even after the rules changed.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.