Corruptible Upgradability Pattern
The Ethos contracts inherit non-upgradeable OpenZeppelin contracts and custom contracts without storage gaps, and their constructors do not disable initializers. If an admin upgrades and adds a storage slot, storage could be corrupted.
Source: https://github.com/sherlock-audit/2024-10-ethos-network-judging/issues/206
Found by
DigiSafe, Kyosi, PNS, dobrevaleri, pkqs90, shaflow01, x0lohaclohell
Summary
The EthosContracts (EthosProfile, EthosReview, ...) are UUPSUpgradeable. However, the current implementation has multiple issues regarding upgradability.
Root Cause
Following is the inheritance chain of the EthosContracts.
graph BT;
classDef nogap fill:#f96;
AccessControl:::nogap-->Pausable:::nogap
AccessControl:::nogap-->AccessControlEnumerable:::nogap
AccessControl:::nogap-->SignatureControl:::nogap
EthosProfile:::nogap-->AccessControl:::nogap
EthosReview:::nogap-->AccessControl:::nogap
EthosAttestation:::nogap-->AccessControl:::nogap
EthosDiscussion:::nogap-->AccessControl:::nogap
EthosVote:::nogap-->AccessControl:::nogap
The Ethos contracts are meant to be upgradeable. However, it inherits contracts that are not upgrade-safe.
The AccessControl and SignatureControl are both contracts written by Ethos team, both contain storage slots but there are no gaps implemented.
Also, AccessControl inherits the non-upgradeable version Pausable and AccessControlEnumerable from Openzeppelin's library, when it should use the upgradeable version from openzeppelin-contracts-upgradeable lib.
https://docs.openzeppelin.com/contracts/5.x/upgradeable
There is also another issue that in all EthosContract, the constructor does not have initializers disabled for the implementation contract. This is also a best practice for proxy contracts.
constructor() {
_disableInitializers();
}
- https://github.com/sherlock-audit/2024-10-ethos-network/blob/main/ethos/packages/contracts/contracts/utils/AccessControl.sol#L15
- https://github.com/sherlock-audit/2024-10-ethos-network/blob/main/ethos/packages/contracts/contracts/utils/SignatureControl.sol#L11
Internal pre-conditions
If admin performs an upgrade and wants to add another storage slot in AccessControl or SignatureControl contract, the storage slot would mess up.
External pre-conditions
N/A
Attack Path
N/A
Impact
Storage of vault contracts might be corrupted during upgrading.
PoC
N/A
Mitigation
- Add gaps in AccessControl, SignatureControl
- Use library from Openzeppelin-upgradeable instead, e.g. PausableUpgradeable, AccessControlEnumerableUpgradeable.
- Disable initializers in EthosContracts constructor.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/trust-ethos/ethos/pull/2204
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 contracts inherit non-upgradeable OpenZeppelin contracts and custom contracts without storage gaps, and do not disable initializers in constructors.
Impact
Storage of vault contracts might be corrupted during upgrading.
What the attacker needed
Admin performs an upgrade; new storage slot added
The fix
The protocol team fixed this issue in PR 2204.
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.
Upgradeable smart contracts use a proxy pattern where the storage layout must stay consistent across versions. This report found that some base contracts were not designed for upgrades, so adding new variables could overwrite existing data. The fix is to use upgrade-safe libraries and reserve storage gaps.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.