Skip to content
Crypto Write-up Advanced

Attacks On GCM With Repeated Nonces

A web application encrypted sequential note IDs with AES-GCM but reused the same nonce (the AES key) for every encryption. An attacker who obtained two ciphertexts could recover the authentication key and forge a valid ciphertext for a chosen note ID, thereby accessing another user's note.

Sebastien Macke Follow

Published on elttam.com

Cryptography is a cornerstone of information security, with implementations running in various places to secure our Internet communications.Quite often web applications also need to use cryptography directly to protect sensitive features or data.Unfortunately quite often also usage errors are made, which can have…

Sebastien Macke, on elttam.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

Root cause

The application used a static nonce (the AES key itself) for every AES-GCM encryption, violating the requirement for a unique nonce per encryption.

Impact

An attacker could forge a valid ciphertext for any chosen note ID and retrieve other users' notes, as demonstrated by accessing a note containing a flag.

What the attacker needed

Ability to save notes (no authentication required); ability to retrieve notes by ID; obtain two ciphertexts

The fix

The application should use a unique nonce for each encryption, or switch to a nonce-misuse-resistant mode such as AES-GCM-SIV, or use AES-CBC with HMAC-SHA following best practices.

How it was found

  1. Save two notes to obtain two ciphertexts.
  2. Run the exploit with the two ciphertexts to recover candidate authentication keys.
  3. Choose a desired ciphertext (e.g., change one byte) and run the exploit again to forge a valid tag.
  4. Send the forged ciphertext to the note retrieval endpoint to access another note.

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.

AES-GCM is a way to encrypt data that also adds a tamper-proof seal (a tag) so any change is detected. This seal relies on a unique random number (nonce) for each encryption; if the same nonce is reused, an attacker can work out the secret used to make the seal and then create fake sealed messages that the app accepts. Here the app reused the same nonce, so an attacker could forge a note ID and read someone else's note.

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.