GRC Careers

HomeResourcesJSON Web Tokens (JWT)

CS-067 · API Security

JSON Web Tokens (JWT)

A compact, signed way to carry identity and claims between services, and how to use it safely.

Executive Summary

A JSON Web Token, or JWT, is a compact, digitally signed container that carries identity and claims between parties in a way each side can verify. It lets a server confirm who a caller is without storing session state, which makes it popular for APIs and single sign-on. The security of a JWT depends entirely on validating its signature, its claims, and its lifetime correctly on every use.

What It Is

A JWT is a string made of three parts joined by dots: a header describing the token type and signing algorithm, a payload of claims such as the subject, issuer, audience, and expiration time, and a signature. The header and payload are encoded, not encrypted, so anyone can read them; the signature is what makes the token trustworthy, because it proves the token was issued by a party holding the signing key and has not been altered. JWTs are commonly used as access tokens and identity tokens in modern authentication flows. Because the token itself carries the claims, a server can verify a caller by checking the signature and the claims rather than looking up a session in a database, which is why JWTs are often called stateless.

Why It Matters

JWTs sit at the center of authentication for a large share of modern web and mobile applications, so a mistake in how they are validated can undermine an entire system. If a server accepts a token without properly checking the signature, the algorithm, the issuer, the audience, and the expiration, an attacker may be able to present a forged or stale token and impersonate any user. Because the payload is readable by anyone, developers who mistake encoding for encryption may place sensitive data in the token by accident. For engineers, understanding JWT validation is one of the highest-leverage security skills, because it is both widely used and frequently implemented incorrectly.

How It Works

An identity provider or authentication service creates a JWT, signs it with a secret key or a private key, and returns it to the client. The client presents the token on later requests, typically in an authorization header. The server verifies the token by checking the signature against the expected key, confirming the algorithm matches what it expects, and validating the standard claims: that the token has not expired, was issued by the trusted issuer, and is intended for this audience. Only after all of these pass does the server trust the claims inside. Signatures can use a shared secret or a public and private key pair; with a key pair, services can verify tokens using a public key without ever holding the signing key. Tokens should be short-lived, and longer sessions should use a separate refresh mechanism rather than one long-lived token.

Architecture Diagram

Auth service issues and signs the tokenClient stores the tokenClient presents it on each requestServer verifies signature and algorithmServer validates issuer, audience, and expiration
A JWT is issued and signed once, then verified on every request by checking its signature and claims.

Visual Workflow

Issue tokens only from a trusted authentication service using a strong signing key.Choose a specific signing algorithm and reject tokens that use any other, including none.Verify the signature on every request against the expected key before trusting any claim.Validate the standard claims: expiration, issuer, and audience.Keep tokens short-lived and use a separate refresh flow for longer sessions.Never place secrets in the payload, since it is only encoded and readable by anyone.

Common Attacks

Common Mistakes

Best Practices

Quick Checklist

Recommended Tools

JWT verification library
Validates signature, algorithm, and standard claims in code
Identity provider
Issues and signs tokens and publishes verification keys
Token inspection tool
Decodes a token for debugging without exposing it in production
Key management service
Stores and rotates signing keys securely

Industry Standards

JSON Web Token (RFC 7519)
Defines the JWT structure and standard claims
JSON Web Signature (JWS)
Defines how tokens are signed and verified
OWASP JSON Web Token Cheat Sheet guidance
Practical validation and handling recommendations

Career Relevance

JWT handling is a daily concern for backend engineers, application security engineers, and API security engineers, who issue, validate, and troubleshoot tokens. Security engineers and penetration testers routinely test JWT implementations for the well-known validation flaws, and identity and AI governance professionals need to understand tokens because they underpin access to modern APIs and AI services.

Interview Questions

Related Certifications

OWASP-aligned application security training GIAC Web Application Penetration Tester (GWAPT) CompTIA Security+ (foundational)

Further Reading

Key Takeaways

Download PDFDownload PNG

FAQ

Is a JWT encrypted?

By default, no. A standard signed JWT is only encoded, so anyone can read the header and payload. The signature protects against tampering, not disclosure. If you need confidentiality, you must use an encrypted token or avoid placing sensitive data in it.

What is the none algorithm attack?

Some libraries once honored a token that declared its algorithm as none, meaning no signature check. An attacker could forge a token and set that algorithm to bypass verification. The defense is to pin the expected algorithm on the server and reject anything else.

How do I handle logout with stateless tokens?

Because JWTs are self-contained, a signed token remains valid until it expires. Use short lifetimes plus a revocable refresh mechanism, or maintain a server-side denylist for tokens that must be invalidated immediately.

Get all 116 reference sheets
The complete AGJ Cybersecurity Professional Reference Library, print-ready PDFs and PNGs.
Browse the library

Related Careers

Related certifications

OWASP-aligned application security trainingGIAC Web Application Penetration Tester (GWAPT)CompTIA Security+ (foundational)

Current openings

Live openings appear on the web version. Browse the job board for current GRC and security roles.
Browse all jobs

Suggested learning path

  1. Ground the basics with CS-001 Cybersecurity
  2. Study this sheet: JSON Web Tokens (JWT)
  3. Go deeper: REST API Security
  4. Go deeper: OAuth 2.0
  5. Validate it: work toward OWASP-aligned application security training
  6. Find the role: browse current openings

Related sheets

More in API Security

Share this LinkedIn Facebook X Email