Security rules
NGB090: Signature verification result ignored
Reports signature / MAC verification calls whose boolean result is never used: crypto.subtle.verify() (awaited or not), Node crypto.verify() and crypto.Verify#verify() (from createVerify()), when the call is an expression statement, discarded with void, stored in a variable that is never read, or followed by a .then() callback that ignores its argument..
| Property | Value |
|---|---|
| Rule ID | NGB090 |
| Category | Cryptography |
| Default severity | high |
| CWE | CWE-347, CWE-252 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports signature / MAC verification calls whose boolean result is never used: crypto.subtle.verify() (awaited or not), Node crypto.verify() and crypto.Verify#verify() (from createVerify()), when the call is an expression statement, discarded with void, stored in a variable that is never read, or followed by a .then() callback that ignores its argument.
Why it matters
Unlike libraries that throw on a bad signature, these APIs only return false. Calling them without checking the result looks like verification in code review but accepts every forged message, token, license or webhook — the same as not verifying at all.
Detection behavior and supported patterns
await crypto.subtle.verify(alg, key, sig, data);as a statement (also withoutawait, or withvoid)const ok = await crypto.subtle.verify(…)whereokis never readcrypto.verify('sha256', data, key, sig);(sync form) andcreateVerify('sha256').update(data).verify(key, sig);/verifier.verify(key, sig);as statementscrypto.subtle.verify(…).then(() => …)with a callback that takes no parameter
Example
await crypto.subtle.verify('HMAC', key, signature, payload);return JSON.parse(text);Safer alternative
if (!(await crypto.subtle.verify('HMAC', key, signature, payload))) throw new Error('invalid signature');return JSON.parse(text);Remediation
Branch on the result and reject the input when it is false: if (!(await crypto.subtle.verify(alg, key, sig, data))) throw new Error("invalid signature");.
False-positive considerations
- Verification run only for timing or side effects (benchmarks) is reported; such code should not live in production paths.
Known limitations
- A result that is read but compared incorrectly (
if (ok !== undefined)) is not detected. crypto.verify()with a callback reports its result through the callback, which is not analyzed.- JWT / JOSE libraries (which throw on failure) are not in scope.
References
Run it
ngbastion explain NGB090