Go Shangmi (Commercial Cryptography) Library
The Go ShangMi (Commercial Cryptography) Library (GMSM) contains a cryptographic vulnerability in the SM9 decryption implementation. The issue stems from a failure to explicitly reject the point at infinity during decryption, allowing an attacker who knows the target user's UID to derive the decryption key material and forge a ciphertext that passes integrity checks. This vulnerability affects the `sm9.Decrypt`, `sm9.DecryptASN1`, and `sm9.UnwrapKey` functions. The root cause is that the implementation only verifies if the elliptic-curve point C1 in the ciphertext is on the curve, but does not explicitly check if it is the point at infinity. An attacker can construct C1 as the point at infinity, causing the bilinear pairing result to degenerate, leading to a predictable constant in the key derivation input. This allows the attacker to forge a ciphertext that decrypts to attacker-chosen plaintext. The vulnerability is not related to confidentiality loss, but to the integrity and authenticity of decrypted data.