/

CVE-2026-51858

Severity:

CRITICAL RISK

(9.8)

Code Injection (CWE-94) in Camel TerminalToolkit Shell

CVE-2026-51858

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A critical code injection vulnerability in camel-ai camel allows the TerminalToolkit.shell_exec function to execute shell commands based on prompt-driven input without an approval boundary. An attacker who can influence prompts or otherwise reach this tool may cause arbitrary commands to run with the privileges of the hosting process.

Affected context

The issue occurs in camel-ai camel releases 0.2.91a1, 0.2.91a2, and 0.2.91a3 when the TerminalToolkit.shell_exec capability is exposed to prompt-driven workflows. Risk depends on whether untrusted users or content can influence tool invocation and whether the hosting process has access to sensitive files, services, or infrastructure.

Exploit preconditions

  • Attack surface: The TerminalToolkit.shell_exec function or an interface that exposes it to an agent
  • Required access: Ability to submit or influence prompts processed by the affected workflow
  • Trigger point: A prompt-driven request that causes shell execution without a separate approval decision
  • Why exploitation is possible: Prompt-derived tool actions are passed to a shell execution capability without an effective authorization boundary

Why this happens

The underlying bug is the direct connection of prompt-controlled behavior to a shell command execution function without an independent approval or authorization step. This treats generated tool input as trusted executable logic rather than untrusted data, allowing attacker-influenced content to reach command execution. The behavior maps to CWE-94: Improper Control of Generation of Code, because externally influenced input can cause executable commands to be generated or invoked.

Potential impact

  • An attacker may execute arbitrary commands with the application's privileges
  • Sensitive files, environment variables, or credentials could be disclosed
  • Application data or local configuration could be modified or deleted
  • The affected host or connected services could be compromised
  • Malicious commands could enable lateral movement or operational disruption

General mitigation guidance

Mitigation generally focuses on separating natural-language intent from privileged command execution and reducing trust in generated tool arguments.

Common defensive patterns include:

  • Require explicit, human-verifiable approval before executing shell commands
  • Prefer narrowly scoped, allowlisted operations over general-purpose shell access
  • Validate and constrain command arguments against structured schemas
  • Run tools in isolated environments with minimal filesystem, network, and operating-system privileges
  • Use dedicated service APIs instead of shell commands where practical
  • Treat prompts, retrieved content, and model-generated arguments as untrusted input
  • Apply execution time, resource, and audit controls to tool invocations

How teams detect issues like this

Organizations can look for:

  • Static analysis findings where prompt or model output flows into shell execution APIs
  • Code review signals showing agent tools with unrestricted command interpreters
  • Missing approval, authorization, allowlisting, or argument-validation checks before tool execution
  • Policies that block general-purpose shell access from untrusted agent workflows
  • Runtime telemetry recording tool calls, command metadata, invoking identity, approval state, and execution results
  • Automated security review rules that flag untrusted data reaching process-spawning or command-execution functions

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/1efc7b63bded3e4d39c54ff7b0caedf4
github.comgithub.com/camel-ai/camel/issues/4038

Frequently asked

questions

It may be exploitable through a remote or user-facing agent interface when untrusted users can influence prompts and the affected shell tool is available. The exact scope depends on deployment architecture and exposure.

Authentication requirements depend on the surrounding application. Any identity that can influence a prompt or invoke the relevant workflow may be sufficient if no independent approval boundary exists.

Do not connect prompt-generated content directly to unrestricted shell execution. Use explicit approval, narrowly allowlisted operations, strict argument validation, and least-privilege isolation.

Treat model output and prompt content as untrusted, enforce authorization at tool boundaries, monitor command execution, and test agent workflows for unintended paths from user input to privileged operations.

Find out what's already
exploitable in your codebase.