← 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?
- A.Use a longer payload
- B.Only accept an explicit allow-list of algorithms when verifying
- C.Encode the token twice
- 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 →