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.
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.
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
- Authenticate to the application and obtain a JWT session cookie.
- Register a second user and authenticate to obtain another JWT.
- Compare the signatures and notice that the first part is identical, indicating nonce reuse.
- Use the two JWTs to recover the public key and then the private key with the described Python libraries.
- 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.