Skip to content
Smart contracts Audit finding Advanced

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.

DigiSafe Follow with Kyosi, PNS and 4 others

Originally disclosed on Sherlock

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.

MERMAID
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.

Solidity
  constructor() {
    _disableInitializers();
  }

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

  1. Add gaps in AccessControl, SignatureControl
  2. Use library from Openzeppelin-upgradeable instead, e.g. PausableUpgradeable, AccessControlEnumerableUpgradeable.
  3. 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

The original report as published on Sherlock, by DigiSafe. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More from Ethos Network Social Contracts

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.