Skip to content
Smart contracts Audit finding Advanced

STORAGE COLLISION BETWEEN PROXY AND IMPLEMENTATION (LACK EIP 1967)

The proxy contract does not use EIP-1967 storage slots, so its implementation address and owner variable share the same storage layout as the logic contract. An attacker could potentially overwrite sensitive variables or cause an upgrade to brick the contract by rearranging inheritance order.

peritoflores Follow

Originally disclosed on Code4rena

Submitted by peritoflores

Storage collision because of lack of EIP1967 could cause conflicts and override sensible variables

Proof of Concept

contract CoreProxy is Ownable {
       address private immutable _implement;

When you implement proxies, logic and implementation share the same storage layout. In order to avoid storage conflicts EIP1967 was proposed.(https://eips.ethereum.org/EIPS/eip-1967) The idea is to set proxy variables at fixed positions (like impl and admin ).

For example, according to the standard, the slot for for logic address should be

0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) ).

In this case, for example, as you inherits from Ownable the variable _owner is at the first slot and can be overwritten in the implementation. There is a table at OZ site that explains this scenario more in detail

https://docs.openzeppelin.com/upgrades-plugins/1.x/proxies

section “Unstructured Storaged Proxies”

Recommended Mitigation Steps

Consider using EIP1967

sofianeOuafir (Joyn) confirmed and commented:

This is an issue we want to investigate and fix if our investigation suggests we indeed need to make improvement on that end.

At the same time, I have little idea of what is the impact of this issue. I’m not sure if it’s a high risk item

deluca-mike (judge) commented:

Impact would be that an upgrade could brick a contract by simply rearranging inheritance order, or adding variables to an inherited contract, since the implantation slot will not be where it is expected. As the warden suggests, its critical that the implementation slot be fixed at an explicit location, and not an implicit location derived purely from inheritance and declaration order.


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

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 proxy stores its implementation address and inherited variables in sequential storage slots instead of using EIP-1967's fixed, collision-resistant slots.

Impact

An upgrade could brick the contract by rearranging inheritance order or adding variables, and sensitive variables like the owner could be overwritten.

What the attacker needed

Proxy contract without EIP-1967

The fix

The proxy should be fixed to use EIP-1967 storage slots for its implementation and admin addresses.

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 proxy contract forwards calls to a logic contract, and both share the same storage. Without a standard like EIP-1967, the proxy's own variables (like the owner) can end up in the same slots as the logic contract's variables, causing them to overwrite each other. This can break the contract or let someone change important settings.

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 peritoflores

View all

4 more disclosed reports, best first.

More from Joyn contest

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.