RustSec logo

History ⋅ Edit ⋅ JSON (OSV)

RUSTSEC-2026-0603

X25519 accepts low-order public keys, yielding session keys computable without a private key

Reported
Issued
Package
dryoc (crates.io)
Type
Vulnerability
Categories
Keywords
#x25519 #curve25519 #low-order #key-exchange #diffie-hellman
Aliases
References
CVSS Score
4.8 MEDIUM
CVSS Details
Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality Impact
Low
Integrity Impact
Low
Availability Impact
None
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N
Patched
  • >=1.0.0
Affected Functions
Version
dryoc::classic::crypto_box::crypto_box_beforenm
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_detached
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_detached_inplace
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_easy
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_easy_inplace
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_open_detached
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_open_detached_inplace
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_open_easy
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_open_easy_inplace
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_seal
  • <1.0.0
dryoc::classic::crypto_box::crypto_box_seal_open
  • <1.0.0
dryoc::classic::crypto_core::crypto_scalarmult
  • <1.0.0
dryoc::classic::crypto_kx::crypto_kx_client_session_keys
  • <1.0.0
dryoc::classic::crypto_kx::crypto_kx_server_session_keys
  • <1.0.0
dryoc::dryocbox::DryocBox::decrypt
  • <1.0.0
dryoc::dryocbox::DryocBox::decrypt_to_vec
  • <1.0.0
dryoc::dryocbox::DryocBox::encrypt
  • <1.0.0
dryoc::dryocbox::DryocBox::encrypt_to_vecbox
  • <1.0.0
dryoc::dryocbox::DryocBox::seal
  • <1.0.0
dryoc::dryocbox::DryocBox::seal_to_vecbox
  • <1.0.0
dryoc::dryocbox::DryocBox::unseal
  • <1.0.0
dryoc::dryocbox::DryocBox::unseal_to_vec
  • <1.0.0
dryoc::keypair::KeyPair::precalculate
  • <1.0.0
dryoc::kx::Session::new_client
  • <1.0.0
dryoc::kx::Session::new_client_with_defaults
  • <1.0.0
dryoc::kx::Session::new_server
  • <1.0.0
dryoc::kx::Session::new_server_with_defaults
  • <1.0.0
dryoc::precalc::PrecalcSecretKey::precalculate
  • <1.0.0

Description

Versions of dryoc before 1.0.0 never reject low-order peer public keys or an all-zero shared secret. In addition, versions 0.5.1 through 0.9.x compute X25519 with the clamped scalar reduced modulo the prime subgroup order ℓ (Scalar::from_bytes_mod_order(clamp(n))) instead of the clamped integer specified by RFC 7748; earlier versions use the unreduced clamped scalar. libsodium, with which these functions are documented as compatible, returns an error for all of these inputs.

This affects crypto_scalarmult, crypto_kx_client_session_keys / crypto_kx_server_session_keys, kx::Session::new_*, and crypto_box_beforenm together with the box and precalculation APIs built on it, whenever the peer public key is not authenticated or can be chosen by a malicious party.

Impact

Applications that only use authenticated peer keys generated by dryoc or libsodium are not affected in practice: honest keys lie in the prime-order subgroup, where the reduced and unreduced scalars give the same result.

Resolution

Upgrade to dryoc 1.0.0 or later. In 1.0.0, X25519 is computed with MontgomeryPoint::mul_clamped (the unreduced clamped scalar, as in RFC 7748), and an all-zero shared secret is rejected, so low-order public keys now return an error from the scalarmult, box, key-exchange and precalculation APIs. Note that 1.0.0 is a backward-incompatible release; several of these functions now return Result.

If upgrading is not yet possible, validate every untrusted peer X25519 public key before passing it to dryoc 0.9.x, for example by rejecting keys that do not map to a torsion-free Edwards point (MontgomeryPoint::to_edwards(0) followed by is_torsion_free() in curve25519-dalek; this requires curve25519-dalek 4.x as a direct dependency). A check based only on is_small_order() prevents the predictable session keys but not the 2-bit leak or the non-standard output.

Advisory available under CC0-1.0 license.