Build a JWT inspector

A JWT is three base64url blocks joined by dots, and only the last one protects anything. This set covers reading the claims with no key, adding the padding that base64url drops, and why a verifier has to fix the algorithm itself instead of trusting the header.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 Why can you read a JWT payload with no key at all?
2 Why does the payload segment need = padding before base64 -d, when the header does not?
3 A token arrives with a header that reads {"alg":"none"}. What is the danger?
4 What is the difference between decoding a JWT and verifying it?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Verify a token signature for real

The jwt.sh you finished is saved next to you. This decodes the sample token and then checks its HS256 signature against the secret it was signed with. Paste the last few lines.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

bash jwt.sh --secret termux-demo-secret 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ik1pcmEiLCJhZG1pbiI6ZmFsc2UsImlhdCI6MTc1MDAwMDAwMH0.LEqKJqaAnM91I32zKqTjqgBXHshwwisBvLXB77iDaXY'
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson