Skip to content

[Bug]: validatePrompt blocks legitimate developer prompts via overly broad pattern matching #2249

@louisgv

Description

@louisgv

What happened?

The validatePrompt() function in packages/cli/src/security.ts uses a blocklist of regex patterns intended to prevent shell injection. However, several patterns are broad enough to reject perfectly valid natural-language prompts that developers would reasonably send to an AI coding agent.

Examples of blocked legitimate prompts

  • "Fix the merge conflict >> registration flow" — caught by the >> redirection pattern
  • "Run tests && deploy if they pass" — caught by the && chaining check
  • "The output where X > Y is slow" — caught by > redirection pattern
  • "Add a heredoc to the Dockerfile" — caught by the << heredoc pattern

Why this is a problem

The prompt is not executed as a shell command — it is passed to a remote AI agent. The security concern (preventing shell injection into the spawn CLI itself, e.g. via argument quoting) is valid, but the current implementation validates the semantic content of what the user wants to ask the agent, not just the transport-layer safety of the string.

This creates a confusing UX where spawn refuses to process queries that contain common programming terminology (>>, &&, >, heredocs) simply because those characters appear in natural language.

Suggested fix

  1. Scope the validation more narrowly to the string as it will be embedded (e.g., check after escaping/quoting, not before)
  2. Or: validate only the CLI argument transport path rather than the full prompt content
  3. At minimum, add tests that assert common developer phrasings are not rejected

Notes


Filed from Slack by Ori

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin-progressIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions