JWT
By design, servers don't store information about the JWTs they issue. Each token is a self-contained entity.
JWT attacks involve users sending modified JWTs to the server to achieve malicious goals.
Arbitrary signatures
Sometimes, developers decode tokens without verifying the signature.
So, tamper the JWT and ignore the signature.
No signature
The JWT header contains an alg
parameter.
JWTs can be left unsigned (alg
set to none
). Servers usually reject unsigned tokens, but obfuscation (mixed capitalization) can bypass filters.
Note: even if unsigned, the token's payload must end with a trailing dot.
Tip: Use JSON Web Tokens Burp Extension. Go to the request -> JSON Web Tokens and test "Alg None Attack".
Brute-forcing secret keys
Some signing algorithms, such as HS256 (HMAC + SHA-256), use a string as the secret key -> crack it.
Wordlist: https://github.com/wallarm/jwt-secrets/blob/master/jwt.secrets.list
Go on JWT Editor Keys tab -> New Symmetric Key -> specify secret -> generate the key -> and finally sign.
JWT header parameter injections
Injecting self-signed JWTs via jwk
Servers should use a limited whitelist of public keys to verify JWTs. However, misconfigured servers may accept any key in the jwk
parameter. So you can sign JWT with your own RSA private key and embedding the matching public key in the jwk
header.
Detect/Exploit with JWT Editor Burp extension
In JWT Editor, create new RSA Key.
In Burp Repeater -> JSON Web Token tab.
Tamper the data (in exploit phase).
Finally, click on Attack -> Embedded JWK. (you can do it manually but pay attention to match
kid
) .
Note: you can also perform this attack manually by adding the jwk
header yourself. So test it even if the token doesn't have jwk
header.
Injecting self-signed JWTs via jku
Some servers use the jku
header parameter to reference a JWK Set containing the key instead of embedding keys directly with the jwk
parameter. Secure sites fetch keys (to verify the signature) from trusted domains, but URL parsing issues can bypass this.
Detect/Exploit with JWT Editor Burp extension
In JWT Editor, create new RSA Key.
In Burp Repeater -> JSON Web Token tab.
Create JWK Set (JSON Web Token tab -> select key -> create JWK Set).
Create webpage on your exploit server with JWK Set. So, from JWT Editor, select "Copy Public Key" and paste inside "keys" array.
Tamper the data (in exploit phase).
Add a new
jku
parameter to the header and set its value to the URL of your JWK Set on the exploit server.Sign and update
kid
parameter.
Tip: to see if the server makes the request, add jku
header and insert Burp collaborator.
Injecting self-signed JWTs via kid
The kid
in JWS is an arbitrary string set by the developer, possibly pointing to a database entry or file. If vulnerable to directory traversal, you could force the server to use any file as the verification key.
If the server supports JWTs signed with a symmetric algorithm, you could point the kid
to a predictable static file, then sign the JWT using a secret that matches the contents of this file. The best way is to use /dev/null
(empty file), and sign the JWT with an empty string to create a valid signature.
Detect/Exploit with JWT Editor Burp extension
In Burp Repeater -> JSON Web Token tab.
Modify
kid
parameter to test path traversalSign with empty string
Repeat the process with different path traversal payload
Tip: try also SQL injection
Last updated