|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-25 21:59 UTC] jani@php.net
[2009-09-27 20:47 UTC] david at majorsecurity dot info
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ If you use a prefix (i.e myownprefix_ ) in your source code to make sure that only files containing this prefix can be opened, this can be bypassed within file_get_contents(). Let's say that you have placed 2 files in your htdocs folder: 1. /htdocs/david/myownprefix_home.php 2. /htdocs/david/home.php 3. /htdocs/bug.php Reproduce code: --------------- --- From manual page: function.file-get-contents --- Example code (bug.php): <?php if(isset($_GET['seite'])) { $seite = $_GET['seite']; $datei = nl2br(file_get_contents("./david/myownprefix_$seite.php")); echo $datei; } ?> Proof of concept: http://localhost/bug.php?seite=/../home Expected result: ---------------- Now this would open the file /htdocs/home.php and our defined prefix will be bypassed.