Skip to content
Smart contracts Audit finding Intermediate

Corruptible Upgradability Pattern

Several upgradeable contracts in the project do not reserve storage space with gap variables, so adding new state variables during a future upgrade could overwrite existing storage slots. This could corrupt contract state and cause core functionality to fail or behave unexpectedly.

Anirruth Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#45368 [SC-Insight] Corruptible Upgradability Pattern

Submitted on May 13th 2025 at 11:10:07 UTC by @Anirruth for Audit Comp | Flare | FAssets

Description

Brief/Intro

Upgradeable smart contracts without proper storage gaps present a critical vulnerability where storage collisions can occur during contract upgrades. When new variables are added contract during an upgrade, they can overwrite existing variables, corrupting the contract state

Vulnerability Details

The vulnerability occurs when upgradeable contracts fail to implement storage gaps (__gap) to reserve space for future state variables. If the owner performs an upgrade and wants to add a new variable the storage slots would be overwritten. The following contract are upgradable contracts but doesn't implement storage gaps : CoreVaultManager, FAsset, AssetManagerController, CollateralPool.

Impact Details

Storage collisions can cause contract variables to be overwritten or misread, leading to corrupted state and unexpected behavior. The entire contract logic may be compromised, causing core functionalities to fail or behave unexpectedly.

References

Implement uint[50] private __gap; for the upgradable contracts mentioned above.

Proof of Concept

Proof of Concept

  • The owner wants to upgrade the contract and wants to introduce new variables.
  • Without gaps, the newly introduces variable would overwrite existing storage slots and corrupt the variables.
  • With storage gaps the new variables could use the gap storage slots.

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

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 upgradeable contracts were written without reserved storage gap arrays, leaving no room for future state variables in the storage layout.

Impact

Storage collisions could corrupt contract state and cause core functionality to fail or behave unexpectedly, though the report rates this as an insight rather than a demonstrated loss of funds.

What the attacker needed

Contract owner performs an upgrade; new state variables are added

The fix

The upgradeable contracts should reserve storage space by declaring a private gap array of unused slots.

How it was found

  1. The owner upgrades the contract and introduces new variables.
  2. Because no gaps exist, the new variable overwrites an existing storage slot.
  3. The overwritten variable is corrupted, changing contract behaviour.

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 contracts keep their data in numbered storage slots, and an upgrade can add new variables. If no empty slots are reserved in advance, a new variable can land on a slot already used by an old one and overwrite its value. A storage gap is a block of unused slots kept in reserve so future variables have somewhere safe to go.

What is Smart contracts?

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

More by Anirruth

View all

6 more disclosed reports, best first.

More from Flare | FAssets

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.