From c56a01c15de7d5d1541083e619281f0da7a8d42c Mon Sep 17 00:00:00 2001 From: MoerAI Date: Tue, 24 Mar 2026 19:17:05 +0900 Subject: [PATCH] fix(tool-execute-before): strip null bytes from bash commands to prevent crash (fixes #2220) --- src/plugin/tool-execute-before.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugin/tool-execute-before.ts b/src/plugin/tool-execute-before.ts index 5d4f2c86e..d96bec02b 100644 --- a/src/plugin/tool-execute-before.ts +++ b/src/plugin/tool-execute-before.ts @@ -41,6 +41,16 @@ export function createToolExecuteBeforeHandler(args: { } return async (input, output): Promise => { + if (input.tool.toLowerCase() === "bash" && typeof output.args.command === "string") { + if (output.args.command.includes("\x00")) { + output.args.command = output.args.command.replace(/\x00/g, "") + log("[tool-execute-before] Stripped null bytes from bash command", { + sessionID: input.sessionID, + callID: input.callID, + }) + } + } + await hooks.writeExistingFileGuard?.["tool.execute.before"]?.(input, output) await hooks.questionLabelTruncator?.["tool.execute.before"]?.(input, output) await hooks.claudeCodeHooks?.["tool.execute.before"]?.(input, output)