Skip to content
Crypto Write-up Advanced

Issue Summary

JSBN's modular exponentiation and inversion implementations contain secret-dependent branches and loop bounds, leaking exponent bits through timing side channels. An attacker with local code execution could recover private keys or messages from RSA, Diffie-Hellman, SRP, and ECDSA operations.

Soatok Follow

Published on github.com

JSBN contains a lot of timing leaks that make it unsuitable for cryptographic use. However, JSBN is broadly used in JavaScript implementations of asymmetric cryptography.

Soatok (@SoatokDhole), on github.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 with local code execution could recover private keys or messages from RSA, Diffie-Hellman, SRP, and ECDSA operations, though the report does not demonstrate a working exploit.

What the attacker needed

Attacker can run code in another browser window; attacker can measure timing of JS engine

The fix

The code should be made constant-time, for example by using constant-time conditional swaps and peasant multiplication as in the author's reference implementation.

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.

This report is about a JavaScript library for big-number maths used in cryptography. The code takes different amounts of time depending on secret values, so an attacker who can measure timing can gradually learn those secrets. It is like guessing a password by seeing how long the check takes.

What is Crypto?

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

More by Soatok

View all

1 more disclosed report, best first.

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.