Learn Quiz

JWT Quiz

Test your JWT knowledge. — 7 questions

Question 1 of 7 Score: 0

About the JWT Quiz

Test your JWT knowledge. This quiz has 7 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.

The questions follow the material in the JWT Explained guide and the JWT cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.

Questions in this quiz

Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.

1. What are the three parts of a JWT?

  1. Header, body, footer
  2. ID, secret, expiry
  3. Header, payload, signature
  4. Token, claims, hash
Show answer

Answer: C. Header, payload, signature
A JWT is header.payload.signature, each part Base64Url-encoded and separated by dots.

2. What does the exp claim represent?

  1. The signing algorithm
  2. The expiration time as a Unix timestamp
  3. The issuer name
  4. The subject identifier
Show answer

Answer: B. The expiration time as a Unix timestamp
exp is a Unix timestamp. The server must reject the token at or after this time regardless of signature validity.

3. Which algorithm uses asymmetric keys (private key to sign, public key to verify)?

  1. HS256
  2. HS512
  3. RS256
  4. MD5
Show answer

Answer: C. RS256
RS256 is RSA + SHA-256. The private key signs; the public key verifies. HS256 uses a single shared secret (symmetric).

4. Why is alg: none dangerous in a JWT header?

  1. It makes the token larger
  2. It disables the signature so a server that accepts it will trust any forged token
  3. It uses a weaker hash function
  4. It prevents the refresh token from working
Show answer

Answer: B. It disables the signature so a server that accepts it will trust any forged token
alg: none means no signature. An attacker can modify the payload and the server would have no way to detect the tampering.

5. Which claim identifies who the token is about?

  1. iss
  2. aud
  3. jti
  4. sub
Show answer

Answer: D. sub
sub (subject) is the principal the token refers to — typically a user ID. iss is the issuer, aud is the intended audience.

6. Where should JWTs be stored to best protect against XSS attacks?

  1. localStorage
  2. sessionStorage
  3. A JavaScript variable
  4. httpOnly, Secure cookie
Show answer

Answer: D. httpOnly, Secure cookie
httpOnly cookies cannot be read by JavaScript, so an XSS attack cannot steal the token. localStorage is convenient but accessible to any script on the page.

7. Is the JWT payload encrypted by default?

  1. Yes, it is AES-encrypted
  2. Yes, with the signing key
  3. No — it is only Base64Url-encoded and readable by anyone
  4. Only when using RS256
Show answer

Answer: C. No — it is only Base64Url-encoded and readable by anyone
The payload is encoded, not encrypted. Anyone with the token can decode it. Never put passwords or sensitive secrets in the payload.

How to use this quiz

  • Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
  • Note the questions you missed and revisit the matching section of the guide or cheatsheet.
  • Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.

Related