php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23612 new "Security" related settings
Submitted: 2003-05-13 10:23 UTC Modified: 2010-12-21 19:22 UTC
From: dale at daledude dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.2RC2 OS: linux rh 7.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dale at daledude dot com
New email:
PHP Version: OS:

 

 [2003-05-13 10:23 UTC] dale at daledude dot com
I posted this as a response to bug #22410, but taking a chance to open it as a new feature request.

How about a virtual chroot, if you will, within php.ini and httpd.conf (needed per vhost). I hacked suexec for perl scripts to *actually* chroot to the vhosts directory tree. Needless to say this meant hardlinking required libs and executables to the vhosts directory tree, but was easy after creating a template directory tree to hardlink to. 

In the case of mod_php it would need to be a "fake" or internal chroot except for ticks, exec, system, etc calls where it can be safe to do an actual chroot() call since the external process will die off and the mod_php environment left in tact.

Here is a proposal of new settings...

* chroot_basedir:
All file operations are relative to this. Not including ticks, system, exec, dl, etc. Example (pseudo):

  <virtualhost domain.com>
    php_admin_value chroot_basedir = /home/virtual/domain.com
  </virtualhost>

  <?php fopen("/var/www/html/file.php"); ?>

The fopen would actually try to open "/home/virtual/domain.com/var/www/html/file.php". This might cause some overhead per function call. As I haven't even started to look at the best way to implement it I'm just guessing. Maybe the fopen arg can be manipulated the same place open_basedir is checked?


* chroot_execdir:
Jail to be in for ticks, exec, system, dl, etc. Follows same premise as chroot_basedir. Spawn a process chroot'd to this directory then execute the external command. Same way suexec does basically.


I am considering implementing the above. No idea where to start just yet. I *very* briefly fgrep'd php source for occurances of open_basedir to get a quick glimpse. Please contact me with remarks.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-21 19:22 UTC] johannes@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-21 19:22 UTC] johannes@php.net
open_basedir is quite close to your request.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 20 09:00:01 2025 UTC