Credential detector
JSON Web Token (JWT): format and detection
Short answer
A JWT is three base64url parts separated by dots. The first two begin with ey (the start of a base64-encoded JSON object) and each must be at least 19 characters; the third, the signature, is at least 10 characters and may be absent.
What it is
A JWT is a bearer credential: whoever holds it can usually act as the user until it expires. Its header and payload are only base64-encoded, not encrypted, so the claims inside (user ID, email, tenant) are readable by anyone who has the token. Maskflare's Credentials pack masks it by default.
In Maskflare this is the detector jwt, labelled "JWT", category password or access key, in the Credentials pack.
Format
- Part one starts with ey and has at least 17 more letters or digits.
- Part two starts with ey and has at least 17 more characters from letters, digits, slash, backslash, underscore and hyphen.
- A dot between the parts, and then the signature of 10 or more characters with up to two = signs, or nothing after the second dot.
How Maskflare recognises it
Structure and an entropy floor of 3.0 on the whole token.
The keyword prefilter looks for ey.
Why this page shows no sample key
A realistic sample key would look like a live credential to secret scanners and to anyone skimming the page, and an obviously fake one would not pass this detector's length and entropy rules. The format above is enough to recognise the key: the prefix, the length and the character set.
Regex and validation caveats
- The pattern wants the key to be followed by a quote, a backtick, whitespace, a semicolon, an escaped newline or the end of the text. A key directly followed by a comma or a closing bracket is therefore not matched by this pattern.
- The detector does not decode or verify the token, so an expired or unsigned token is masked the same as a live one.
How to detect it in LLM traffic
JWTs reach assistants through pasted HTTP traces, browser developer-tool output and curl commands with Authorization: Bearer headers, and through logs that print a request.
Maskflare reads the whole request body, including the system prompt, earlier messages and tool arguments, and replaces each match with a token such as mf_mask_d7e0 before the request goes out. Coding agents are covered through hooks that mask tool inputs and results, so a key printed by a shell command does not travel onward in the next prompt. On ChatGPT, browser protection blocks prompts that contain API keys, tokens or private keys outright.
If you build the detection yourself
- Scan the raw text rather than parsed fields: keys sit in code, JSON strings, headers, shell output and pasted logs, often with no label at all.
- Match the prefix and the exact length for the JSON Web Token (JWT). Where the key has no fixed prefix, require the provider's name and an assignment next to the value instead of matching any long string.
- Compute the Shannon entropy of the candidate and reject low values, and keep an allow list of placeholders (${KEY}, repeated characters, the alphabet run), because documentation and templates are full of them.
- Mask the value before the text is sent anywhere. If the key was already sent, treat it as exposed and rotate it; masking later does not recall it.
How Maskflare handles it
- Protect now, Finance - Protect now, Healthcare, Developer and Monitor first: mask (a reversible token).
The available actions are mask (reversible token), redact, partial, hash, format-preserving encryption, generalize, alert and block. Masked values are kept encrypted for 30 days so that answers can be restored, then they expire; prompts and responses are not logged. The full list of detectors is in the detector reference.
Compliance profiles that include it
All 6 compliance profiles include the Credentials pack, and applying them turns this detector on: HIPAA Safe Harbor, GDPR - EU/EEA, UK GDPR, PCI DSS, US personal data and Switzerland - nDSG health data. A profile is a floor: it never turns anything off or weakens a rule that is already stricter.
Frequently asked questions
Is the payload of a JWT secret?
No. It is base64-encoded, not encrypted, so anyone with the token can read the claims. That is one more reason to mask the whole token.
Does Maskflare check the signature?
No. It matches the structure only.
Is the JSON Web Token (JWT) detector on by default?
Yes. It belongs to the Credentials pack, which the default Protect now template turns on with the action mask.
Does Maskflare store the keys it masks?
Prompts and responses are not logged. A masked value is kept encrypted for 30 days so the answer can be restored, then it expires.
Rules on this page describe what Maskflare's detectors and validators check. They are read from the detection catalogue and are not the specification of the body that issues the identifier. No sample key is shown on purpose.