Skip to content

Control-flow timing leak in Kyber reference implementation when compiled with Clang 15-18 for -Os, -O1 and other options

Moderate
dstebila published GHSA-f2v9-5498-2vpp Jun 7, 2024

Package

liboqs

Affected versions

<=0.10.0

Patched versions

0.10.1 and higher

Description

liboqs is a C-language cryptographic library that provides implementations of post-quantum cryptography algorithms.

Impact

A control-flow timing leak has been identified in the reference implementation of the Kyber key encapsulation mechanism when it is compiled with Clang 15-18 for -Os, -O1, and other compilation options.

A proof-of-concept local attack on the reference implementation leaks the entire ML-KEM 512 secret key in ~10 minutes using end-to-end decapsulation timing measurements.

Patches

Fixed in version 0.10.1 and main branch of liboqs on GitHub.

Workarounds

Some compiler options may produce vectorized code that does not leak secret information, however relying on these compiler options as a workaround may not be reliable.

References

Further details

The function poly_frommsg produces a polynomial based on the bits of the message m. Given that m is sensitive in both the encapsulation and decapsulation procedure, it is crucial that the implementation does not leak the bits of m through timing. Despite the source-level mitigations in poly_frommsg, the latest generations of Clang recognize that the code essentially performs a bit test and produces a secret-dependent branch for several compiler options.

The following compiler options when used with Clang 15, 16, 17, and 18 on x86 produce a branch:

  • -Os
  • -O1
  • -O2 -fno-vectorize
  • -O3 -fno-vectorize

Credits

The vulnerability was identified by Antoon Purnal (PQShield). A patch was developed by Peter Schwabe (MPI-SP).

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N

CVE ID

CVE-2024-36405

Credits