Skip to content

[BUG] Malformed (unterminated-quote) command can partially execute before shell syntax error #529

Description

@edelauna

Problem (one or two sentences)

A command with an unterminated quote (e.g. sh -c 'echo a'; sh 'echo b) is currently blocked from auto-approval but can still be manually approved and sent to the terminal. The shell executes the well-formed prefix before hitting the syntax error, resulting in partial execution of the intended command.

Context (who is affected and when)

Affects any user who manually approves a command that Zoo Code flags as containing an unterminated quote. LLMs frequently generate malformed quoting when deeply nested quoting is required, so this surfaces in real usage — not just edge cases.

Reproduction steps

  1. Configure an allowlist that does not include sh (so auto-approval is blocked and the prompt appears).
  2. Ask the agent to run: sh -c 'echo a'; sh 'echo b (unterminated quote on the second sub-command).
  3. Manually approve the command when prompted.
  4. Observe: echo a executes and prints a; the shell then emits a syntax error for the malformed second statement.

Expected result

The command is rejected before reaching the terminal with a clear error message sent back to the agent (e.g. "Command contains an unterminated quote and cannot be executed. Please fix the quoting and retry.").

Actual result

The well-formed prefix (sh -c 'echo a') executes successfully; only the remainder causes a shell syntax error after partial execution has already occurred.

App Version

v3.53.0+

Additional notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions