Skip to content
Access control Audit finding Intermediate

Business logic bug in __abdicate() function - 2 Bugs

The abdicate function that is meant to renounce governance only clears the main governor address, leaving the emergency governor and any pending governor in place. A pending governor could later accept the role and take control of the protocol, potentially capturing its fees.

cyberboy Follow

Originally disclosed on Code4rena

Submitted by cyberboy, also found by Meta0xNull

Impact

The \__abdicate() function at https://github.com/code-423n4/2021-11-streaming/blob/main/Streaming/src/Locke.sol#L46-L50 is the logic to remove the governance i.e., to renounce governance. However, the function logic does not consider emergency governor and pending governor, which can be a backdoor as only the “gov” is set to zero address while the emergency and pending gov remains. A pending gov can just claim and become the gov again, replacing the zero address.

Proof of Concept

  1. Compile the contract and set the \_GOVERNOR and \_EMERGENCY_GOVERNOR.
  2. Now set a pendingGov but do not call acceptGov()

Bug 1

  1. Call the \__abdicate() function and we will notice only “gov” is set to zero address while emergency gov remains.

Bug2

  1. Now use the address used in pendingGov to call acceptGov() function.
  2. We will notice the new gov has been updated to the new address from the zero address.

Hence the \__abdicate() functionality can be used as a backdoor using emergency governor or leaving a pending governor to claim later.

Tools Used

Remix to test the proof of concept.

Recommended Mitigation Steps

The \__abdicate() function should set emergency_gov and pendingGov as well to zero address.

brockelmore (Streaming Protocol) confirmed and disagreed with severity:

Yes, the governor can be recovered from abdication if pendingGov != 0 as well as emergency gov needs to be set to 0 before abdication because it won’t be able to abdicate itself.

Would consider it to be medium risk because chances of it ever being called are slim as it literally would cutoff the protocol from being able to capture its fees.

0xean (judge) commented:

Given that the functionality and vulnerability exists, and the governor does claim fees, this could lead to the loss of funds. Based on the documentation for C4, that would qualify as high severity.

3 — High: Assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).

The original report as published on Code4rena, by cyberboy. 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 abdicate function clears only the main governor variable and does not reset the emergency governor or pending governor, so governance can be recovered.

Impact

Governance could be recovered after abdication, which the judge said could lead to the loss of funds, though the protocol team considered the chance of it being called slim.

What the attacker needed

Governor calls abdicate; a pending governor was set earlier

The fix

The abdicate function should also set the emergency governor and pending governor to the zero address.

How it was found

  1. Compile the contract and set the governor and emergency governor addresses.
  2. Set a pending governor without calling acceptGov.
  3. Call the abdicate function and observe that only the main governor is set to the zero address.
  4. Call acceptGov from the pending governor address and observe that it becomes the new governor.

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 can have a special owner account, called a governor, that controls it. This report shows that the function meant to give up that ownership only cleared one of several owner slots, so another account could still step in and take over.

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 cyberboy

View all

2 more disclosed reports, best first.

More from Streaming Protocol 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.