Sensitive Data in JWT Payload
JSON Web Tokens carry personal data, internal details or secrets in their payload, which is only encoded, not encrypted, so anyone who sees a token can read them.
| Severity | Low |
| CVSS 3.1 | 3.7 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-201: Insertion of Sensitive Information Into Sent Data |
| OWASP Top 10 | A01:2025 Broken Access Control |
| Category | Information Disclosure |
Description
The payload of a signed JSON Web Token (a JWS, the usual form) is Base64url encoded, not encrypted. The signature protects it from being changed, but anyone who holds or sees the token can decode and read it without any key. The application places information in the payload that should not be readable by everyone who may see the token, such as personal data (full name, date of birth, address, telephone number or national identifiers), internal identifiers, database or infrastructure details, permissions beyond what the client needs to know, or secrets such as passwords, password hashes and API keys.
Tokens travel further than their owner: they are kept in browser storage, sent to every service that accepts them, and can appear in logs, monitoring tools and error reports, and, where they are placed in URLs, in browser history and Referer headers. Anyone who obtains a token along the way, including through intermediaries or a compromised client device, can read the information in it without breaking any protection. Personal data exposed in this way may need to be handled as a data protection matter, and internal details help an attacker plan further attacks, while secrets such as API keys or passwords give direct access to other systems and would raise the severity. A user reading their own token mostly sees their own data, so the impact depends on what the claims contain and how widely tokens are copied and logged.
The weakness is identified by decoding tokens issued to test accounts, with any Base64url decoder or a tool such as jwt_tool, and reviewing every claim for information that would be sensitive if read by a third party.
Remediation
Keep tokens to the minimum their recipients need:
- Limit claims to what the receiving services need to make their decisions, typically an opaque user identifier, the issuer, audience and expiry, and the scopes or roles required. Retrieve personal and other sensitive details from the server when they are needed instead of carrying them in the token.
- Never place passwords, password hashes, API keys, connection strings or other secrets in a token.
- Where sensitive claims must travel with the token, encrypt it as a JSON Web Encryption (JWE) token, or give the client an opaque reference token that the API exchanges internally for the full token.
- Avoid placing tokens in URLs, and keep them out of logs by masking the
Authorizationheader and token parameters in application, proxy and monitoring logs.
Rotate any secret that has appeared in a token, and treat tokens already issued as exposed until they expire. Confirm the fix by decoding newly issued tokens and checking that only the intended claims are present.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.