Skip to content
Crypto Disclosed report Advanced

Constant-time comparison is not always implemented; critical areas are vulnerable to key-timing attacks

The report claims that constant-time comparison is not globally implemented in Monero, leaving several cryptographic areas potentially vulnerable to key-timing attacks. An attacker might be able to forge RingCT signatures or other cryptographic material by measuring comparison timing, though no proof of concept is provided.

anonimal Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 3 days
  • Fixed in 48 days
  • Disclosed after 58 days

In my most superficial of reviews, constant-time comparison appears to not be globally implemented (at a glance, only implemented within the ref10 implementation).

With that said, the following areas either appear to be vulnerable, or are potentially vulnerable, to key-timing attacks:

  1. Containers used for RingCT (in particular, the key struct) as deployed throughout RingCT
  2. The definition and implementations of CRYPTO_MAKE_COMPARABLE
  3. equalKeys in rctOps.cpp, whose comparison speed appears to be relative to its available hardware

For points 1 and 2, as a steadfast rule; do NOT use memcmp when comparing cryptographic secrets (or any cryptographic material for that matter). For point 3, be careful with conditional branches which can be optimized or subject to speculative execution. One possible fix for point 3 is to perform an XOR of all the bytes in both buffers, and then compare the result (see kovri below).

As the literature states, key timing vulnerabilities can range from somewhat-trivial to extremely-difficult to exploit. For this report, I cannot assess a difficulty. For an active attack, monero has a very simple yet friendly network layer which I imagine could make remote execution somewhat easier (depending on the context and application) but, I don't have PoC. Now, at the local level for, let's say, a malicious node that wants to forge X before sending to the next peer, the results could be easier to attain (again, no PoC).

This was only the most superficial of reviews - so please forgive any assumptions or inaccuracies on my part. If I had more time with this issue, I would love to look deeper in order to provide a more details and to assert a monero PoC. Unfortunately, I am too busy with kovri - but I hope that this report will at least raises awareness.

Mitigation:

Impact

At first glance, a forged RingCT signature - but the extent of the problem could be possibly extended to other areas (to be determined).

The original report as published on HackerOne, by anonimal. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

Likely the use of non-constant-time comparison functions such as memcmp for cryptographic secrets, and conditional branches that may be optimised or subject to speculative execution.

Impact

A forged RingCT signature could be possible, but the extent of the problem is undetermined and no proof of concept was provided.

What the attacker needed

Ability to measure comparison timing

The fix

Use a constant-time comparison function, such as the crypto++ solution used by kovri, and avoid conditional branches that can be optimised or subject to speculative execution.

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 report has not been written yet. The Original tab links to the source.

Some security checks compare secret values byte by byte and stop at the first difference. The time this takes can leak information about the secret, allowing an attacker to guess it piece by piece. This report says some parts of Monero may use such non-constant-time comparisons.

What is Crypto?

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

More by anonimal

View all

1 more disclosed report, best first.

More from Monero

View all

The newest disclosed reports for this program.

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.