VNX-347: Improper Verification of Cryptographic Signature
A signature or MAC check whose result is discarded, or whose failure is caught and swallowed, so forged data is processed as genuine. Java, Go, JavaScript/TypeScript and Python.
| Field | Value |
|---|---|
| Rule ID | VNX-347 |
| Severity | High |
| SARIF level | error |
| Kind | sast |
| Languages | Go, Java, JavaScript / TypeScript, Python |
| CWE | CWE-347 |
| CAPEC | CAPEC-66 |
| ATT&CK | T1190 |
| CWSS vector | CWSS:1.0/TI:H/AP:A/AL:A/IC:N/FC:LT/RP:N/RL:A/AV:I/AS:N/IN:A/SC:A/BI:H/DI:H/EX:H/EC:N/P:H |
| Tags | signature crypto cwe-347 |
| Source | internal/sast/rules/vnx-347.rego |
Overview
VNX-347 maps to CWE-347: Improper Verification of Cryptographic Signature. It reports code that runs a signature or MAC check and then ignores the outcome:
- Result discarded (the call is a bare statement): Java
java.security.Signature.verify(); Goed25519.Verify,ecdsa.Verify/VerifyASN1,hmac.Equal,subtle.ConstantTimeCompare,rsa.VerifyPKCS1v15/VerifyPSS(also assigned to_); Node.jsverify()on acreateVerify()object,crypto.verify()without a callback,crypto.timingSafeEqual(),crypto.subtle.verify(), the jws package’s booleanjws.verify(); Pythonhmac.compare_digest(). - Failure swallowed: Python
except InvalidSignature/BadSignature/BadSignatureError/InvalidSignatureError(or a bare/Exceptionhandler around a.verify()statement) whose body is onlypass,...or a log call; Javacatch (SignatureException | SignatureVerificationException | InvalidSignatureException | JWTVerificationException | JwtException ...)(orExceptionaround a.verify()statement) whose block is empty or only logs.
Why This Matters
A verification that nobody checks is no verification: a forged update, webhook, licence or token is accepted exactly as a genuine one. The bug survives review because the verify call is visibly there.
Not reported: a Python handler whose try body only assigns the verified value to names set to None/False/empty just above it (user_id = None; try: user_id = s.loads(v) except BadSignature: pass fails closed; a default holding the unverified input is still reported); results that are tested, assigned, returned or passed on (including an assignment split over two lines); calls that throw on failure (jsonwebtoken jwt.verify, auth0 JWTVerifier.verify) outside a swallowing handler; crypto.verify with a callback; handlers that raise, return or rethrow; empty catches around code that verifies nothing; comments and string literals. Disabled TLS certificate validation is VNX-CRYPTO-005’s concern and disabled JWT verification VNX-JWT-001’s.
What Gets Flagged
sig.update(payload);
sig.verify(sigBytes);
return payload;
ed25519.Verify(pub, body, sig)
_ = rsa.VerifyPKCS1v15(pub, crypto.SHA256, digest, sig)
verifier.verify(publicKey, signature, "base64");
crypto.timingSafeEqual(digest, Buffer.from(req.get("X-Signature"), "hex"));
try:
public_key.verify(signature, blob)
except InvalidSignature:
pass
Remediation
- Test the result and stop on failure:
if (!sig.verify(s)) throw ...,if !ed25519.Verify(...) { return err },if not hmac.compare_digest(...): abort(401). - In a handler for a signature failure, reject the input: raise, return an error, or abort the request.
References
Suppressing this rule
Put a nosec comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file’s language (#, //, -- or ;):
# nosec vnx-347
// nosec vnx-347
Or record an ignore rule: vulnetix ignore add --rule vnx-347 --reason "...". See Suppressing findings.