CVE-2021-23840 Overview
CVE-2021-23840 is an Integer Overflow vulnerability affecting the OpenSSL cryptographic library. Calls to EVP_CipherUpdate, EVP_EncryptUpdate, and EVP_DecryptUpdate functions may overflow the output length argument when the input length approaches the maximum permissible value for an integer on the platform. When this overflow occurs, the function incorrectly returns 1 (indicating success) while setting the output length value to a negative number, potentially causing applications to behave incorrectly or crash.
This vulnerability represents a significant risk to applications relying on OpenSSL for encryption and decryption operations, particularly those processing large data blocks. The widespread deployment of OpenSSL across enterprise infrastructure, web servers, and embedded devices amplifies the potential impact of this flaw.
Critical Impact
Applications using vulnerable OpenSSL versions may crash or exhibit undefined behavior when processing large encryption/decryption operations, potentially leading to denial of service conditions.
Affected Products
- OpenSSL versions 1.1.1 through 1.1.1i
- OpenSSL versions 1.0.2 through 1.0.2x
- Debian Linux 10.0
- Oracle MySQL Server, GraalVM, Business Intelligence
- Node.js (multiple versions)
- Tenable Log Correlation Engine and Nessus Network Monitor
- McAfee ePolicy Orchestrator
- Fujitsu M10 and M12 series firmware
Discovery Timeline
- February 16, 2021 - CVE-2021-23840 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2021-23840
Vulnerability Analysis
The vulnerability exists within OpenSSL's EVP (Envelope) cipher API functions. When an application calls EVP_CipherUpdate, EVP_EncryptUpdate, or EVP_DecryptUpdate with an input length value approaching INT_MAX, an arithmetic overflow can occur during the calculation of the output buffer length. This integer overflow causes the output length parameter to wrap around to a negative value.
The dangerous aspect of this vulnerability is that the function still returns a success code (1) despite the overflow condition. Applications that rely on the output length value to determine how much data was processed will receive incorrect information, potentially leading to buffer mismanagement, application crashes, or unpredictable behavior in cryptographic operations.
Root Cause
The root cause is an Integer Overflow (CWE-190) in the output length calculation within the EVP cipher functions. The functions fail to properly validate that the computed output length will fit within the bounds of a signed integer before performing arithmetic operations. When the input data size is sufficiently large (close to platform integer limits), the calculation overflows, producing a negative result that passes through without proper error handling.
Attack Vector
An attacker can exploit this vulnerability through network-accessible services that process encrypted data using OpenSSL. The exploitation requires the ability to influence the size of data being processed by the vulnerable cipher functions. Attack scenarios include:
- Sending specially crafted large encrypted payloads to applications using OpenSSL for TLS/SSL processing
- Targeting applications that allow user-controlled data sizes in encryption/decryption operations
- Exploiting web servers, database connections, or any network service relying on OpenSSL for cryptographic operations
The vulnerability is exploitable remotely without requiring authentication or user interaction, making it particularly concerning for internet-facing services.
Detection Methods for CVE-2021-23840
Indicators of Compromise
- Application crashes or unexpected terminations during large data encryption/decryption operations
- Negative values appearing in logging or debugging output related to buffer sizes in cryptographic operations
- Memory corruption signatures or segmentation faults in processes using OpenSSL
- Unexpected service restarts or denial of service conditions affecting OpenSSL-dependent applications
Detection Strategies
- Inventory all systems running OpenSSL and identify versions prior to 1.1.1j or 1.0.2y
- Monitor application logs for abnormal termination signals or crash reports related to cryptographic functions
- Deploy vulnerability scanning tools to identify affected OpenSSL library versions across the infrastructure
- Use software composition analysis (SCA) tools to identify applications bundling vulnerable OpenSSL versions
Monitoring Recommendations
- Implement real-time monitoring for application stability metrics on services using OpenSSL
- Configure alerts for unusual memory allocation patterns or negative buffer size calculations in cryptographic operations
- Monitor system logs for crash dumps mentioning EVP cipher functions
- Track version information of OpenSSL libraries deployed across all systems through asset management
How to Mitigate CVE-2021-23840
Immediate Actions Required
- Upgrade OpenSSL to version 1.1.1j or later for systems running 1.1.1 branch
- For systems still on OpenSSL 1.0.2 (Premium Support customers only), upgrade to version 1.0.2y
- Migrate systems running OpenSSL 1.0.2 without premium support to the 1.1.1 branch, as 1.0.2 is end-of-life
- Update all applications and dependencies that bundle OpenSSL libraries
- Apply vendor-specific patches for affected products including Node.js, Oracle products, and Tenable tools
Patch Information
OpenSSL has released patched versions addressing this vulnerability. The fix is included in OpenSSL 1.1.1j for the 1.1.1 branch and 1.0.2y for premium support customers on the 1.0.2 branch. The patches implement proper bounds checking to prevent integer overflow in the output length calculation.
For detailed patch information, refer to the OpenSSL Security Advisory 20210216. The specific code changes can be reviewed in the OpenSSL git repository commit diffs: OpenSSL Commit Diff 6a51b9e and OpenSSL Commit Diff 9b1129.
Additional vendor advisories are available from Oracle CPU April 2021, Debian Security DSA-4855, and Tenable Security Advisory TNS-2021-03.
Workarounds
- Implement input validation to reject excessively large data blocks before passing them to EVP cipher functions
- Deploy network-level controls to limit the maximum size of encrypted payloads accepted by vulnerable services
- Enable application-level protections that monitor and restrict buffer sizes in cryptographic operations
- Consider temporarily disabling or isolating services that process large encrypted data volumes until patching is complete
# Check OpenSSL version on Linux systems
openssl version -a
# Verify patched version is installed (should be 1.1.1j or later)
openssl version | grep -E "1\.1\.1[j-z]|1\.0\.2y"
# List packages depending on OpenSSL for comprehensive patching
# Debian/Ubuntu
dpkg -l | grep -i openssl
apt list --installed 2>/dev/null | grep -i ssl
# RHEL/CentOS
rpm -qa | grep -i openssl
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


