[php-src] PR #21871: ext/standard: Reject null bytes in proc_open() $cwd
| From: | LamentXU123 | Date: | Sat, 25 Apr 2026 07:39:07 +0000 |
| Subject: | [php-src] PR #21871: ext/standard: Reject null bytes in proc_open() $cwd | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35891@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21871
Author: LamentXU123
In function [
proc_open](https://www.php.net/manual/en/function.proc-open.php), although
the we check the parameter $commend to reject NUL bytes, we didn't actually check
$cwd, so this would happen:
```php
<?php
$cwd = sys_get_temp_dir() . '/php-src-proc-open-nul-poc'; @mkdir($cwd);
try { $proc = proc_open([PHP_BINARY, '-r', "echo getcwd(), PHP_EOL;"], [1 =>
['pipe', 'w']], $pipes, $cwd . "\0/ignored"); echo
stream_get_contents($pipes[1]); proc_close($proc); }
catch (ValueError $e) { echo $e->getMessage(), PHP_EOL; }
```
The output would be /php-src-proc-open-nul-poc, ignoring trailing
\0/ignored
reproduce in: https://3v4l.org/X0lWm#v