|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42670 require/include fail to read file with ../ in path
Submitted: 2007-09-14 12:47 UTC Modified: 2007-09-18 10:52 UTC
From: suicas at gmail dot com Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.2.4 OS: Solaris 10
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: suicas at gmail dot com
New email:
PHP Version: OS:


 [2007-09-14 12:47 UTC] suicas at gmail dot com
Trying to include or require a file containing '../' in its path fails with permission denied or file not found.

I've made sure that suhosin has not been loaded, and that safe mode is turned off while testing this, and can provide PHP's configure line and php.ini changes if needed.

This may to be related to closed bug #39351 (

Reproduce code:
File /www/included.php:
<?php echo 'Included ' ?>

File /www/a/index.php:
echo substr(sprintf('%o ', fileperms('/www/included.php')), -5);

echo substr(sprintf('%o ', fileperms('../included.php')), -5);

Expected result:
When viewing file /www/a/index.php from a web browser:
0644 Included 0644 Included

When running PHP from the command line on /www/a/index.php:
0644 Included 0644 Included

Actual result:
From a web browser:
0644 Included 0644
Warning: include(../included.php) [function.include]: failed to open stream: Permission denied in /www/a/index.php on line 6

Warning: include() [function.include]: Failed opening '../included.php' for inclusion (include_path='.:/opt/php5/lib/php') in /www/a/index.php on line 6

From the command line:
0644 Included

Warning: fileperms(): stat failed for ../included.php in /www/a/index.php on line 5

Warning: include(../included.php): failed to open stream: No such file or directory in /www/a/index.php on line 6

Warning: include(): Failed opening '../included.php' for inclusion (include_path='.:/opt/php5/lib/php') in /www/a/index.php on line 6


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-18 10:52 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #41822
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 20:05:44 2022 UTC