Interview Prep/DevSecOps/Vulnerability Management and OWASP

Your Node.js service uses JWTs, and a tester forged a token with `"alg": "none"`. How do you fix it?

IntermediateScenarioVulnerability Management and OWASP
Answer

Situation read → The verification code accepted whatever algorithm the token declared. Anyone can mint admin tokens.

What I'd do →

  1. Pin allowed algorithms in verification:
    jwt.verify(token, publicKey, { algorithms: ['RS256'], issuer: 'https://auth.example.com', audience: 'api' });
    
  2. Upgrade the JWT library; current versions reject none by default.
  3. Validate exp, iss and aud, and keep access tokens short-lived (5–15 minutes).
  4. Rotate the signing key and invalidate active sessions if forged tokens were used.
  5. Look for the related key-confusion bug (RS256 public key used as HS256 secret).

Why → Never let the token tell the server how to verify it.

Interview tip → "Algorithm allowlist" is the key phrase.

All DevSecOps questions Roadmap: Security in the pipeline

More on Vulnerability Management and OWASP