Skip to content
Crypto Write-up Advanced

ECDSA Nonce Reuse

A web application signed JWTs using ECDSA with a static nonce, causing the same nonce to be reused across signatures. An attacker could recover the private key and forge tokens to impersonate any user, including administrators.

Ingredous Labs Follow

Published on labs.ingredous.com

Disclaimer: The information presented in this blog post is not novel research, but rather a writeup demonstrating the attack. The goal of this post is to help developers and pentesters alike to be aware of this vulnerability.

Ingredous Labs, on labs.ingredous.com

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

Impact

An attacker could forge JWTs with arbitrary claims and gain access as a highly privileged user, such as an administrator.

What the attacker needed

Ability to obtain two signed JWTs; access to the application's sign-up or login

The fix

The application should use a cryptographically secure random nonce for each signature, typically by using a well-tested ECDSA library rather than a custom implementation.

How it was found

  1. Authenticate to the application and obtain a JWT session cookie.
  2. Register a second user and authenticate to obtain another JWT.
  3. Compare the signatures and notice that the first part is identical, indicating nonce reuse.
  4. Use the two JWTs to recover the public key and then the private key with the described Python libraries.
  5. Forge a new JWT with modified claims, such as an admin username, using the recovered private key.

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.

ECDSA is a way to digitally sign data so others can check it came from you. It relies on a random number called a nonce for each signature; if the same nonce is used twice, the secret signing key can be calculated from the two signatures. Here, the application reused the nonce, so an attacker who collected two tokens could work out the key and create fake tokens.

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.