Proposals overwrite
The Governance contract's submitProposal function does not verify that a proposal ID already exists before storing metadata, so if the kernel module is updated and reconfigured, a new proposal could overwrite an existing one. An attacker could potentially replace a legitimate proposal with their own, but only under specific upgrade conditions.
Submitted by 0x1f8b
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L167 https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L66
It is possible to overwrite proposals in certain circumstances. The method Governance.submitProposal doesn’t check if the proposalId (stored in a different contract) exists already as a valid proposal in getProposalMetadata.
Proof of Concept
If the project update the kernel module ”INSTR” and reconfigure proposals and call INSTR.store(instructions_);, the counter may return a proposalId of an existing proposal and overwrite an existing previous one.
This is due to the fact that the proposals are saved in a mapping of a contract that is not related to the one that returns the counters, and furthermore, they do not check that the record already exists.
uint256 proposalId = INSTR.store(instructions_);
getProposalMetadata[proposalId] = ProposalMetadata(
title_,
msg.sender,
block.timestamp,
proposalURI_
);
Recommended Mitigation Steps
- Store the proposal metadata in the same
INSTRcontract or ensure that the proposal doesn’t exist.
fullyallocated (Olympus) acknowledged, but disagreed with severity and commented:
Agreed with the validity of the circumstance, but it is contingent on us upgrading the contract in an unexpected way. Is the same as saying “if you upgrade a contract incorrectly it can break the dependencies”.
0xean (judge) decreased severity to Medium and commented:
Going to downgrade to medium based on some external requirements needing to be in place to be realized.
Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.Function of the protocol could be impacted and there are external requirements.
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 proposal ID counter is stored in a separate contract from the proposal metadata, and the submitProposal function does not check for existing IDs before writing.
Impact
The function of the protocol could be impacted, but external requirements (an unexpected contract upgrade) must be in place for the attack to be realised.
What the attacker needed
Contract upgrade in an unexpected way
The fix
The proposal metadata should be stored in the same INSTR contract, or the code should ensure that the proposal does not already exist.
How it was found
- Update the kernel module INSTR and reconfigure proposals.
- Call INSTR.store(instructions_) which may return an existing proposalId.
- The new proposal metadata overwrites the existing proposal with that ID.
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 stores proposals in a list, each with a unique number. The function that adds a new proposal does not check if that number is already used. If the system is upgraded in a certain way, the numbering could reset and a new proposal might get the same number as an old one, replacing it. This could let someone overwrite an existing proposal with their own.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.