sm-crypto is vulnerable to NULL Pointer Dereference
53
Medium Risk
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.
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.
sm-crypto is vulnerable to NULL Pointer Dereference in versions 0.0.1 - 0.5.3.
Upgrade the sm-crypto library to the patch version.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant