🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: JWT and API Security: all 10 questions

Quiz: JWT and API Security · Question 3 of 10

How should a server defend against the "alg": "none" attack?

How should a server defend against the "alg": "none" attack?

  1. A.Use a longer payload
  2. B.Only accept an explicit allow-list of algorithms when verifying
  3. C.Encode the token twice
  4. D.Store tokens in localStorage
Answer & explanation

Correct answer: Only accept an explicit allow-list of algorithms when verifying

Never trust the alg in the header; pass algorithms=["HS256"] (or your chosen algorithm) to verify.

Can you get the rest right without peeking?

Take the timed Quiz: JWT and API Security quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →