The current implementation performs the startedInSameEra() check after the _execute function. This sequence creates a vulnerability where the era consistency check could be bypassed if the _execute function contains operations that can prematurely terminate execution.
This vulnerability could lead to proposals being executed in a different era than they were proposed, potentially causing:
Execution of proposals under unexpected protocol conditions
Manipulation of governance decisions
Inconsistent protocol state
Possible exploitation of outdated proposals
Proof of Concept
A proposal is created and approved in Era A.
Before execution, the protocol transitions to Era B.
The proposal execution is initiated.
The _execute function encounters one of the following scenarios:
a. Gas exhaustion: A complex operation consumes all available gas, causing the transaction to fail before reaching the startedInSameEra() check.
b. Non-reverting opcode error: An assembly-level operation results in an error that doesn't trigger a revert (e.g., an invalid jump destination or stack underflow).
Due to these scenarios, the execution terminates prematurely, bypassing the startedInSameEra() check.
In a subsequent transaction, the proposal execution is retried. This time, it succeeds, but executes in Era B instead of Era A, potentially leading to unintended consequences.
Tools Used
Manual Review
Recommended Mitigation Steps
Move the startedInSameEra() check to the beginning of the proposal execution process, before any actions in _execute are performed. For example: ```solidity
function executeProposal(uint256 proposalId) public {
require(startedInSameEra(proposalId), "new era");
super._execute(proposalId, targets, values, calldatas, descriptionHash);
}
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/plugins/governance/Governance.sol#L136-L145
Vulnerability details
Impact
The current implementation performs the
startedInSameEra()
check after the_execute
function. This sequence creates a vulnerability where the era consistency check could be bypassed if the_execute
function contains operations that can prematurely terminate execution.This vulnerability could lead to proposals being executed in a different era than they were proposed, potentially causing:
Proof of Concept
_execute
function encounters one of the following scenarios:a. Gas exhaustion: A complex operation consumes all available gas, causing the transaction to fail before reaching the
startedInSameEra()
check.b. Non-reverting opcode error: An assembly-level operation results in an error that doesn't trigger a revert (e.g., an invalid jump destination or stack underflow).
startedInSameEra()
check.Tools Used
Manual Review
Recommended Mitigation Steps
Move the
startedInSameEra()
check to the beginning of the proposal execution process, before any actions in_execute
are performed. For example: ```solidityfunction executeProposal(uint256 proposalId) public { require(startedInSameEra(proposalId), "new era");
super._execute(proposalId, targets, values, calldatas, descriptionHash); }