Skip to content

bugfix: Subprocesses inherit pipe descriptors from unrelated requests - #2558

Merged
zhuizhuhaomeng merged 1 commit into
masterfrom
codex-security/arp_0e9db855ff6207950ac7d86408c69390
Nov 28, 2026
Merged

zhuizhuhaomeng merged 1 commit into
masterfrom
codex-security/arp_0e9db855ff6207950ac7d86408c69390

Conversation

@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

All subprocess data pipes now close across unrelated execs.

  • A shared creator applies O_CLOEXEC atomically when pipe2 is available.
  • The portable fallback marks both endpoints with ngx_cloexec and fails closed on errors.
  • Every created stdin, stdout, and separate stderr pipe now crosses this enforcement boundary.
  • Existing dup2 handling preserves the current child's standard streams and merged-stderr behavior.
  • The regression source covers overlapping helpers, prompt EOF, and all three standard channels.

Static Verification Checks

  • Descriptor creation protected (Passed) — Runtime checks were not performed; ngx_http_lua_pipe_create statically establishes every data endpoint closes across exec.

  • All channels use helper (Passed) — ngx_http_lua_ffi_pipe_spawn routes stdin, stdout, and separate stderr creation through the protected helper, closing every cited path.

  • Child streams remain usable (Passed) — ngx_http_lua_ffi_pipe_spawn dup2 calls retain the current child's standard streams before exec, preserving legitimate subprocess I/O.

  • Fallback failures close safely (Passed) — ngx_http_lua_pipe_create closes both endpoints and restores errno when either ngx_cloexec call fails, preventing partial exposure.

  • Regression source covers isolation (Passed) — t/200-pipe-fd-isolation.t asserts prompt EOF with a concurrent helper and verifies stdin, stdout, and stderr remain functional.

  • Finding: acf_210c4913d59a9cd9d021853126edafd3

  • Patch: arp_0e9db855ff6207950ac7d86408c69390

  • Base commit: 5079ce71b15b21729ce3c5a75e98ddd1007fb619

  • Patch SHA-256: 5eb478632a5aa14ef02aa204debeb53cf8686a1c2cdd5dce7c2a3f16cb87a640

@zhuizhuhaomeng zhuizhuhaomeng changed the title [Codex Security] Subprocesses inherit pipe descriptors from unrelated requests bugfix: Subprocesses inherit pipe descriptors from unrelated requests Nov 28, 2026
@zhuizhuhaomeng
zhuizhuhaomeng marked this pull request as ready for review November 28, 2026 07:16
@zhuizhuhaomeng
zhuizhuhaomeng merged commit 57cfdc3 into master Nov 28, 2026
2 of 7 checks passed
@zhuizhuhaomeng
zhuizhuhaomeng deleted the codex-security/arp_0e9db855ff6207950ac7d86408c69390 branch November 28, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant