JSON Web Token meaning, in plain words

A JWT is a compact document carrying claims such as who the user is and when it expires. How signing differs from encryption and what OWASP says to verify.

Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated

A JWT is a document that makes proof of login portable. The name is short for JSON Web Token, and RFC 7519 defines it as a compact representation of claims, which can also be put in a URL, for passing between two parties. A claim is a statement such as who this user is and until when it is valid.

How does a JWT work?

Imagine a certificate stamped with the issuer's seal. It carries a name and an expiry date, and the person who receives it can tell from the seal that the contents have not been rewritten. A JWT is also made of its statements and a signature.

RFC 7519 lists two ways to protect the statements. The signed format (JWS) attaches a digital signature or an authentication code to the statements. The encrypted format (JWE) encrypts the statements themselves. When both are used, signing first and then encrypting is the usual way.

In OpenID Connect, the ID token that conveys the result of login takes the form of a JWT. Pitfalls in implementation are set out in JWT implementation flaws. For help designing verification, contact us.

Why does a JWT matter?

It is convenient, but if mishandled it accepts forgeries and mix-ups. OWASP's REST Security Cheat Sheet lists these points for verifying a JWT.

  • Do not accept an unsigned JWT. Detect tampering by a signature or authentication code.
  • Decide the algorithm used for verification in server-side settings, not by what the JWT header says.
  • Check the issuer (iss), the audience (aud), and the expiry (exp).
  • When revocation is needed, prepare a deny list that uses the JWT's ID (jti).

Another caution is that the contents can be seen. RFC 7519 asks for measures against leaks when a JWT includes information concerning privacy. The methods are using an encrypted JWT, sending over an encrypted channel, or not putting it in at all.

That it stays valid until it expires is also easy to overlook. OWASP says that because a JWT is valid until its expiry, in cases such as logout you can revoke it with the deny list described above.

Related terms

  • Access token: a temporary pass issued after login
  • Session: the series of usage from login to the end
  • OpenID Connect: a mechanism that does the identity check for login on top of OAuth 2.0
  • OAuth: a mechanism for giving another app permission without handing over the password

Frequently asked questions

Can other people see the contents of a JWT?

The signed format is for detecting tampering and does not hide the contents. RFC 7519 asks that, when information concerning privacy is included, an encrypted JWT or an encrypted channel be used. Not putting it in is the simplest countermeasure.

Can a JWT be revoked at any time after it is issued?

Not at any time. OWASP says a JWT is valid until it expires. When you want to invalidate one, as at logout, it gives the method of preparing a deny list that uses the JWT's ID.

Next step

Pitfalls in JWT implementation are in JWT implementation flaws. The free URL check shows only what is visible from outside, and for the design of verification, contact us.

Frequently asked questions

Can other people see the contents of a JWT?

The signed format is for detecting tampering and does not hide the contents. RFC 7519 asks that, when information concerning privacy is included, an encrypted JWT or an encrypted channel be used. Not putting it in is the simplest countermeasure.

Can a JWT be revoked at any time after it is issued?

Not at any time. OWASP says a JWT is valid until it expires. When you want to invalidate one, as at logout, it gives the method of preparing a deny list that uses the JWT's ID.

See what an attacker can see, today

The free URL check returns a grade in under a minute. For costs and next steps, book a free consultation.