AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 60 Bitcoin

crypto: use constant-time equality for Poly1305 tags

Public commit record

What the developer wrote

Authored by Alexey Gradoboev

96/100 · Strong
crypto: use constant-time equality for Poly1305 tags

Currently, the `decrypt` method uses the standard `==` operator for tag verification, which is vulnerable to timing attacks

### Changes
- Introduced a helper function `constant_time_eq` that iterates through the entire 16-byte tag regardless of where a mismatch occurs as constant-time alternative.

This change ensures that the decryption process is secure against side-channel timing leaks.

Fixes #6122
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a timing attack weakness in the ChaCha20-Poly1305 decryption code. Previously, the code compared the authentication tag using Rust's normal `==` operator, which can stop early when it finds a mismatch. That early-stop behavior can leak information about how much of the tag is correct if an attacker can measure tiny timing differences. The patch replaces it with a constant-time comparison that always scans all 16 bytes, so no timing information about the tag's contents is revealed.

Recommended action

Review the new `constant_time_eq` implementation to confirm the compiler does not optimize away the loop or short-circuit the OR accumulation under release builds; consider adding a `black_box`-style barrier or using a well-reviewed constant-time crate if stronger guarantees are needed. Ensure the fix is included in the next release and that issue #6122 is closed with an advisory note.

Security signals we found

01

Timing side-channel in cryptographic tag comparison

02

Use of non-constant-time equality (`==`) on Poly1305 authentication tag

03

Introduction of constant-time equality helper

04

Fixes issue #6122

Risk score

Why this scored 60/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 8/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.