CVE-2025-1861

9.8 CRITICAL

📋 TL;DR

This CVE describes a buffer size limitation vulnerability in PHP's HTTP redirect parsing. When PHP processes HTTP redirect responses, it truncates location headers longer than 1024 bytes instead of the recommended 8000 bytes, potentially causing users to be redirected to incorrect or malicious URLs. This affects PHP applications that make HTTP requests and follow redirects.

💻 Affected Systems

Products:
  • PHP
Versions: PHP 8.1.* before 8.1.32, PHP 8.2.* before 8.2.28, PHP 8.3.* before 8.3.19, PHP 8.4.* before 8.4.5
Operating Systems: All operating systems running affected PHP versions
Default Config Vulnerable: ⚠️ Yes
Notes: Any PHP application using HTTP client functionality (like file_get_contents with HTTP contexts, curl, or other HTTP libraries) that follows redirects is vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could redirect users to malicious sites for phishing, malware distribution, or credential theft by crafting HTTP responses with specially truncated location headers.

🟠

Likely Case

Users could be redirected to unintended or malicious websites when interacting with PHP applications that follow HTTP redirects from untrusted sources.

🟢

If Mitigated

With proper input validation and URL verification, the risk is reduced to potential service disruption from incorrect redirects.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the PHP application to make HTTP requests to attacker-controlled servers or servers that can be manipulated to return malicious redirects.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: PHP 8.1.32, PHP 8.2.28, PHP 8.3.19, PHP 8.4.5

Vendor Advisory: https://github.com/php/php-src/security/advisories/GHSA-52jp-hrpf-2jff

Restart Required: Yes

Instructions:

1. Identify PHP version using 'php -v'. 2. Update PHP to patched version using your package manager (apt-get upgrade php, yum update php, etc.). 3. Restart web server (apache2 restart, systemctl restart nginx, etc.). 4. Verify update with 'php -v'.

🔧 Temporary Workarounds

Disable HTTP redirect following

all

Configure PHP HTTP clients to not automatically follow redirects, requiring manual handling of redirect responses.

For file_get_contents: stream_context_set_default(['http' => ['follow_location' => 0]])
For cURL: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false)

Validate redirect URLs

all

Implement custom redirect handling that validates location URLs before following them.

Manual implementation required - check URL length and domain before redirecting

🧯 If You Can't Patch

  • Implement network controls to restrict outbound HTTP requests from PHP applications to trusted domains only
  • Deploy WAF rules to detect and block malicious redirect patterns in HTTP responses

🔍 How to Verify

Check if Vulnerable:

Run 'php -v' and check if version falls within affected ranges: 8.1.0-8.1.31, 8.2.0-8.2.27, 8.3.0-8.3.18, 8.4.0-8.4.4

Check Version:

php -v | grep -oP 'PHP \K[0-9]+\.[0-9]+\.[0-9]+'

Verify Fix Applied:

Run 'php -v' and confirm version is 8.1.32+, 8.2.28+, 8.3.19+, or 8.4.5+

📡 Detection & Monitoring

Log Indicators:

  • Unusual redirect patterns in application logs
  • HTTP requests to unexpected domains following redirects

Network Indicators:

  • HTTP 3xx responses with location headers longer than 1024 bytes
  • Redirects to suspicious or unexpected domains

SIEM Query:

source="php.log" AND ("Location:" AND length>1024) OR ("redirect" AND "unexpected")

🔗 References

📤 Share & Export