JWT Attacks
JWT Attacks
The JWT token format contains three parts, each separated by a dot. there is the header, the payload
and the signature
The header and payload part of the json is just base 64 encoded of the json objects
The header contains the meta data about the token itself
the payload contains the actual claims about the users
the JWT libraries provide one method for the verification of tokens and uses another one just to
decode them.
If the incoming token is passed to the decode () method, this means that the signature is not being
verified.
In the first lab the jwt token was not being verified by the server thus changing the token got us access
to the admin panel.
in the jwt header there is a alg parameter, this is used to tell the sever which alg was used to sign the
token. the server uses this to verify the signature.
in the jwt token only the alg parameter is necessary. this means that the attacker can inject headers.
Servers use crypto keys for the signing of different kids of data. For this reason the JWT token have
the key id parameter (kid). This helps the server identify which keys to use when it has to verify the
signature.
they keys are often stored as jwk sets, this makes the server look for the same kid as the JWK . Since
there is no hard and fast rule to define the specifications and it is just an arbitrary string and the kid
parameter can be used to point to a specific entry in the data base or a file.