Summary
Warp Agent code search tools contain an OS command injection flaw where Grep and FileGlob actions build shell commands directly from agent-controlled inputs and execute them in the active terminal.
When agents or tools can influence search text, paths, or glob patterns, this vulnerability can lead to unintended command execution and compromise of the developer's local environment.
Affected context
This vulnerability occurs in Warp's agentic development environment when Agent code search tools (Grep and FileGlob) are permitted to run within an active terminal session.
It manifests in workflows where agents are trusted to construct search queries or file patterns, and their inputs are turned into shell commands without sufficient validation or isolation.
The risk is elevated when agents consume untrusted project content, external prompts, or tool outputs that can influence the search parameters passed to the terminal.
Exploit preconditions
- Attack surface: Agent code search operations (Grep and FileGlob) running in a Warp terminal.
- Required access: Ability to control or influence agent inputs such as search strings, file paths, or glob patterns (directly or via upstream data/prompt injection).
- Trigger point: Execution of the Agent's search action, which constructs shell command strings and runs them in the user's active terminal session.
- Why exploitation is possible: The implementation treats agent-controlled parameters as trusted, interpolating them into shell commands without robust sanitization, escaping, or command separation, allowing injected shell syntax to be executed.
Why this happens
The underlying issue is a classic OS command injection pattern: application logic constructs shell commands by concatenating untrusted data and executes them without strict validation or escaping.
In Warp's Agent code search tools, Grep and FileGlob actions are conceptually read-only, but their implementations still rely on shell command execution, directly embedding agent-controlled inputs into the command line.
This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where user- or agent-supplied strings can introduce shell metacharacters or additional commands that the system executes.
Potential impact
- Agent-controlled inputs may cause arbitrary commands to run in the user's terminal session.
- Attackers could read or exfiltrate local files accessible to the terminal's user.
- Malicious commands could modify project source code or configuration files.
- Local environment integrity and tooling configurations can be tampered with.
- In some setups, injected commands may install additional tooling or backdoors for later misuse.
General mitigation guidance
Effective mitigation focuses on eliminating direct command construction from untrusted inputs and tightening trust boundaries around agent operations.
Recommended patterns include:
- Prefer parameterized, non-shell APIs (e.g., library calls for search and filesystem traversal) instead of building shell strings.
- When shell usage is unavoidable, strictly escape or validate all input, rejecting or constraining shell metacharacters and control operators.
- Treat agent-provided data as untrusted, enforcing strong input validation and limiting the set of allowed actions to clearly read-only operations.
- Run agent actions within a constrained execution context, such as sandboxed environments or minimal-permission sessions, reducing the blast radius of unexpected commands.
- Design policies that differentiate between "read/search" and "execute" capabilities, ensuring that tools labeled as read-only cannot trigger arbitrary command execution.
How teams detect issues like this
Detection can rely on both proactive and reactive techniques:
- Static analysis and code scanning rules targeting string concatenation or interpolation paths that feed into shell execution APIs (e.g., system calls, subprocess runners).
- Code review checklists that flag use of shell commands in components advertised as read-only, and require explicit justification and safety measures.
- Policy enforcement in CI/CD or internal tooling that rejects or warns on insecure command construction patterns, especially in agent-related or automation code.
- Runtime monitoring and logging that record executed commands originating from agent workflows, allowing teams to spot anomalous or unexpectedly complex command lines.

