|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81131 open_basedir bypass through bindtextdomain()
Submitted: 2021-06-12 17:24 UTC Modified: 2021-07-12 17:23 UTC
Avg. Score:3.0 ± 1.4
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jeffbencteux at gmail dot com Assigned: stas (profile)
Status: Assigned Package: Gettext related
PHP Version: 8.0.7 OS: Debian 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
24 - 4 = ?
Subscribe to this entry?

 [2021-06-12 17:24 UTC] jeffbencteux at gmail dot com
It is possible to test for files and directories existence by using the $category parameter of the bindtextdomain() 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 bindtextdomain("test", "../test.txt");

Expected result:
Warning: bindtextdomain(): 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-01 15:29 UTC]
-Assigned To: +Assigned To: stas
 [2021-07-01 15:29 UTC]
The fix is trivial:

 ext/gettext/gettext.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 003787f5c0..cc027d57fd 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -278,6 +278,10 @@ PHP_NAMED_FUNCTION(zif_bindtextdomain)
+	if (php_check_open_basedir(dir_name)) {
+	}
 	retval = bindtextdomain(domain, dir_name);

I'm not sure, though, whether not checking open_basedir is by

Stas, what do you think?
 [2021-07-12 15:36 UTC]
-Type: Security +Type: Bug
 [2021-07-12 15:36 UTC]
open_basedir bypasses are not considered to be security issues;
cf. <>
and <>.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 05:01:28 2024 UTC