Merge pull request #2801 from MoerAI/fix/null-byte-sanitization
fix(tool-execute-before): strip null bytes from bash commands to prevent crash (fixes #2220)
This commit is contained in:
@@ -41,6 +41,16 @@ export function createToolExecuteBeforeHandler(args: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return async (input, output): Promise<void> => {
|
return async (input, output): Promise<void> => {
|
||||||
|
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.writeExistingFileGuard?.["tool.execute.before"]?.(input, output)
|
||||||
await hooks.questionLabelTruncator?.["tool.execute.before"]?.(input, output)
|
await hooks.questionLabelTruncator?.["tool.execute.before"]?.(input, output)
|
||||||
await hooks.claudeCodeHooks?.["tool.execute.before"]?.(input, output)
|
await hooks.claudeCodeHooks?.["tool.execute.before"]?.(input, output)
|
||||||
|
|||||||
Reference in New Issue
Block a user