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.
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
- Compile the contract and set the
\_GOVERNORand\_EMERGENCY_GOVERNOR. - Now set a
pendingGovbut do not callacceptGov()
Bug 1
- Call the
\__abdicate()function and we will notice only “gov” is set to zero address while emergency gov remains.
Bug2
- Now use the address used in
pendingGovto callacceptGov()function. - 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.
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).
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
- Compile the contract and set the governor and emergency governor addresses.
- Set a pending governor without calling acceptGov.
- Call the abdicate function and observe that only the main governor is set to the zero address.
- 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.