CVE-2023-40014: OpenZeppelin Contracts vulnerable to Improper Escaping of Output

@openzeppelin/contracts Updated 02 Oct 2025

Summary

11/08/2023
Yes i
Moderate
5.3

CVE-2023-40014: OpenZeppelin Contracts vulnerable to Improper Escaping of Output. Affects @openzeppelin/contracts versions >= 4.0.0, < 4.9.3. Fixed in 4.9.3. 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

OpenZeppelin Contracts is a library for secure smart contract development. It provides a collection of reusable and audited smart contracts that developers can use to build decentralized applications (dApps) on blockchain platforms. The library aims to enhance security and reduce the risk of vulnerabilities in smart contracts. However, a vulnerability has been discovered in OpenZeppelin Contracts versions 4.0.0 to 4.9.3 that can lead to improper escaping of output.

Vulnerability Detail

The vulnerability in OpenZeppelin Contracts arises when using ERC2771Context along with a custom trusted forwarder. In certain circumstances, calls originating from the forwarder with calldata shorter than 20 bytes may cause _msgSender to return address(0). This combination of circumstances is not common, as it does not occur with the default MinimalForwarder from OpenZeppelin Contracts or any deployed forwarder known to the team. However, if this vulnerability is exploited, it can result in unexpected behavior and potential security risks for contracts using the affected combination of components.

How To Fix

Minimum fixed version

4.9.3

This is the first release that contains the fix.

npm install @openzeppelin/contracts@4.9.3

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

Workaround

There is no specific workaround mentioned for this vulnerability.

Conclusion

OpenZeppelin Contracts versions 4.0.0 to 4.9.3 are vulnerable to an improper escaping of output vulnerability. This can lead to unexpected behavior and potential security risks for contracts using the affected combination of components. It is recommended to upgrade to OpenZeppelin Contracts version 4.9.3 or later to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for @openzeppelin/contracts →

Share this vulnerability

FAQ

OpenZeppelin Contracts is a library for secure smart contract development. It provides a collection of reusable and audited smart contracts that developers can use to build decentralized applications (dApps) on blockchain platforms.

Versions 4.0.0 to 4.9.3 of OpenZeppelin Contracts are affected by this vulnerability.

The vulnerability can cause _msgSender to return address(0) in certain circumstances, leading to unexpected behavior and potential security risks for contracts using the affected combination of components.

Yes, the vulnerability has been patched in OpenZeppelin Contracts version 4.9.3.

To fix the vulnerability, developers should upgrade their OpenZeppelin Contracts dependency to version 4.9.3 or later.

Related vulnerabilities

Recent vulnerabilities recorded for @openzeppelin/contracts.

How To Fix

Minimum fixed version

4.9.3

This is the first release that contains the fix.

npm install @openzeppelin/contracts@4.9.3

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