|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72129 PHP_VALUE, PHP_ADMIN_VALUE... changed by environment variables set in .htaccess
Submitted: 2016-04-29 15:46 UTC Modified: 2021-12-04 18:23 UTC
From: ouroboros_17 at hotmail dot com Assigned: bukka (profile)
Status: Assigned Package: FPM related
PHP Version: 5.6.21 OS: Debian (all Linux distributions)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
40 + 3 = ?
Subscribe to this entry?

 [2016-04-29 15:46 UTC] ouroboros_17 at hotmail dot com
It is possible, for a malicious user, to change PHP configuration with a .htaccess file on Apache with PHP-FPM. It is not something trivial, but if he can upload a .htaccess in the www folder, he can break open_basedir restrictions (see example below).

This behaviour can be fixed:
- AllowOverride None in Apache configuration (a good practice but it is not really usual in the real world)
- prevent upload of .htaccess (application side, not related with PHP-FPM)
- disable mod_env

PHP as a module of Apache cannot be affected because only php_value can be set in .htaccess.

It should be documented at least, or it should be possible to disable the hability to set configuration via environment variables.

See bug #3991 too.

Test script:
Apache vhost
DocumentRoot /var/www
<Directory /var/www/>
  AllowOverride All

  <FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"

Options +FollowSymLinks -SymLinksIfOwnerMatch
SetEnv PHP_ADMIN_VALUE "open_basedir=/"

<?php symlink('/etc', 'foo');

PHP-FPM pool
php_admin_value[open_basedir] = /var/www

Access "index.php" with HTTP so it creates the symlink, see files in /etc via the URI.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-29 22:53 UTC]
-Assigned To: +Assigned To: fat
 [2017-10-24 07:45 UTC]
-Status: Assigned +Status: Open -Assigned To: fat +Assigned To:
 [2021-07-12 16:05 UTC]
-Type: Security +Type: Bug
 [2021-07-12 16:05 UTC]
> but if he can upload a .htaccess in the www folder, he can break
> open_basedir restrictions

open_basedir bypasses are not considered to be security issues;
cf. <>
and <>.

Besides that the possibility to upload a .htaccess to the web root
would be a serious issue of the application.

> /var/www/index.php
> ------------------
> <?php symlink('/etc', 'foo');

This code looks obviously malicious, so is not a security issue
according to <>.
 [2021-12-04 18:23 UTC]
-Type: Bug +Type: Feature/Change Request
 [2021-12-04 18:23 UTC]
This behaviour is on purpose and its mitigation (optional disabling) is treated as a feature.
 [2021-12-04 18:23 UTC]
-Assigned To: +Assigned To: bukka
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 07:01:34 2024 UTC