Skip to main content

CVE-2021-3711 — Vulnerability in openssl-src — CVE Details

CRITICAL

SM2 Decryption Buffer Overflow

Published May 24, 2022Updated June 24, 2024Source: OSV

What Should I Do?

Fix in Your Next Sprint

This vulnerability has a 88.58% chance of being exploited within 30 days.

Does your project use an affected openssl-src version?

Paste your Cargo.lock to check it for CVE-2021-3711 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my Cargo.lock

Summary

In order to decrypt SM2 encrypted data an application is expected to call the API function EVP_PKEY_decrypt(). Typically an application will call this function twice. The first time, on entry, the "out" parameter can be NULL and, on exit, the "outlen" parameter is populated with the buffer size required to hold the decrypted plaintext. The application can then allocate a sufficiently sized buffer and call EVP_PKEY_decrypt() again, but this time passing a non-NULL value for the "out" parameter. A bug in the implementation of the SM2 decryption code means that the calculation of the buffer size required to hold the plaintext returned by the first call to EVP_PKEY_decrypt() can be smaller than the actual size required by the second call. This can lead to a buffer overflow when EVP_PKEY_decrypt() is called by the application a second time with a buffer that is too small. A malicious attacker who is able present SM2 content for decryption to an application could cause attacker chosen data to overflow the buffer by up to a maximum of 62 bytes altering the contents of other data held after the buffer, possibly changing application behaviour or causing the application to crash. The location of the buffer is application dependent but is typically heap allocated. Fixed in OpenSSL 1.1.1l (Affected 1.1.1-1.1.1k).

Advisory Timeline

  • First published May 24, 2022 (1647 days ago).
  • Last revised June 24, 2024 — 762 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Cargo
Update openssl-src to 111.16.0 or later
cargo update -p openssl-src --precise 111.16.0

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: crates.io (1).

PackageFixed In
openssl-src crates.io · Affected: All versions111.16.0

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-120
    Buffer Copy Without Checking SizeMITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

References

Frequently Asked Questions

What is CVE-2021-3711?
SM2 Decryption Buffer Overflow. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.8/10).
How do I check if my project is affected by CVE-2021-3711?
CVE-2021-3711 affects openssl-src. It has a 88.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2021-3711 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
9.8

Maximum impact if exploited, often with little effort or access required.

EPSS Score (30-day exploit probability)
88.58%
EPSS percentile: 99.9

This places it in the top 5% of EPSS-scored vulnerabilities — 99.9% of tracked vulnerabilities score at or below it, so it is far more likely to be exploited than nearly all other tracked vulnerabilities.

Also Known As

GHSA-5ww6-px42-wc85
RUSTSEC-2021-0097

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Cargo.lock