Patchfirst
CVE-2021-3711 EPSS 87.8%

SM2 Decryption Buffer Overflow

OpenSSL · OpenSSL

Summary

The flaw is a heap buffer overflow in OpenSSL's SM2 decryption code, reached through the EVP_PKEY_decrypt() API, where the size calculated for the first call can be smaller than what the second call needs. An attacker who can get an application to decrypt attacker-supplied SM2 content can overflow the caller's buffer by up to 62 bytes, which can alter adjacent data or crash the application, depending on how the application allocates and uses that buffer.

Official description · CVE.org

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).

Breakdown
21.3 / 100
Exploited
Not confirmed
Reports
0
Tactics
0/15

Disclosed on 24 Aug 2021. No public exploit code or confirmed exploitation is recorded.

techniques

No techniques linked

No ATT&CK techniques are linked to this CVE yet. MITRE CTID has not mapped it, and no report passage in the corpus ties it to a technique.

Am I affected? What do I upgrade to?

From GitHub Security Advisories and OSV

1 package in 1 ecosystem. Main package: openssl-src.

Upgrade to 111.25.0 or later

Fixes this CVE and 3 other known vulnerabilities in this package (CVE-2021-3449, CVE-2022-0778, +1).

Cargocargo update -p openssl-src --precise 111.25.0

First fixed in 111.16.0 for CVE-2021-3711.

Affected versions

If you runUpgrade to
All versions before 111.16.0111.25.0first fix for this CVE: 111.16.0

“Up to” means the second version is the fix and is not affected.

Check your lockfile against all CVEs

What security researchers reported

Not named in any threat report yet

Also mentioned in 3 community threat pulses (AlienVault OTX)

Weaker evidence

Pulses are indicator collections that anyone can publish. A mention is not confirmation of exploitation.

References

17 links, grouped by NVD tag
↑ ↓ chooseEnter openEsc close