JWT Missing Signing Method Check
JWT keyfunc returns the verification key without asserting the token's signing method, enabling algorithm-confusion attacks (CWE-347).
Standards mapping
- OWASP Top 10
- A02:2021 - Cryptographic Failures
- OWASP ASVS
- V3.5.3 (L1)
Vulnerable vs. safe
return jwt.Parse(tokenStr, func(t *jwt.Token) (interface{}, error) {return jwt.Parse(tokenStr, func(t *jwt.Token) (interface{}, error) {Why it matters & how to fix it
JWT keyfunc returns the verification key without asserting the token's signing method, enabling algorithm-confusion attacks (CWE-347). An attacker can forge a token signed with HMAC using your RSA/EC public key as the secret, or downgrade to 'none'. Inside the keyfunc, verify the concrete algorithm, e.g. `if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, err }`, before returning the key.
References
Rule ID integsec-go-jwt-missing-signing-method-check - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Authentication & SecretsHardcoded JWT Secret
- JavaScript / TypeScript - Authentication & SecretsHardcoded Secret
- JavaScript / TypeScript - Authentication & SecretsInsecure Cookie Flags
- JavaScript / TypeScript - Authentication & SecretsJWT Algorithm None
- JavaScript / TypeScript - Authentication & SecretsJWT Decode Without Verify
- JavaScript / TypeScript - Authentication & SecretsTLS Verification Disabled