Zum Inhalt springen

JWT no validation (ARCH3126)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.security.jwt-no-validation · Severity error · Category security · CWE CWE-347

Decoding a JWT without verifying its signature (decode, verify=false, alg: none) lets attackers freely tamper with token contents. Always verify the signature with the expected algorithm.

import jwt from "jsonwebtoken";
const payload = jwt.decode(token) as { sub: string };
const user = await findUser(payload.sub);
import jwt from "jsonwebtoken";
const payload = jwt.verify(token, publicKey, {
algorithms: ["RS256"],
}) as { sub: string };
const user = await findUser(payload.sub);

Use verify instead of decode; specify allowed algorithms explicitly and never permit none.