Skip to content
Access control Audit finding Intermediate

Its possible to lose total governance control by mistake

The role manager contract's member count function includes addresses that have already renounced a role, so the count overstates the number of active governors. An attacker or careless admin could rely on this incorrect count and remove the last real governor, permanently losing governance control.

hubble Follow

Originally disclosed on Code4rena

Submitted by hubble, also found by antonttc, csanuragjain, gs8nrv, rayn, reassor, and TrungOre

RoleManager.sol#L43-L46 RoleManager.sol#L115-L128

The impact of this vulnerability, i.e., losing all governance control is very High. There is a possibility, due to a corner case as described below.

Proof of Concept

Contract : RoleManager.sol Function : renounceGovernance()

   Step 0:
     Let current governance role given to = CURRENT_GOV_ADDRESS
     so, getRoleMemberCount() for "governance" role will return = 1

   Step 1: Add a new address say ALICE to governance role, by addGovernor(ALICE)
     now, ALICE also has governace role, and getRoleMemberCount() for "governance" role will return = 2

   Step 2: Assume that ALICE renounces governance role, by renounceGovernance()
     now, ALICE does not have governance role, but getRoleMemberCount() for "governance" role will return = 2, due to a BUG

   Step 3: In some distant future, if there is a compromise of CURRENT_GOV_ADDRESS keys or due to some other reason,
     its decided to revoke governance role for CURRENT_GOV_ADDRESS via renounceGovernance(), and the command succeeds
     It can be assumed that since getRoleMemberCount() for "governance" role returns = 2, at least there is one other active governor address.
     But now, CURRENT_GOV_ADDRESS does not have governance role, and the total governance control on the protocol is lost my mistake.

Recommended Mitigation Steps

getRoleMemberCount() currently returns _roleMembers[role].length(); It should return the count only for _roles[role].members[account] = true;

Its recommended to add a new function to know who are the active members for any role, like getRoleMembers(bytes32 role) returning address account.

chase-manning (Backd) confirmed

gzeon (judge) decreased severity to Medium


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

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 member count function returns the length of an array that is never pruned when a member renounces, instead of counting only addresses that still hold the role.

Impact

If the last real governor is removed based on the inflated count, all governance control over the protocol is permanently lost.

What the attacker needed

Governance role with at least two members; one member renounces the role; admin later revokes the remaining governor

The fix

The member count should count only addresses that still hold the role, and a function should be added to list active members.

How it was found

  1. Start with one governor address holding the governance role.
  2. Add a second address to the governance role.
  3. Have the second address renounce the governance role.
  4. Observe that the member count still reports two governors.
  5. Later, revoke the original governor's role, believing another governor remains.
  6. Realise that no active governor is left and governance control is lost.

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 has a list of people allowed to make important decisions (governors). The contract has a function that is supposed to say how many governors there are, but it keeps counting people who have already left. If someone removes the last real governor thinking others remain, no one can govern the contract anymore.

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.

More by hubble

View all

11 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.