Skip to content
Info disclosure Disclosed report Intermediate

linkinfo - openbasedir bypass on Windows PHP

The linkinfo function on Windows PHP did not enforce the open_basedir restriction, allowing an attacker to check for the existence of files outside the allowed directories. This could be abused to discover files on paths that should be inaccessible.

fms Follow

Originally disclosed on HackerOne

Bounty$500 Medium View original
  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 3 months

Upstream bug - windows linkinfo lacks openbasedir check

https://bugs.php.net/bug.php?id=76459

Summary

Description:

linkinfo function on windows doesn't implement openbasedir check, it can be seen by reviewing the source code. This could be abused to find files on paths outside of the allowed directories.

Windows: https://github.com/php/php-src/blob/master/ext/standard/link_win32.c#L88 Unix: https://github.com/php/php-src/blob/master/ext/standard/link.c#L85

Test script:

<?php $var1="c:\\jump"; print "checking $var1 ...".PHP_EOL; print @linkinfo($var1).PHP_EOL; $var1="c:\\jump\\folder\\file1.txt"; print "checking $var1 ...".PHP_EOL; print @linkinfo($var1).PHP_EOL; $var1="c:\\jump\\blabla"; print "checking $var1 ...".PHP_EOL; print @linkinfo($var1).PHP_EOL; Expected result: ---------------- Warning: linkinfo(): open_basedir restriction in effect Patch == http://git.php.net/?p=php-src.git;a=commit;h=289cb0f77c28b80a779170711f5e4e92cdd4fbdb Fixed for PHP 5.6.37, PHP 7.0.31, PHP 7.1.20, PHP 7.2.8 == http://php.net/ChangeLog-5.php#5.6.37 ## Impact Bypass openbasedir restriction set by hosting provider on a shared environment http://php.net/manual/en/ini.core.php#ini.open-basedir

The original report as published on HackerOne, by fms. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Windows implementation of linkinfo lacked the open_basedir check that the Unix version had, as the report notes by comparing source code.

Impact

An attacker could bypass the open_basedir restriction set by a hosting provider on a shared environment, potentially discovering files outside the allowed directories.

What the attacker needed

PHP on Windows; open_basedir restriction enabled; ability to run PHP code

The fix

The issue was fixed in PHP versions 5.6.37, 7.0.31, 7.1.20, and 7.2.8 by adding the missing open_basedir check.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

PHP has a setting called open_basedir that limits which folders a script can access, like a fence around a playground. On Windows, one function called linkinfo ignored that fence, so a malicious script could peek at files outside the allowed area. This matters on shared hosting where many users run code on the same server.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by fms

View all

33 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.