Listen to this Post
The vulnerability resides in the `BinaryField` class constructor within Math/BinaryField.php. phpseclib uses binary fields to represent elliptic-curve points. The constructor computes a string of repeated `’0’` characters where the length equals the degree `$m` of the binary field. If an attacker forces the library to process a specially crafted X.509 certificate, PKCS8 key, or any ASN.1 structure that embeds an extremely large degree value, the constructor will attempt to allocate a string of that size. No upper bound was enforced prior to the patch, so a malicious value (e.g., $m = 1000000) triggers the creation of a huge string, causing excessive CPU consumption and memory exhaustion. The library becomes unresponsive, leading to a full denial‑of‑service condition. This issue is particularly hazardous because any PHP application that loads untrusted ASN.1 files – including X.509 certificates, RSA private or public keys in PKCS8 format, etc. – is affected. The fix introduced a hard‑coded limit of 571 degrees, throwing an `\OutOfBoundsException` if a larger value is provided. The patch also added a regression test that verifies the exception is thrown when an excessively large degree is supplied.
DailyCVE Form (3‑word max per line):
Platform: phpseclib PHP
Version: 3<3.0.34
Vulnerability: DoS via BinaryField
Severity: High (7.5)
Date: 2023‑11‑27
Prediction: Patch available 2023‑11‑27
What Undercode Say:
Check installed version composer show phpseclib/phpseclib | grep versions Update to patched version composer require phpseclib/phpseclib:^3.0.34 Verify the patch applied grep -r "Degrees larger than 571" vendor/phpseclib/phpseclib/Math/BinaryField.php
Exploit:
An attacker crafts an X.509 certificate containing a malicious ASN.1 binary-field degree (e.g., 1,000,000). When the certificate is parsed by a vulnerable phpseclib version, the library constructs a string of that length, exhausting CPU and memory. No special privileges are required; the certificate can be delivered over TLS, file upload, or any vector that causes the application to parse the ASN.1 data.
Protection from this CVE
- Upgrade to phpseclib 3.0.34 or newer as soon as possible.
- If upgrading is not immediately feasible, implement a whitelist for acceptable binary‑field degrees before trusting any ASN.1 input.
- Monitor for unexpected CPU spikes when processing certificates or private keys.
Impact
- Confidentiality: None.
- Integrity: None.
- Availability: Full – an attacker can completely disable the application with a single crafted certificate, turning it into a remote unresponsive service.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

