Description
phpseclib is a PHP secure communications library. Prior to 3.0.57 and 4.0.1, pure-PHP X25519 scalar multiplication in phpseclib/Math/PrimeField/Integer.php performs data-dependent conditional modular reductions in add() and subtract(). During the Montgomery ladder in phpseclib/Crypt/EC/BaseCurves/Montgomery.php, the reduction behavior of each step depends on the secret scalar prefix, creating per-step timing and libgmp call-count observations that can reveal a reused 251-bit clamped private scalar. The phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php derivation path invokes the pure-PHP multiplication without a native-engine check, while phpseclib/Crypt/EC/Formats/Keys/PKCS8.php reaches it when ext-sodium is unavailable. Exploitation requires a reused or long-lived X25519 private key, knowledge of the corresponding public key, execution of the pure-PHP path, and a local observer capable of resolving individual ladder steps or libgmp entry-point calls. Ephemeral X25519 keys, including phpseclib's normal SSH exchange path, are not affected. Recovery of the scalar permanently compromises operations that reuse that key. This issue is fixed in versions 3.0.57 and 4.0.1.
Published: 2026-09-01
Score: 6.3 Medium
EPSS: < 1% Very Low
KEV: No
Impact: Private Key Disclosure
Action: Immediate Patch
AI Analysis

Impact

The vulnerability is found in phpseclib's pure‑PHP implementation of X25519 scalar multiplication in Math/PrimeField/Integer.php. During the Montgomery ladder, data‑dependent conditional modular reductions create timing and libgmp call‑count variations that depend on the secret scalar prefix. This side channel allows a local observer to recover the full 251‑bit clamped private key when the key is reused, permitting any operation that reuses the key to be compromised. The flaw is a timing side‑channel that results in private‑key disclosure.

Affected Systems

Applications or scripts that use phpseclib before version 3.0.57 or 4.0.1, relying on the pure‑PHP X25519 path and where the ext‑sodium engine is not available, are affected. Long‑lived or reused private keys exposed to a local observer are vulnerable. Ephemeral keys and the native engine path are not impacted.

Risk and Exploitability

With a CVSS score of 6.3 the attack is considered moderate. Exploitation requires the attacker to observe the timing or libgmp call patterns of the pure‑PHP ladder, know the corresponding public key, and have access to a reused private key. While the EPSS is not provided, the attack is feasible in environments where such observations can be captured locally. The vulnerability is not yet listed in the CISA KEV catalog, but the fix is available in phpseclib 3.0.57 and 4.0.1.

Generated by OpenCVE AI on September 2, 2026 at 02:59 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade phpseclib to version 3.0.57 or 4.0.1 or later.
  • Enable the native Sodium engine in PHP or ensure ext‑sodium is available to bypass the pure‑PHP path.
  • Avoid reusing X25519 private keys—rotate keys frequently and use ephemerally generated keys for SSH exchanges.
  • If an upgrade is not possible, consider disabling the pure‑PHP X25519 implementation or restricting its use to highly trusted contexts.

Generated by OpenCVE AI on September 2, 2026 at 02:59 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-q97c-8qh3-fpc6 phpseclib — non-constant-time X25519 scalar multiplication permits full private-key recovery
History

Thu, 03 Sep 2026 18:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Wed, 02 Sep 2026 03:15:00 +0000

Type Values Removed Values Added
First Time appeared Phpseclib
Phpseclib phpseclib
Vendors & Products Phpseclib
Phpseclib phpseclib

Tue, 01 Sep 2026 22:00:00 +0000

Type Values Removed Values Added
Description phpseclib is a PHP secure communications library. Prior to 3.0.57 and 4.0.1, pure-PHP X25519 scalar multiplication in phpseclib/Math/PrimeField/Integer.php performs data-dependent conditional modular reductions in add() and subtract(). During the Montgomery ladder in phpseclib/Crypt/EC/BaseCurves/Montgomery.php, the reduction behavior of each step depends on the secret scalar prefix, creating per-step timing and libgmp call-count observations that can reveal a reused 251-bit clamped private scalar. The phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php derivation path invokes the pure-PHP multiplication without a native-engine check, while phpseclib/Crypt/EC/Formats/Keys/PKCS8.php reaches it when ext-sodium is unavailable. Exploitation requires a reused or long-lived X25519 private key, knowledge of the corresponding public key, execution of the pure-PHP path, and a local observer capable of resolving individual ladder steps or libgmp entry-point calls. Ephemeral X25519 keys, including phpseclib's normal SSH exchange path, are not affected. Recovery of the scalar permanently compromises operations that reuse that key. This issue is fixed in versions 3.0.57 and 4.0.1.
Title phpseclib — non-constant-time X25519 scalar multiplication permits full private-key recovery
Weaknesses CWE-208
CWE-385
References
Metrics cvssV3_1

{'score': 6.3, 'vector': 'CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N'}


Subscriptions

Phpseclib Phpseclib
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-09-03T17:41:50.214Z

Reserved: 2026-09-01T16:17:43.078Z

Link: CVE-2026-84308

cve-icon Vulnrichment

Updated: 2026-09-03T17:41:25.583Z

cve-icon NVD

Status : Deferred

Published: 2026-09-01T20:17:24.867

Modified: 2026-09-09T21:09:13.080

Link: CVE-2026-84308

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-02T03:00:13Z

Weaknesses