OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(plugin): preserve closed helper stdin under BusyBox ash (#2540)
Michael D'Angelo067bfcd61605
diff --git a/plugins/codex-security/scripts/launch_codex_security_mcp b/plugins/codex-security/scripts/launch_codex_security_mcpindex 909107203..d383d8758 100755--- a/plugins/codex-security/scripts/launch_codex_security_mcp+++ b/plugins/codex-security/scripts/launch_codex_security_mcp@@ -16,10 +16,10 @@ launch_node() {if [ "${1:-}" = "--helper" ]; thenshift# Preserve POSIX argv and HOME bytes without temporary files or consuming stdin.- helper_stdin=-+ helper_stdin_open=falseif (exec 4<&0) 2>&-; thenexec 4<&0- helper_stdin=4+ helper_stdin_open=truefiwait_helper() {if wait "$!" 2>&-; then exit 0; else exit $?; fi@@ -34,8 +34,15 @@ launch_node() {trap 'forward_signal HUP 129' HUPtrap 'forward_signal INT 130' INTtrap 'forward_signal TERM 143' TERM- printf '%s\000' "${HOME+x}" "${HOME-}" "$@" | od -An -v -tx1 | tr -d ' \n' |- "$node_command" "$server_path" --helper 3<&0 0<&"$helper_stdin" 4<&- &+ printf '%s\000' "${HOME+x}" "${HOME-}" "$@" | od -An -v -tx1 | tr -d ' \n' | {+ # BusyBox ash requires a literal close redirection for a closed stdin.+ if [ "$helper_stdin_open" = true ]; then+ exec 0<&4+ else+ exec 0<&-+ fi+ exec "$node_command" "$server_path" --helper 4<&-+ } 3<&0 &exec 4<&-wait_helperfidiff --git a/sdk/typescript/tests-ts/mcp-launcher.test.ts b/sdk/typescript/tests-ts/mcp-launcher.test.tsindex d9259c636..40777c1e0 100644--- a/sdk/typescript/tests-ts/mcp-launcher.test.ts+++ b/sdk/typescript/tests-ts/mcp-launcher.test.ts@@ -448,9 +448,17 @@ process.exitCode = 23;},);-test.skipIf(process.platform === "win32")(- "launches argument-only helpers with closed stdin",- async () => {+const busybox = process.platform === "linux" ? Bun.which("busybox") : null;+test+ .skipIf(process.platform === "win32")+ .each([+ { shell: "system shell", interpreter: [] },+ ...(busybox+ ? [{ shell: "BusyBox ash", interpreter: [busybox, "ash"] }]+ : []),+ ])(+ "launches argument-only helpers with closed stdin ($shell)",+ async ({ interpreter }) => {const node = Bun.which("node");if (node === null)throw new Error("Node is required for the launcher test.");@@ -480,9 +488,13 @@ process.exitCode = 23;"/bin/sh",["-c",- 'exec 0<&-; exec "$1" --helper probe "argument with spaces"',+ 'exec 0<&-; exec "$@"',"helper-test",+ ...interpreter,launcher,+ "--helper",+ "probe",+ "argument with spaces",],{encoding: "utf8",