Skip to content
Crypto Write-up Intermediate

Finding Insecure JWT Signature Validation with CodeQL

The jwtk/jjwt library's parse method accepts a JWT with an empty signature, so an attacker could forge a token and bypass authentication. The author used CodeQL to find four vulnerable applications that relied on this method.

intrigus.org

Published on intrigus.org

In this post I want to show how I found four vulnerabilities in users of the jwtk/jjwt library using CodeQL.

The author, on intrigus.org

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The library's parse method treated a JWT with an empty signature as valid instead of rejecting it.

Impact

An attacker could forge a token and gain access to protected resources without knowing the user's password or second factor.

What the attacker needed

Victim uses a vulnerable application; attacker can send a crafted JWT

The fix

The library should reject tokens with an empty signature when a signing key is configured.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A JWT is a token a server gives you after login to prove who you are. The server checks a cryptographic signature to make sure you did not tamper with it. Here, the library skipped that check when the signature part was empty, so anyone could create a fake token and be treated as a valid user.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.