You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-web/hacking-jwt-json-web-tokens.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,53 @@ Set the algorithm used as "None" and remove the signature part.
96
96
97
97
Use the Burp extension call "JSON Web Token" to try this vulnerability and to change different values inside the JWT (send the request to Repeater and in the "JSON Web Token" tab you can modify the values of the token. You can also select to put the value of the "Alg" field to "None").
Some stacks expect a **signed inner JWT** wrapped inside an **encrypted JWE**. In vulnerable `pac4j-jwt` versions (before `4.5.9`, `5.7.9`, and `6.3.3`), the authenticator decrypts the JWE, tries to parse the payload as a signed JWT, and only verifies the signature if that conversion succeeds. If the decrypted payload is a **PlainJWT** (`alg=none`), `toSignedJWT()` returns `null` and the signature verification path is skipped.
102
+
103
+
-**Pre-reqs**:
104
+
- The application accepts **JWE bearer tokens**
105
+
- The server public key is exposed (commonly via **JWKS** such as `/.well-known/jwks.json` or `/api/auth/jwks`)
106
+
- Authorization depends on attacker-controlled claims such as `sub`, `role`, `groups`, or `scope`
107
+
-**Impact**: forge an encrypted token for any user/role using **only the public key**
108
+
109
+
Practical checks:
110
+
111
+
- Enumerate the frontend / API docs for clues such as `RSA-OAEP-256`, `A128GCM`/`A256GCM`, `jwks`, or comments saying "inner JWT is signed".
112
+
- Fetch the JWKS and import the RSA key from `n`/`e`.
113
+
- Build the inner token manually as `base64url(header) + "." + base64url(payload) + "."` so the signature is empty.
114
+
- Encrypt that plaintext JWT as a JWE using the exposed public key and replay it as the bearer token.
- If your JWT library refuses to emit `alg=none`, generate the compact token manually as shown above.
143
+
- The `enc` value must match one accepted by the target; frontend comments and legitimate tokens often disclose this.
144
+
- In SPAs, check whether the bearer token is stored in `sessionStorage`, `localStorage`, or a JS-accessible cookie; dropping the forged token there is often enough to validate the bypass quickly.
145
+
99
146
### Change the algorithm RS256(asymmetric) to HS256(symmetric) (CVE-2016-5431/CVE-2016-10555)
100
147
101
148
The algorithm HS256 uses the secret key to sign and verify each message.\
0 commit comments