Intel

AIKIDO-2026-139254

sm-crypto is vulnerable to NULL Pointer Dereference

NULL Pointer DereferenceGHSA-xj7m-r97m-9h7w Published 2 days ago

53

Medium Risk

This Affects:

JSsm-crypto
0.0.1 - 0.5.3
Fixed in 0.5.4
Are you affected? Scan for Free

TL;DR

The SM2 signature verification function in sm-crypto hashes the message together with the caller-supplied public key before it validates that key. doVerifySignature calls getHash, which passes the public key to decodePointHex and dereferences the returned point without a null check, so the guard that would reject a malformed key runs too late. When verification is called with an unparseable public key the decode returns null and the code throws a TypeError instead of returning false, so callers that expect a boolean can crash. The fix moves the public key validity check ahead of the hashing step so a malformed key returns false.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and you pass an externally influenced or untrusted public key into SM2 signature verification and treat the result as a boolean.

Background info

sm-crypto is vulnerable to NULL Pointer Dereference in versions 0.0.1 - 0.5.3.

How to fix this

Upgrade the sm-crypto library to the patch version.