|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15547 tempnam() bypasses security
Submitted: 2002-02-14 02:18 UTC Modified: 2005-01-31 23:13 UTC
From: temisu at utu dot fi Assigned:
Status: Closed Package: Safe Mode/open_basedir
PHP Version: 4.0.6 OS: Linux(RedHat 7.1)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: temisu at utu dot fi
New email:
PHP Version: OS:


 [2002-02-14 02:18 UTC] temisu at utu dot fi
tempnam() function bypasses open_basedir directive
set by php.ini

This can be seen f.e. by following code:

// this is a success regardless of a open_basedir setting
// file is already created but fopen() fails if 
// open_basedir is set, but not to include /tmp


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-15 13:08 UTC]
Are you sure safe-mode is enabled? 
 [2002-02-18 01:44 UTC] temisu at utu dot fi
> Are you sure safe-mode is enabled?

No it is not. open_basedir seems to be independent directive
without connection to the safe-mode (Atleast, the directory 
restrictions work on other file-operations but not tempnam)

The following is example what triggered this in my code. 

php.ini has open_basedir=/www/htdocs and safe_mode= off

The working code...

// success if /www/htdocs/tmp/ exists and is writable
// directory
// opens the file.

The initial version, which does not care about the

// creates the temp-file.
// tries to open the file but does not succeed because of
// the open_basedir setting!
// Because (any other) file operations cannot be used on /tmp
// this code clutters the /tmp directory with zerobyte
// temp-files.
 [2002-02-18 10:20 UTC]
AFAIK, open_basedir restrictions only _work_ when having safe_mode ON.
 [2002-02-19 01:10 UTC] temisu at utu dot fi

says that

If instead of safe_mode, you set an open_basedir directory 
then all file operations will be limited to files under the specified directory For example (Apache httpd.conf example):
 [2002-02-20 15:37 UTC]
open_basedir is completely separate from safe_mode so this is actually a bug.
 [2002-07-02 02:17 UTC]
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at In case this was a documentation 
problem, the fix will show up soon at
In case this was a website problem, the change will show
up on the site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

 [2002-07-14 06:04 UTC] shane at aaatechnologiesaus dot net
open_basedir =/var/vhosts/sites:/tmp/
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 21 03:03:36 2021 UTC