Inconsistent storage layout for ERC2771ContextUpgradeable in @openzeppelin/contracts-upgradeable

Summary

14/03/2022
LOW
Yes i
Low
Not published

GHSA-7j52-6fjp-58gr: Inconsistent storage layout for ERC2771ContextUpgradeable. Affects @openzeppelin/contracts-upgradeable versions >= 4.0.0, < 4.3.0. Fixed in 4.3.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The @openzeppelin/contracts-upgradeable package is an open-source library that provides upgradeable smart contract functionality for Ethereum-based applications. It includes various contract templates and utilities to facilitate contract upgrades and maintenance. One of the contracts in this package is ERC2771ContextUpgradeable, which is used for implementing the ERC2771 standard for gasless transactions. This vulnerability affects versions 4.0.0 to 4.2.0 of the package.

Vulnerability Detail

The vulnerability arises from an inconsistent storage layout in the ERC2771ContextUpgradeable contract. In versions 4.0.0, 4.1.0, and 4.2.0, the contract has a length of 51 slots, while in version 4.3.0 and onwards, it has a length of 50 slots. This difference in layout can lead to breaking upgrades if a contract using ERC2771ContextUpgradeable <4.3.0 is upgraded to a newer version that uses >=4.3.0. The risk of breaking upgrades can cause issues in the functionality and stability of the upgraded contract.

How To Fix

Latest published version: 5.6.1 as of 22 Oct 2026

npm install @openzeppelin/contracts-upgradeable@5.6.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.3.0

This is the first release that contains the fix.

npm install @openzeppelin/contracts-upgradeable@4.3.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

A possible workaround for this vulnerability is to copy the previous implementation of ERC2771ContextUpgradeable from the release-4.2 branch and include it in your codebase. This ensures that the storage layout remains consistent and avoids potential breaking upgrades.

Conclusion

In summary, the @openzeppelin/contracts-upgradeable package has a vulnerability related to the inconsistent storage layout of the ERC2771ContextUpgradeable contract. Upgrading from a contract using ERC2771ContextUpgradeable <4.3.0 to a newer version that uses >=4.3.0 can result in breaking upgrades. To mitigate this vulnerability, it is recommended to be cautious during upgrades, use the OpenZeppelin Upgrades Plugins, and consider copying the previous implementation of ERC2771ContextUpgradeable if necessary. For further assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for @openzeppelin/contracts-upgradeable →

Share this vulnerability

FAQ

The impact of this vulnerability is the potential for breaking upgrades when upgrading from a contract that uses ERC2771ContextUpgradeable <4.3.0 to a newer version that uses >=4.3.0. This can result in issues with the functionality and stability of the upgraded contract.

To mitigate the risk of breaking upgrades, it is recommended to be extremely careful when upgrading from a contract that uses ERC2771ContextUpgradeable <4.3.0 to a newer version that uses >=4.3.0. Additionally, using the OpenZeppelin Upgrades Plugins for Hardhat and Truffle can help catch potentially breaking upgrades.

If you need to upgrade to a newer version of the Upgradeable Contracts library, it is recommended to copy the previous implementation of ERC2771ContextUpgradeable from the release-4.2 branch and package it with your code. This ensures that the storage layout remains consistent and avoids potential breaking upgrades.

Yes, the OpenZeppelin Upgrades Plugins for Hardhat and Truffle can help with upgrades and catch potentially breaking upgrades. It is recommended to use this tooling for all your upgrades.

Related vulnerabilities

Recent vulnerabilities recorded for @openzeppelin/contracts-upgradeable.

How To Fix

Latest published version: 5.6.1 as of 22 Oct 2026

npm install @openzeppelin/contracts-upgradeable@5.6.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.3.0

This is the first release that contains the fix.

npm install @openzeppelin/contracts-upgradeable@4.3.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback