/

CVE-2026-22699

Severity:

HIGH RISK

(7.5)

Improper Input Validation in RustCrypto Elliptic Curves SM2

CVE-2026-22699

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20

Impact:

Denial of Service via Panic in Cryptographic Decryption Path

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

RustCrypto Elliptic Curves versions 0.14.0-pre.0 and 0.14.0-rc.0 contain an input validation flaw in the SM2 public key encryption (PKE) decryption path that can cause the library to panic when processing malformed points.

An attacker who can supply crafted SM2 ciphertexts with syntactically valid but off-curve C1 points can trigger a panic via an unchecked unwrap, leading to denial of service in applications using the library.

Affected context

This vulnerability occurs in applications that:

  • Use the RustCrypto Elliptic Curves crate with SM2 PKE support enabled
  • Are built on affected pre-release versions (0.14.0-pre.0 or 0.14.0-rc.0)
  • Accept or process untrusted SM2 ciphertexts from external sources

The issue manifests when the decryption routine decodes the C1 elliptic-curve point from input and assumes it is valid without fully handling the case where it does not lie on the SM2 curve.

Exploit preconditions

  • Attack surface: SM2 PKE decryption API exposed by an application (e.g., network protocols, file formats, or message-based systems using SM2 encryption).
  • Required access: Ability to submit or influence SM2 ciphertexts processed by the vulnerable decryption routine.
  • Trigger point: Passing a ciphertext whose C1 component encodes coordinates that are syntactically correct but correspond to a point not lying on the SM2 curve.
  • Why exploitation is possible: The code calls AffinePoint::from_encoded_point(&encoded_c1) and directly .unwrap()s the result. When the point is off-curve, the function returns None/CtOption::None; the unchecked unwrap triggers a panic, which can terminate the process or task handling the request.

Why this happens

The bug stems from improper input validation and error handling in the SM2 PKE decryption logic.

Rather than treating the result of AffinePoint::from_encoded_point(&encoded_c1) as fallible and explicitly handling the None case, the code used .unwrap(), implicitly assuming that all syntactically valid encoded points are also valid curve points.

This maps to CWE-20: Improper Input Validation, where external input is not rigorously validated against the domain constraints of the elliptic curve and the potential failure mode of the decoding function is ignored, allowing malformed but syntactically correct data to cause a runtime panic.

Potential impact

  • Remote denial of service by repeatedly triggering panics in services performing SM2 PKE decryption
  • Disruption of cryptographic operations, such as secure messaging or key exchange that rely on SM2 PKE
  • Potential exhaustion of worker threads or processes in multi-tenant or high-load environments due to repeated panics and restarts
  • Reduced availability of APIs, microservices, or systems that depend on the vulnerable library for SM2 cryptography

General mitigation guidance

Effective mitigation focuses on robust input validation and defensive error handling around cryptographic primitives:

  • Treat elliptic-curve point decoding as a fallible operation, explicitly handling the case where decoded points are not on the curve.
  • Avoid using .unwrap() or equivalent unchecked operations on results derived from untrusted or partially trusted input; prefer pattern matching or error propagation.
  • Enforce domain-specific validation for cryptographic inputs, ensuring both syntactic correctness and adherence to curve constraints before use.
  • Design APIs to return structured errors for invalid ciphertexts and ensure calling code can handle these errors without panicking.
  • Run cryptographic services with graceful failure strategies so malformed inputs cannot easily cascade into system-wide outages.

How teams detect issues like this

Organizations can detect this class of issue using several complementary approaches:

  • Static analysis and linters: Configure rules to flag .unwrap()/.expect() calls on data paths influenced by external input, especially around cryptographic operations.
  • Code review practices: During review, scrutinize ECC point decoding and cryptographic parsing for explicit handling of invalid or off-curve inputs; look for unchecked options or results.
  • Fuzz testing: Apply fuzzers to SM2 decryption interfaces with randomly mutated ciphertexts to detect panics or crashes triggered by malformed inputs.
  • Runtime monitoring: Instrument services to log and alert on panics or abnormal termination patterns, especially near cryptographic request handlers.
  • Policy enforcement in CI/CD: Use automated tools or custom scripts in CI to block merges that introduce new unchecked unwraps in security-sensitive components.

Sources

SourceLink
github.comgithub.com/RustCrypto/elliptic-curves/commit/085b7bee647029bd189e1375203418205006bcab
github.comgithub.com/RustCrypto/elliptic-curves/pull/1602
github.comgithub.com/RustCrypto/elliptic-curves/security/advisories/GHSA-78p6-6878-8mj6

Frequently asked

questions

Yes, if the SM2 PKE decryption endpoint is exposed to remote users or untrusted data sources. An attacker who can submit crafted ciphertexts to that endpoint can trigger the panic and cause denial of service.

The attacker only needs the ability to influence or submit SM2 ciphertexts processed by an affected decryption routine. No valid keys or prior authentication are required beyond whatever the application normally requires to send data to the decryption API.

Replace unchecked .unwrap() calls on elliptic-curve point decoding results with explicit error handling. Treat the decoding call as fallible, verify that the point lies on the curve, and return or propagate a structured decryption error instead of panicking.

Adopt defensive coding standards that forbid .unwrap()/.expect() in cryptographic and other security-sensitive paths, enforce systematic input validation for all externally influenced data, and integrate static analysis, fuzzing, and rigorous code review focused on failure handling and robustness of cryptographic code.

Find out what's already
exploitable in your codebase.