Skip to content

JWT No Validation (ARCH6126)

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

Decoding a JWT without signature verification (verify: false or the none algorithm) lets attackers forge claims. Always verify the signature and algorithm.

require "jwt"
payload, = JWT.decode(token, nil, false)
user_id = payload["sub"]
require "jwt"
secret = ENV.fetch("JWT_SIGNING_KEY")
payload, = JWT.decode(token, secret, true, algorithm: "HS256")
user_id = payload["sub"]

Call JWT.decode with verify = true and an explicit algorithm; never skip the signature.