nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

Bug: custom-tool execution approval bypass on malformed args unbounded output buffering orphaned processes on timeout

Open tusharui opened this issue 2 months ago • 1 comments

Three tool-execution safety bugs found while auditing the approval and custom-tool runtime paths.

1. Approval bypass on malformed args (tool-confirmation.tsx:140-151) When tool args fail schema validation, the approval prompt is skipped and the call is auto-approved (onConfirm(true)). Tools can run without user consent. Fix: never auto-resolve true — show the validation error with the approval prompt and let the user decide.

2. Unbounded output buffering (custom-tools/handler.ts:63-81) Custom-tool stdout/stderr is accumulated with no byte limit; truncation only runs after the process exits. A large-output tool can exhaust memory. The built-in bash tool already caps this at 5 MB (bash-executor.ts). Fix: mirror that byte-budget pattern while streaming.

3. Timeout orphans processes and hangs forever (custom-tools/handler.ts:57-74,88-102) On timeout only the direct shell is SIGTERMed; grandchildren are not killed and can hold the pipes open, so the close event never fires and the call never returns. bash-executor.ts fixes this with detached + process-group kill + stream destroy. Fix: replicate that cleanup on timeout.

All three reproduced on current code. Regression tests can be provided. Labels: bug, area:tools, security

tusharui avatar Sep 07 '26 14:09 tusharui

Picking this up - a fix will follow shortly.

awhite0030 avatar Sep 13 '26 03:09 awhite0030