| CARVIEW |
Select Language
HTTP/2 302
server: myracloud
date: Sun, 28 Dec 2025 13:04:23 GMT
content-type: text/html; charset=iso-8859-1
content-length: 300
location: https://bugs.php.net/bug.php?id=81131
expires: Sun, 28 Dec 2025 13:04:23 GMT
cache-control: max-age=0
HTTP/2 200
server: myracloud
date: Sun, 28 Dec 2025 13:04:24 GMT
content-type: text/html; charset=UTF-8
content-length: 3081
set-cookie: PHPSESSID=481ap0pvic4p09hjnce0ed3aut; path=/
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-store, no-cache, must-revalidate
pragma: no-cache
x-frame-options: SAMEORIGIN
vary: accept-encoding
content-encoding: gzip
PHP :: Bug #81131 :: open_basedir bypass through bindtextdomain()
|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-06-12 17:24 UTC] jeffbencteux at gmail dot com
Description:
------------
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:
---------------
<?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 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:
--------------
/var/www/html/test.txt
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commitsRelated reports
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 28 13:00:01 2025 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) RETURN_FALSE; } + if (php_check_open_basedir(dir_name)) { + RETURN_FALSE; + } + retval = bindtextdomain(domain, dir_name); RETURN_STRING(retval); I'm not sure, though, whether not checking open_basedir is by design. Stas, what do you think?