The HMAC key passed to JWT.encode / JWT.decode is a hard-coded string literal.
Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.
Why this matters
This key signs and verifies every token: committed to source control it is one search away from compromise, letting an attacker forge a token for any user or role (CWE-798). AI-generated samples inline the secret to make the snippet "just work" and it ships unchanged.
Read the key from the environment or Rails credentials instead: JWT.encode(payload, ENV.fetch('JWT_SECRET'), 'HS256') JWT.decode(token, Rails.application.credentials.jwt_secret, true, { algorithm: 'HS256' })
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.
// oauthlint-disable-next-line auth.ruby.secret.hardcoded-jwt-secret -- <reason>