|  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 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: jeffbencteux at gmail dot com
New email:
PHP Version: OS:


 [2021-07-07 18:50 UTC] jeffbencteux at gmail dot com
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:

* 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:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-12 15:35 UTC]
-Type: Security +Type: Bug
 [2021-07-12 15:35 UTC]
open_basedir bypasses are not considered to be security issues;
cf. <>
and <>.
 [2024-01-16 21:20 UTC] wed4fgd_ffg1 at gmail dot com
Nice solution...!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 16:01:29 2024 UTC