Commit 6ec698758e5 for php
commit 6ec698758e50d0356a7befeca6b2bfaffffa15aa
Author: Jorg Sowa <jorg.sowa@gmail.com>
Date: Wed Oct 14 23:09:48 2026 +0200
Fix proc_open() null descriptor not inheritable on Windows
The nul handle was opened without security attributes, making it
non-inheritable. It was then passed to CreateProcess() via
STARTF_USESTDHANDLES, where the child cannot use a non-inheritable
handle. Use php_proc_open_security so the handle is inheritable, like
the pipe handles.
Closes GH-24335.
diff --git a/NEWS b/NEWS
index 1d855a4b1ec..aa752e0af38 100644
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,8 @@ PHP NEWS
when getpwnam_r() needs a larger buffer. (Ilia Alshanetsky)
. Fixed password_get_info() and password_needs_rehash() accepting malformed
bcrypt costs. (Ilia Alshanetsky)
+ . Fixed proc_open() null descriptor not being inheritable on Windows.
+ (Jorg Sowa)
- Tidy:
. Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 54a523a4291..ed01405e840 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -845,7 +845,7 @@ static zend_result set_proc_descriptor_to_blackhole(descriptorspec_item *desc)
{
#ifdef PHP_WIN32
desc->childend = CreateFileA("nul", GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &php_proc_open_security, OPEN_EXISTING, 0, NULL);
if (desc->childend == INVALID_HANDLE_VALUE) {
php_error_docref(NULL, E_WARNING, "Failed to open nul");
return FAILURE;