CVE-2021-3711
JSON

9.8critical

SM2 Decryption Buffer Overflow

Severity
9.8critical CVSS:3.1 by NVD
Exploit likelihood
88.6% (higher than 99% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
openssl
Also known as
GHSA-5ww6-px42-wc85RUSTSEC-2021-0097

Description

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

Affected

Product or packageVersionsReported by
OpenSSL OpenSSLFixed in OpenSSL 1.1.1l (Affected 1.1.1-1.1.1k), from 1.1.1 before 1.1.1lCVE List, NVD
openssl-src (crates.io)before 111.16.0, from 0.0.0-0 before 111.16.0GitHub Advisory Database, RustSec Advisory Database
debian debian_linux10.0, 11.0NVD
netapp active_iq_unified_managerNot specifiedNVD
netapp clustered_data_ontapNot specifiedNVD
netapp clustered_data_ontap_antivirus_connectorNot specifiedNVD
netapp e-series_santricity_os_controllerfrom 11.0 up to 11.50.2NVD
netapp hci_management_nodeNot specifiedNVD
netapp manageability_software_development_kitNot specifiedNVD
netapp oncommand_insightNot specifiedNVD
netapp oncommand_workflow_automationNot specifiedNVD
netapp santricity_smi-s_providerNot specifiedNVD

All scores

GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
RustSec Advisory Database9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

CWE-120

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.

What each source says

CVE List

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

RustSec Advisory Database

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.

NVD (es)

Para descifrar los datos cifrados de SM2 se espera que una aplicación llame a la función de la API EVP_PKEY_decrypt(). Normalmente, una aplicación llamará a esta función dos veces. La primera vez, al entrar, el parámetro "out" puede ser NULL y, al salir, el parámetro "outlen" se rellena con el tamaño del búfer necesario para contener el texto plano descifrado. La aplicación puede entonces asignar un búfer de tamaño suficiente y llamar de nuevo a EVP_PKEY_decrypt(), pero esta vez pasando un valor no NULL para el parámetro "out". Un bug en la implementación del código de descifrado SM2 significa que el cálculo del tamaño del búfer necesario para mantener el texto plano devuelto por la primera llamada a EVP_PKEY_decrypt() puede ser menor que el tamaño real requerido por la segunda llamada. Esto puede conllevar a un desbordamiento del búfer cuando la aplicación llama a EVP_PKEY_decrypt() por segunda vez con un búfer demasiado pequeño. Un atacante malicioso que sea capaz de presentar el contenido de SM2 para su descifrado a una aplicación podría causar que los datos elegidos por el atacante desborden el búfer hasta un máximo de 62 bytes alterando el contenido de otros datos mantenidos después del búfer, posiblemente cambiando el comportamiento de la aplicación o causando el bloqueo de la misma. La ubicación del búfer depende de la aplicación, pero normalmente se asigna a la pila. Corregido en OpenSSL versión 1.1.1l (Afectada 1.1.1-1.1.1k).

References

https://www.openssl.org/news/secadv/20210824.txtvendor-advisory, web
https://git.openssl.org/gitweb/?p=openssl.git%3Ba=commitdiff%3Bh=59f5e75f3bced8fc0e130d72a3f582cf7b480b46web
https://www.debian.org/security/2021/dsa-4963third-party-advisory, vendor-advisory, web
https://lists.apache.org/thread.html/r18995de860f0e63635f3008fd2a6aca82394249476d21691e7c59c9e%40%3Cdev.tomcat.apache.org%3Emailing-list, web
http://www.openwall.com/lists/oss-security/2021/08/26/2mailing-list, third-party-advisory, web
https://lists.apache.org/thread.html/rad5d9f83f0d11fb3f8bb148d179b8a9ad7c6a17f18d70e5805a713d1%40%3Cdev.tomcat.apache.org%3Emailing-list, web
https://security.netapp.com/advisory/ntap-20210827-0010/third-party-advisory
https://www.oracle.com/security-alerts/cpuoct2021.htmlpatch, third-party-advisory, web
https://www.tenable.com/security/tns-2021-16third-party-advisory, web
https://www.oracle.com/security-alerts/cpujan2022.htmlpatch, third-party-advisory, web
https://security.netapp.com/advisory/ntap-20211022-0003/third-party-advisory
https://www.tenable.com/security/tns-2022-02third-party-advisory, web

Sources

SourceRecordLicence
CVE ListCVE-2021-3711 changed 2026-10-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-5ww6-px42-wc85 changed 2024-06-24CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0097 changed 2023-11-08CC0-1.0
NVDCVE-2021-3711 changed 2026-10-08Public domain