Signature Validation

circle-check

None Algorithm

circle-check

The below example is based on TCM's Practical API Hackingarrow-up-right course.

After obtaining a JWT, we can start by auditing it by using an endpoint which process the token in some way, i.e., sends back different responses if the token is and it isn't present (Figure 1).

Figure 1: Finding an appropriate endpoint.

The JWT header contains an alg parameter which tells the server which algorithm was used to sign the token, i.e., which alogirthm it needs to use when veryfing the signature. This is inherently flawed as it is user-controlled. JWTs can be also left unsigned using "alg":"none", aka unsecure JWT. Servers usually reject this tokens, but since this relies on string parsing, it can be obfuscated.

circle-exclamation

We can then audit the JWT (Figure 2).

Figure 2: Auditing the JWT using jwt_tool.

We could then use Burp's JWT Editorarrow-up-right extension to validate the alg:none vulnerability (Figure 3 & 4).

Figure 3: Validating the alg:none attack.
Figure 4: The server sends a 200 without validating the JWT signature (BOLA).

We also have the option to choose different capitalization of the none algorithm (Figure 5).

Figure 5: Capitalization options for the none algorithm.

Blank Signature

circle-check

The below example is based on APISEC University's course API Penetration Testingarrow-up-right.

We can generate a token without a signature and see how the server responds.

Arbitraty Signature

circle-check

The below example is based on PortSwigger's JWT authentication bypass via unverified signaturearrow-up-right lab.

JWT libraries usually provide 2 methods, one for verification and one for decoding. For example, Node.js's jsonwebtoken library has the verify() and decode() methods. If a developer only use the latter, the application won't verify the signature at all. In this case, it is possible to modify a claim directly (Figure 6).

Figure 6: Modifying the sub claim results in an altered signature which is accepted by the server.

Last updated

Was this helpful?