CVE-2024-27354

7.5 HIGH

📋 TL;DR

This vulnerability in phpseclib allows attackers to cause denial of service by providing a malformed certificate with an extremely large prime number, triggering excessive CPU consumption during primality checks. It affects all systems using vulnerable versions of phpseclib for certificate processing. The issue was introduced while attempting to fix a previous vulnerability (CVE-2023-27560).

💻 Affected Systems

Products:
  • phpseclib
Versions: 1.x before 1.0.23, 2.x before 2.0.47, 3.x before 3.0.36
Operating Systems: All operating systems running PHP with phpseclib
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using phpseclib for certificate parsing/validation is vulnerable. This includes SSH, SFTP, SSL/TLS implementations, and other cryptographic operations using phpseclib.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability due to CPU exhaustion, potentially affecting multiple services if phpseclib is used in critical authentication or encryption components.

🟠

Likely Case

Degraded performance or temporary service disruption when processing malicious certificates, particularly in web applications or API endpoints that accept user-provided certificates.

🟢

If Mitigated

Minimal impact with proper input validation, rate limiting, and updated libraries preventing certificate processing from consuming excessive resources.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the ability to provide a malformed certificate to the vulnerable system, which could be through various attack vectors including man-in-the-middle attacks or direct API calls.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.0.23, 2.0.47, or 3.0.36

Vendor Advisory: https://github.com/phpseclib/phpseclib/security/advisories/GHSA-8wvq-3gjj-8g6h

Restart Required: No

Instructions:

1. Identify phpseclib version in your project. 2. Update composer.json to require patched version. 3. Run 'composer update phpseclib/phpseclib'. 4. Test certificate functionality after update.

🔧 Temporary Workarounds

Input validation for certificates

all

Implement strict validation of certificate size and structure before passing to phpseclib functions

Rate limiting certificate processing

all

Limit the rate at which certificates can be submitted for processing to prevent DoS attacks

🧯 If You Can't Patch

  • Implement WAF rules to block certificates with unusually large prime numbers or malformed structures
  • Monitor CPU usage spikes during certificate processing and implement alerting for potential attacks

🔍 How to Verify

Check if Vulnerable:

Check composer.lock or vendor/phpseclib/phpseclib/VERSION file for version number. If version is below 1.0.23, 2.0.47, or 3.0.36, system is vulnerable.

Check Version:

php -r "require 'vendor/autoload.php'; echo phpseclib\Crypt\RSA::VERSION;"

Verify Fix Applied:

After updating, verify the version is at least 1.0.23, 2.0.47, or 3.0.36 depending on your major version. Test certificate processing functionality.

📡 Detection & Monitoring

Log Indicators:

  • Unusually long processing times for certificate validation
  • High CPU usage spikes correlated with certificate processing requests
  • Multiple failed certificate validation attempts from single source

Network Indicators:

  • Unusually large certificate payloads in network traffic
  • Multiple certificate submission attempts from single IP

SIEM Query:

source="application_logs" AND (message="*certificate*processing*timeout*" OR message="*phpseclib*error*")

🔗 References

📤 Share & Export