HIGH 7.5

CVE-2026-12340: WolfSSL SM2 Out-of-Bounds Heap Read – Certificate DoS

A flaw in WolfSSL's SM2/SM3 certificate signature verification can cause the application to crash when processing specially crafted certificates. The vulnerability occurs because the code reads 65 bytes from a public key without first verifying the key is long enough, potentially accessing memory beyond allocated bounds. This affects only builds compiled with SM2 support enabled. There is no data corruption or information disclosure risk—the primary impact is denial of service through application crashes.

Source data · NVD / CISA · public domain

CVSS
3.1 · 7.5 HIGH · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weaknesses (CWE)
CWE-125
Affected products
1 configuration(s)
Published / Modified
2026-06-25 / 2026-06-26

NVD description (verbatim)

Out-of-bounds heap read during SM2/SM3 certificate signature verification. When parsing a certificate with an SM3wSM2 signature, the Subject Key Identifier computation reads the trailing 65 bytes of the public key without checking that the key is at least that long. A public key shorter than 65 bytes results in an out-of-bounds heap read, leading to a potential crash (denial of service); there is no out-of-bounds write. Note this only affects builds with SM2 support (--enable-sm2 or --enable-all).

2 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

CVE-2026-12340 is an out-of-bounds heap read in WolfSSL affecting Subject Key Identifier (SKI) computation during SM2/SM3 certificate signature verification. When a certificate with an SM3wSM2 signature is parsed, the code unconditionally reads the trailing 65 bytes of the subject's public key without length validation. If the public key is shorter than 65 bytes, the read extends past the allocated heap buffer. The vulnerability is present only in builds configured with SM2 support (via --enable-sm2 or --enable-all flags). No heap write occurs, limiting the attack surface to denial of service and potential information disclosure of adjacent heap memory.

Business impact

Organizations using WolfSSL with SM2 enabled in certificate validation or TLS server roles face availability risk. An attacker can send a malformed certificate with a truncated SM2 public key, triggering an out-of-bounds read that crashes the application. This leads to service interruption and potential cascading failures in dependent systems. The impact is most severe in automated certificate processing pipelines, IoT deployments, and edge devices where WolfSSL is embedded without extensive input sanitization upstream.

Affected systems

WolfSSL versions prior to remediation are affected when built with SM2 support. This includes any deployment using --enable-sm2 or --enable-all compile options. The vulnerability does not affect builds compiled without SM2 support, making scope-limited in organizations using WolfSSL primarily for legacy cryptography or non-SM2 use cases. SM2 adoption is concentrated in deployments targeting Chinese regulatory requirements and PKI ecosystems.

Exploitability

Exploitation requires network access to send a certificate with a malformed SM2 public key to a vulnerable service. No authentication, user interaction, or special client-side conditions are required. The attack surface is present whenever WolfSSL processes untrusted certificates—including TLS handshakes, OCSP responders, or certificate chain validation in automated systems. The low barrier to exploitation is offset by the constraint that only SM2-enabled builds are vulnerable and SM2 adoption remains niche outside specific regional and regulatory contexts.

Remediation

Update WolfSSL to a patched version that includes bounds checking prior to reading the public key during SKI computation. The fix validates that the SM2 public key length meets the 65-byte minimum before accessing those bytes. Organizations should verify patch availability from WolfSSL's security advisories and test in non-production environments before deployment. For builds not using SM2, no action is required beyond standard patching practices.

Patch guidance

Consult the WolfSSL security advisory and release notes for the specific patched version addressing CVE-2026-12340. Apply patches to all WolfSSL instances in certificate validation paths, particularly those configured with SM2 support. Verify that compiled binaries include the SM2 fix and are built from patched source. Perform integration testing with existing certificate chains to confirm no regression in legitimate SM2 or other signature verification workflows. Organizations should document which deployments use SM2 to prioritize patching where the vulnerability is actually present.

Detection guidance

Monitor for application crashes or service restarts correlated with certificate processing, especially in environments processing certificates from external sources. Review logs for errors during certificate parsing or Subject Key Identifier computation. Check WolfSSL build configurations across your infrastructure to identify which systems have SM2 enabled via --enable-sm2 or --enable-all. Implement certificate validation in network IDS/IPS to flag certificates with truncated SM2 public keys (length <65 bytes). Heap memory corruption detection tools and sanitizers (AddressSanitizer, Valgrind) will flag the out-of-bounds read if deployed in development or testing.

Why prioritize this

This vulnerability warrants HIGH priority for organizations with SM2-enabled WolfSSL deployments in certificate validation or public-facing TLS roles. The low complexity of exploitation and direct path from malformed certificate to denial of service justify urgent patching in affected systems. However, organizations without SM2 support can safely defer this update. The lack of data breach or integrity risk (no write, no information leak) means prioritization should reflect service availability criticality rather than data sensitivity.

Risk score, explained

CVSS 3.1 score of 7.5 (HIGH) reflects network accessibility, low attack complexity, no privileges required, and high availability impact (denial of service). The absence of confidentiality and integrity impacts prevents a Critical rating. The constraint that only SM2-enabled builds are vulnerable is a deployment-time decision rather than a network-exploitable bypass, so the score does not apply a population adjustment. Real-world risk depends heavily on whether SM2 is actually enabled in your infrastructure and whether untrusted certificate input reaches vulnerable code paths.

Frequently asked questions

Does this affect all WolfSSL installations?

No. The vulnerability only affects WolfSSL compiled with SM2 support enabled (--enable-sm2 or --enable-all). Builds without SM2 are unaffected. Check your build configuration and documentation to confirm whether SM2 is active.

What happens when this vulnerability is exploited?

An attacker sends a certificate with a truncated SM2 public key, causing WolfSSL to read beyond the allocated heap buffer. This typically results in an application crash or denial of service. There is no data breach or memory corruption that could lead to code execution.

Where is SM2 typically used?

SM2 is a cryptographic standard mandated in China's regulatory and PKI frameworks. Adoption is concentrated in deployments targeting Chinese compliance requirements or those using cryptography approved by OSCCA. Many organizations outside these contexts do not enable SM2.

What should we do if we use WolfSSL but are unsure if SM2 is enabled?

Review your WolfSSL build configuration, installation documentation, or contact your vendor/supplier. Compile WolfSSL with verbose configure output to confirm flags. Once you establish whether SM2 is present, apply patches to vulnerable systems and leave unaffected systems on their normal patch schedule.

This analysis is provided for informational and educational purposes. Patch availability, affected versions, and remediation steps must be verified against official WolfSSL security advisories and vendor guidance. Organizations should conduct their own risk assessment based on their specific WolfSSL configurations, deployment contexts, and certificate processing workflows. No guarantee is made regarding the accuracy or completeness of this information as applied to your environment. Consult security professionals and vendor documentation before implementing mitigations. Source: NVD (public-domain), retrieved 2026-08-04. Analysis generated by SEC.co (claude-haiku-4-5).