Hardcoded JWT signing key (ARCH3137)
هذا المحتوى غير متوفر بلغتك بعد.
Key typescript.security.hardcoded-jwt-signing-key · Severity error · Category security · CWE CWE-321
Embedding a JWT/HMAC signing key as a literal in source compromises token integrity once the source leaks. Read the key from configuration or a secrets manager.
Incorrect
Section titled “Incorrect”import jwt from "jsonwebtoken";
const token = jwt.sign({ sub: user.id }, "super-secret-key-123");Correct
Section titled “Correct”import jwt from "jsonwebtoken";
const secret = process.env.JWT_SIGNING_KEY!;const token = jwt.sign({ sub: user.id }, secret);Load the signing key from an environment variable or secrets manager; never keep it as a literal in source.