November 19, 2026
From P4 to P1: Day 21 — JWT Vulnerabilities: Finding Authentication and Authorization Weaknesses
Category: Web Application Security Series: From P4 to P1 — The Bug Hunter’s Journey Topic: JSON Web Token (JWT) Security

By cyb3rD1vvy@
8 min read
1. Introduction
JWTs are everywhere.
Modern web applications use JSON Web Tokens for authentication, session management, API authorization, and communication between services.
But here's the problem: developers sometimes trust token contents without properly validating the signature, use weak signing secrets, or implement algorithms incorrectly.
For bug hunters, these implementation mistakes can create opportunities to identify authentication bypasses, privilege escalation, and unauthorized access.
In this article, we'll explore how JWTs work, common JWT vulnerabilities, practical testing techniques, false positives, and how to write professional vulnerability reports.
2. What Is a JWT?
A JSON Web Token (JWT) is a compact, URL-safe token format used to transfer claims between parties.
A JWT commonly consists of three parts:
HEADER.PAYLOAD.SIGNATUREHEADER.PAYLOAD.SIGNATUREExample:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.
eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciJ9
.
SIGNATUREeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.
eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciJ9
.
SIGNATUREA. Header
The header identifies the token type and signing algorithm.
Example:
{
"alg": "HS256",
"typ": "JWT"
}{
"alg": "HS256",
"typ": "JWT"
}B. Payload
The payload contains claims about the subject or token.
Example:
{
"sub": "123",
"username": "testuser",
"role": "user",
"iat": 1760000000,
"exp": 1760003600
}{
"sub": "123",
"username": "testuser",
"role": "user",
"iat": 1760000000,
"exp": 1760003600
}C. Signature
The signature is used to verify that the token has not been modified and was produced by a party possessing the appropriate signing key.
Important: A normal signed JWT is not encrypted. Anyone who obtains it can generally decode its header and payload. Never place passwords, secrets, or sensitive personal information in an ordinary JWT payload.
3. How JWT Authentication Works
A simplified authentication flow:
- A user submits login credentials.
- The application validates the credentials.
- The server creates a JWT.
- The client stores the token.
- The client sends the token with subsequent requests.
- The server validates the token and its claims.
- The application makes an authorization decision.
Example request:
GET /api/account HTTP/1.1
Host: example.com
Authorization: Bearer YOUR_JWT_TOKENGET /api/account HTTP/1.1
Host: example.com
Authorization: Bearer YOUR_JWT_TOKENThe server should validate the signature, allowed algorithm, expiration, issuer, audience, and other relevant claims before trusting the token.
A valid signature alone does not mean the user is authorized to access every resource.
4. Common JWT Vulnerabilities
Let's explore the weaknesses bug hunters should understand.
4.1 Algorithm Confusion
Algorithm confusion occurs when a JWT implementation incorrectly handles the algorithm specified in the token header.
For example, an application might expect an asymmetric algorithm such as RS256 but incorrectly accept a token using a symmetric algorithm such as HS256.
If the implementation mistakenly uses the public key as an HMAC secret, an attacker may be able to forge a valid signature.
What to investigate:
- Whether the server enforces a fixed algorithm.
- Whether token verification follows the expected key type.
- Whether unexpected algorithms are rejected.
- Whether different endpoints enforce consistent verification rules.
Do not assume that changing the alg field automatically creates a vulnerability. You must demonstrate successful unauthorized token acceptance.
4.2 Weak JWT Signing Secret
Some applications use weak or predictable secrets to sign HS256 tokens.
If the signing secret is weak, an attacker who obtains a token may be able to guess the secret and generate a valid signature.
Example of an insecure secret:
secret123
password
adminsecret123
password
adminA properly generated high-entropy secret is significantly harder to guess.
What to investigate:
- Whether the signing secret is predictable.
- Whether exposed configuration files reveal signing material.
- Whether the application uses a sufficiently strong secret.
- Whether a recovered secret actually permits unauthorized token creation.
A weak-looking secret is not enough to establish impact. Demonstrate that it enables a meaningful attack within the authorized scope.
4.3 Improper Signature Validation
One of the most serious JWT implementation mistakes is accepting tokens without correctly validating their signatures.
If a server trusts modified claims without verifying the signature, an attacker may be able to manipulate token contents.
For example, the original payload might contain:
{
"sub": "123",
"role": "user"
}{
"sub": "123",
"role": "user"
}A modified payload might contain:
{
"sub": "123",
"role": "admin"
}{
"sub": "123",
"role": "admin"
}The modified payload must not be trusted unless its signature is valid and the user is authorized for the requested action.
What to investigate:
- Whether unsigned tokens are rejected.
- Whether invalid signatures are rejected.
- Whether modified claims are accepted.
- Whether authorization decisions rely on unverified token data.
4.4 JWT Expiration Validation Issues
JWTs often use the exp claim to define when a token expires.
Example:
{
"sub": "123",
"exp": 1760003600
}{
"sub": "123",
"exp": 1760003600
}Potential weaknesses include:
- Expired tokens still being accepted
- Missing expiration claims where expiration is required.
- Inconsistent expiration enforcement across endpoints.
- Incorrect handling of token lifetime and clock skew.
A token without an exp claim is not automatically vulnerable if the application has a different, intentional token-lifetime policy. Validate the application's security requirements and actual behavior.
4.5 Sensitive Information in JWT Payload
JWT payloads are commonly Base64URL-encoded, not encrypted.
An application may accidentally include:
- Email addresses
- Internal user identifiers
- Account metadata
- Permission information
- Internal system details
- Sensitive application data
The exposure depends on whether the token is accessible to an unintended party and what information it contains.
Do not report ordinary, intentionally disclosed claims as a vulnerability without demonstrating meaningful security impact.
4.6 Missing Issuer and Audience Validation
JWTs may contain claims such as:
{
"iss": "https://auth.example.com",
"aud": "example-api",
"sub": "123"
}{
"iss": "https://auth.example.com",
"aud": "example-api",
"sub": "123"
}The server should validate that the token was issued by a trusted issuer and intended for the receiving service.
Weak validation can allow a token issued for one application or service to be accepted by another.
Investigate whether:
- The issuer is checked.
- The audience is checked.
- Tokens are accepted by unintended services.
- Different applications share token validation rules incorrectly.
4.7 Key ID (kid) Handling Issues
The JWT header may contain a kid claim identifying the signing key.
Example:
{
"alg": "RS256",
"typ": "JWT",
"kid": "key-2026"
}{
"alg": "RS256",
"typ": "JWT",
"kid": "key-2026"
}Applications may introduce weaknesses if they use the kid value unsafely when selecting or retrieving keys.
Look for:
- Untrusted key identifiers used in file paths.
- Unsafe external key retrieval.
- Inconsistent key selection.
- Trusting attacker-controlled key locations.
A kid header by itself is normal. Only report an issue when unsafe handling produces a demonstrable security impact.
5. Practical JWT Testing Methodology
Let's walk through a controlled testing workflow using Burp Suite.
Step 1 — Capture an authenticated request
Log in with your authorized test account and intercept an API request containing a JWT.
Example:
GET /api/profile HTTP/1.1
Host: target.example
Authorization: Bearer YOUR_JWT_TOKENGET /api/profile HTTP/1.1
Host: target.example
Authorization: Bearer YOUR_JWT_TOKENSend the request to Burp Repeater.
Step 2 — Decode the JWT
You can decode the token using a trusted local tool or an approved JWT decoder.
For example, using Python:
import base64
import json
token = "HEADER.PAYLOAD.SIGNATURE"
header, payload, signature = token.split(".")
def decode_part(part):
part += "=" * (-len(part) % 4)
decoded = base64.urlsafe_b64decode(part)
return json.loads(decoded)
print("Header:", decode_part(header))
print("Payload:", decode_part(payload))import base64
import json
token = "HEADER.PAYLOAD.SIGNATURE"
header, payload, signature = token.split(".")
def decode_part(part):
part += "=" * (-len(part) % 4)
decoded = base64.urlsafe_b64decode(part)
return json.loads(decoded)
print("Header:", decode_part(header))
print("Payload:", decode_part(payload))This only decodes the token. It does not validate its signature.
Step 3 — Review the header
Check:
algtypkid- Any additional key-related headers
Understand which algorithm and key configuration the application is expected to use.
Step 4 — Review the payload
Inspect claims such as:
subroleissaudexpiatnbf
Look for unexpected information, excessive privileges, missing required claims, or inconsistent values.
Step 5 — Perform controlled validation tests
Using your own test account:
- Send the original token and record the baseline response.
- Modify a harmless claim in a test request.
- Leave the signature invalid and observe whether the server rejects it.
- Test expired or otherwise invalid tokens where permitted.
- Observe whether the server validates issuer, audience, and expiration.
- Check whether the application enforces authorization independently of token claims.
Do not attempt privilege escalation against real users or production accounts outside your authorization.
Step 6 — Verify actual impact
For example, if you suspect role manipulation:
- Use two accounts you control, with different permissions.
- Identify a harmless, authorized test operation that is restricted to the higher-privileged account.
- Verify the normal authorization behavior.
- Test whether the lower-privileged account can perform that operation.
- Confirm that the result is caused by the JWT weakness rather than another authorization issue.
A changed token or altered HTTP response is not proof of a vulnerability.
6. Useful Tools for JWT Testing
Burp Suite
- Capture and modify JWT-bearing requests.
- Compare responses.
- Test authorization behavior.
JWT.io
- Decode and inspect JWT structures.
- Understand headers and claims.
jwt_tool
- Automate selected JWT security checks in authorized environments.
- Help investigate token validation weaknesses.
CyberChef
- Decode Base64URL data.
- Inspect token components.
Python
- Build controlled token-inspection scripts.
- Decode and analyze claims.
Always verify tool output manually. Automated findings are not proof of exploitability.
7. Common JWT Testing Mistakes
MistakeCorrect approachTreating Base64 decoding as decryptionExplain that normal JWT payloads are readable encodingChanging role and reporting immediatelyProve the server accepts the modified token and grants unauthorized accessAssuming alg: none always worksVerify actual signature-validation behaviorFinding a weak-looking secret and stoppingDemonstrate that it permits valid token forgeryReporting missing exp automaticallyCheck the application's intended token-lifetime policyTreating every exposed claim as sensitiveEstablish confidentiality or authorization impactTrusting automated scanner outputReproduce and verify the finding manually
8. Impact of JWT Vulnerabilities
Depending on the implementation weakness, JWT vulnerabilities may lead to:
- Authentication bypass
- Account impersonation
- Privilege escalation
- Unauthorized API access
- Cross-account data exposure
- Session or token forgery
- Unauthorized access to administrative functionality
Severity should be based on demonstrated impact, required attacker capabilities, affected users, and the scope of the application.
A JWT issue is not automatically Critical or High.
9. Professional Vulnerability Report Example
Title: Improper JWT Signature Validation Allows Unauthorized Privilege Escalation
Suggested Severity: High, if a lower-privileged account can successfully perform privileged actions without authorization.
Description
During the security assessment, improper JWT signature validation was identified in the application's authentication mechanism.
The application accepts a modified JWT containing altered authorization claims without correctly validating the token signature.
This behavior allows an authenticated lower-privileged user to manipulate token claims and potentially access functionality intended for higher-privileged accounts.
Steps to Reproduce
- Create and authenticate a standard test account.
- Capture an authenticated API request containing a JWT.
- Decode the JWT and identify the relevant authorization claim.
- Modify the claim in a controlled test request.
- Submit the modified token with an invalid signature.
- Observe whether the application accepts the token.
- Access a harmless privileged test operation that the standard account should not be permitted to perform.
- Record the response and verify the resulting application state.
Impact
An attacker with access to a valid token may be able to manipulate authorization claims and gain privileges beyond those assigned to their account.
Depending on the application's functionality, this could expose sensitive data or enable unauthorized administrative actions.
Remediation
- Enforce cryptographic signature verification for every protected request.
- Explicitly allow only the expected signing algorithms.
- Use strong, securely managed signing keys.
- Validate issuer and audience claims.
- Enforce token expiration and other required claims.
- Implement authorization checks on the server side.
- Avoid trusting authorization information from unverified token contents.
- Rotate exposed or compromised signing keys.
- Add security tests for invalid, expired, and modified tokens.
10. OWASP and CWE References
Relevant references depend on the actual root cause:
- OWASP API Security Top 10 — API2:2023 Broken Authentication: Relevant when token validation weaknesses compromise authentication.
- OWASP API Security Top 10 — API5:2023 Broken Function Level Authorization: Relevant when JWT-related authorization weaknesses expose privileged functions.
- OWASP Top 10 — A07:2021 Identification and Authentication Failures: Relevant to authentication and session-validation failures.
- CWE-347 — Improper Verification of Cryptographic Signature: Relevant when signatures are not correctly verified.
- CWE-326 — Inadequate Encryption Strength: Potentially relevant to inadequate cryptographic strength, depending on the specific implementation.
Choose mappings based on the demonstrated root cause, not simply because a JWT is involved.
11. JWT Security Testing Checklist
- Identify JWT usage in authenticated requests.
- Decode and inspect the header and payload.
- Identify the expected signing algorithm.
- Check whether invalid signatures are rejected.
- Check whether unexpected algorithms are rejected.
- Review signing-secret strength where authorized.
- Check expiration enforcement.
- Review issuer and audience validation.
- Inspect key selection and
kidhandling. - Check whether authorization is enforced server-side.
- Verify impact using controlled test accounts.
- Prepare a report with reproducible evidence.
12. Final Thoughts
JWTs are not inherently insecure. The vulnerabilities usually come from how developers generate, validate, store, and trust them.
As a bug hunter, don't focus only on changing token values. Understand the complete authentication flow and determine what the server actually trusts.
The real finding is not a modified JWT. It's an unauthorized action that the application accepts because of incorrect token validation.
What's Next? — Day 22
In Day 22, we'll explore GraphQL Security Testing: Finding Authorization, Introspection, and API Exposure Issues.
We'll cover GraphQL fundamentals, introspection, query abuse, authorization testing, IDOR in GraphQL resolvers, common mistakes, and professional vulnerability reporting.