CVE-2024-8927: cgi.force_redirect configuration is bypassable due to the environment variable collision

Published Sep 26, 2024
·
Updated

According to https://www.php.net/manual/en/security.cgi-bin.force-redirect.php, the configuration directive cgi.forceredirect prevents anyone from calling PHP directly with a URL like http://host.example/cgi-bin/php/secretdir/script.php. The default value of cgi.forceredirect is 1.

But there is a bug that can cause attackers to bypass restrictions and access php-cgi directly.

Other sources

cgi.forceredirect configuration is bypassable due to the environment variable collision

Microsoft

In PHP versions 8.1. before 8.1.30, 8.2. before 8.2.24, 8.3. before 8.3.12, HTTPREDIRECTSTATUS variable is used to check whether or not CGI binary is being run by the HTTP server. However, in certain scenarios, the content of this variable can be controlled by the request submitter via HTTP headers, which can lead to cgi.forceredirect option not being correctly applied. In certain configurations this may lead to arbitrary file inclusion in PHP.

NVD

Affected Software

14 affected componentsFixes available
PHP PHP<8.3.12
8.3.12
php-fpm PHP-FPM>=8.1.0<8.1.30
php-fpm PHP-FPM>=8.2.0<8.2.24
php-fpm PHP-FPM>=8.3.0<8.3.12
debian/php7.4<=7.4.33-1+deb11u5
7.4.33-1+deb11u8
debian/php8.2
8.2.26-1~deb12u18.2.28-1~deb12u1
PHP PHP>=8.1.0<8.1.30
PHP PHP>=8.2.0<8.2.24
PHP PHP>=8.3.0<8.3.12
Microsoft cbl2 php 8.1.29-1
Microsoft cbl2 php 8.1.29-1
Microsoft azl3 php 8.3.8-1
Microsoft azl3 php 8.3.12-1
Microsoft cbl2 php 8.1.30-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.3.12
  2. Upgrade

    Upgrade debian/php7.4 to a version that resolves this vulnerability.

    Fixed in 7.4.33-1+deb11u8
  3. Upgrade

    Upgrade debian/php8.2 to a version that resolves this vulnerability.

    Fixed in 8.2.26-1~deb12u1Fixed in 8.2.28-1~deb12u1
  4. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.1.30
  5. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.2.24
  6. Configuration

    Ensure cgi.force_redirect is set to 1 (default value is 1), because in affected versions the HTTP_REDIRECT_STATUS environment variable collision can cause cgi.force_redirect not to be correctly applied in certain configurations.

    PHP cgi.force_redirect = 1

Event History

Sep 26, 2024
CVE Published
via PHP·12:00 AM
Oct 7, 2024
Data Sourced
via Red Hat·07:56 PM
DescriptionSeverityAffected Software
Oct 8, 2024
CVE Published
via MITRE·03:56 AM
Data Sourced
via MITRE·03:56 AM
DescriptionSeverity
Data Sourced
via NVD·04:15 AM
DescriptionSeverityWeaknessAffected Software
Nov 1, 2024
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Updated
via Microsoft·07:00 AM
Description
Feb 27, 2025
Data Sourced
via Ubuntu·09:03 AM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-8927?

CVE-2024-8927 has a high severity due to its potential to allow unauthorized access to PHP scripts.

2

How do I fix CVE-2024-8927?

To fix CVE-2024-8927, update PHP to versions 8.3.12, 8.2.26-1~deb12u1, or 8.2.27 as appropriate.

3

Which versions of PHP are affected by CVE-2024-8927?

CVE-2024-8927 affects PHP versions from 8.1.0 to 8.1.30, 8.2.0 to 8.2.24, and from 8.3.0 to 8.3.12.

4

What configuration settings can mitigate CVE-2024-8927?

Setting cgi.force_redirect to a value that restricts access can mitigate the risks associated with CVE-2024-8927.

5

Is CVE-2024-8927 related to other PHP vulnerabilities?

Yes, CVE-2024-8927 is related to previous vulnerabilities affecting PHP’s handling of CGI scripts.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203