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 package | Versions | Reported by |
|---|---|---|
| OpenSSL OpenSSL | Fixed in OpenSSL 1.1.1l (Affected 1.1.1-1.1.1k), from 1.1.1 before 1.1.1l | CVE List, NVD |
| openssl-src (crates.io) | before 111.16.0, from 0.0.0-0 before 111.16.0 | GitHub Advisory Database, RustSec Advisory Database |
| debian debian_linux | 10.0, 11.0 | NVD |
| netapp active_iq_unified_manager | Not specified | NVD |
| netapp clustered_data_ontap | Not specified | NVD |
| netapp clustered_data_ontap_antivirus_connector | Not specified | NVD |
| netapp e-series_santricity_os_controller | from 11.0 up to 11.50.2 | NVD |
| netapp hci_management_node | Not specified | NVD |
| netapp manageability_software_development_kit | Not specified | NVD |
| netapp oncommand_insight | Not specified | NVD |
| netapp oncommand_workflow_automation | Not specified | NVD |
| netapp santricity_smi-s_provider | Not specified | NVD |
| netapp snapcenter | Not specified | NVD |
| netapp solidfire | Not specified | NVD |
| netapp storage_encryption | Not specified | NVD |
| oracle communications_cloud_native_core_security_edge_protection_proxy | 1.7.0 | NVD |
| oracle communications_cloud_native_core_unified_data_repository | 1.15.0 | NVD |
| oracle communications_session_border_controller | 8.4, 9.0 | NVD |
| oracle communications_unified_session_manager | 8.2.5, 8.4.5 | NVD |
| oracle enterprise_communications_broker | 3.2.0, 3.3.0 | NVD |
| oracle enterprise_session_border_controller | 8.4, 9.0 | NVD |
| oracle essbase | before 11.1.2.4.47, from 21.1 before 21.3 | NVD |
| oracle health_sciences_inform_publisher | 6.2.1.1, 6.3.1.1 | NVD |
| oracle jd_edwards_enterpriseone_tools | before 9.2.6.3 | NVD |
| oracle jd_edwards_world_security | a9.4 | NVD |
| oracle mysql_connectors | up to 8.0.27 | NVD |
| oracle mysql_enterprise_monitor | up to 8.0.25 | NVD |
| oracle mysql_server | from 5.7.0 up to 5.7.35, from 8.0.0 up to 8.0.26 | NVD |
| oracle peoplesoft_enterprise_peopletools | 8.57, 8.58, 8.59 | NVD |
| oracle zfs_storage_appliance_kit | 8.8 | NVD |
| tenable nessus_network_monitor | up to 5.13.1 | NVD |
| tenable tenable.sc | from 5.16.0 up to 5.19.1 | NVD |
All scores
| GitHub | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| RustSec Advisory Database | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.5high CVSS:2.0 | AV:N/AC:L/Au:N/C:P/I:P/A:P |
Classification
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
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-3711 changed 2026-10-08 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5ww6-px42-wc85 changed 2024-06-24 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2021-0097 changed 2023-11-08 | CC0-1.0 |
| NVD | CVE-2021-3711 changed 2026-10-08 | Public domain |