CVE-2024-27354
JSON

7.5high

phpseclib: guardrails needed on isPrime and randomPrime

Severity
7.5high CVSS:3.1 by CISA-ADP
Exploit likelihood
0.60% (higher than 50% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
mitre
Also known as
GHSA-2528-jw5q-ww88

Description

An issue was discovered in phpseclib 1.x before 1.0.23, 2.x before 2.0.47, and 3.x before 3.0.36. An attacker can construct a malformed certificate containing an extremely large prime to cause a denial of service (CPU consumption for an isPrime primality check). NOTE: this issue was introduced when attempting to fix CVE-2023-27560.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
phpseclib 1xbefore 1.0.23CVE List
phpseclib 2xbefore 2.0.47CVE List
phpseclib 3xbefore 3.0.36CVE List
phpseclib/phpseclib (Packagist)from 0.1.1 before 1.0.23, from 2.0.0 before 2.0.47, from 3.0.0 before 3.0.36GitHub Advisory Database
phpseclib phpseclibfrom 1.0.0 before 1.0.23, from 2.0.0 before 2.0.47, from 3.0.0 before 3.0.36NVD
debian debian_linux10.0NVD

All scores

CISA-ADP7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Classification

CWE-400

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

An issue was discovered in phpseclib 1.x before 1.0.23, 2.x before 2.0.47, and 3.x before 3.0.36. An attacker can construct a malformed certificate containing an extremely large prime to cause a denial of service (CPU consumption for an isPrime primality check). NOTE: this issue was introduced when attempting to fix CVE-2023-27560.

GitHub Advisory Database
Impact

Anyone trying to generate a prime and testing the primality of a number.

Patches

https://github.com/phpseclib/phpseclib/commit/ad5dbdf2129f5e0fb644637770b7f33de8ca8575

Workarounds

Using the GMP extension would probably help, assuming that one has its own guardrails.

Resources

https://github.com/phpseclib/phpseclib/commit/ad5dbdf2129f5e0fb644637770b7f33de8ca8575 https://www.usenix.org/system/files/conference/usenixsecurity25/sec25cycle1-prepub-599-shi-bing.pdf

NVD (es)

Se descubrió un problema en phpseclib 1.x anterior a 1.0.23, 2.x anterior a 2.0.47 y 3.x anterior a 3.0.36. Un atacante puede crear un certificado con formato incorrecto que contenga un valor principal extremadamente grande para provocar una denegación de servicio (consumo de CPU para una verificación de primalidad de isPrime). NOTA: este problema se introdujo al intentar solucionar CVE-2023-27560.

References

https://github.com/phpseclib/phpseclib/blob/master/phpseclib/Math/PrimeField.php#L49product, web
https://gist.github.com/katzj/ee72f3c2a00590812b2ea3c0c8890e0bthird-party-advisory, web
https://lists.debian.org/debian-lts-announce/2024/03/msg00002.htmlmailing-list, third-party-advisory, web
https://lists.debian.org/debian-lts-announce/2024/03/msg00003.htmlmailing-list, third-party-advisory, web
https://github.com/phpseclib/phpseclib/security/advisories/GHSA-2528-jw5q-ww88web
https://nvd.nist.gov/vuln/detail/CVE-2024-27354advisory
https://github.com/phpseclib/phpseclib/commit/2870c8fab3f132d2ed40a66c97a36fe5ab625698web
https://github.com/phpseclib/phpseclib/commit/ad5dbdf2129f5e0fb644637770b7f33de8ca8575web
https://github.com/phpseclib/phpseclib/commit/c55b75199ec8d12cec6eadf6da99da4a3712fe56web
https://github.com/FriendsOfPHP/security-advisories/blob/master/phpseclib/phpseclib/CVE-2024-27354.yamlweb
https://github.com/phpseclib/phpseclibpackage

Sources

SourceRecordLicence
CVE ListCVE-2024-27354 changed 2025-04-22CVE Terms of Use
GitHub Advisory DatabaseGHSA-2528-jw5q-ww88 changed 2026-05-06CC-BY-4.0
NVDCVE-2024-27354 changed 2026-06-17Public domain