Severity:

CRITICAL RISK

(9.8)

OS Command Injection in radare2-mcp JSON-RPC Command

CVE-2026-6942

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

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

radare2-mcp up to version 1.6.0 contains an OS command injection vulnerability in how user-controlled input is passed to r2_cmd_str() and ultimately to the system shell.

By sending shell metacharacters through JSON-RPC parameters, a remote unauthenticated attacker can bypass command filtering and execute arbitrary commands on the host running radare2-mcp.

Affected context

This vulnerability appears in deployments where radare2-mcp exposes its JSON-RPC interface and accepts commands that are ultimately executed via r2_cmd_str() on the underlying system.

It is relevant when:

  • The JSON-RPC API is accessible over a network (LAN, VPN, or internet)
  • Input received from clients is incorporated into shell commands or command lines
  • The command filter is either incomplete or can be bypassed by shell metacharacters

In such contexts, radare2-mcp can act as a conduit for executing OS-level commands under the privileges of the radare2-mcp process.

Exploit preconditions

  • Attack surface: Network-exposed JSON-RPC interface of radare2-mcp.
  • Required access: Remote unauthenticated access to the JSON-RPC endpoint; no prior credentials or local shell on the host are required.
  • Input control: Ability to supply JSON-RPC parameters that are concatenated or interpolated into strings processed by r2_cmd_str().
  • Trigger point: Invocation of functionality that passes user-controlled input into shell-executed command lines, where shell metacharacters are not safely handled.
  • Why exploitation is possible: The command filter does not fully neutralize or validate shell metacharacters; user-controlled data is effectively treated as part of a shell command, enabling the attacker to break out of the intended command context and inject arbitrary OS commands.

Why this happens

The underlying issue is improper neutralization of special elements used in an OS command (CWE-78).

User-provided values received via the JSON-RPC interface are incorporated into command strings passed to r2_cmd_str(), which ultimately interacts with the system shell.

Instead of treating user input as opaque data, the code allows shell metacharacters (such as command separators, redirection operators, or subshell syntax) to influence how the command line is parsed and executed.

This pattern—building shell commands from untrusted input and attempting to filter them rather than using strict argumentized execution or robust validation—creates a classic command injection sink.

Potential impact

  • Remote execution of arbitrary OS commands with the privileges of the radare2-mcp process
  • Full compromise of the host running radare2-mcp, including installation of backdoors or lateral movement tooling
  • Access to or modification of files and data accessible to the radare2-mcp user account
  • Use of the compromised host as a pivot to attack internal systems and networks
  • Disruption or sabotage of analysis workflows that depend on radare2-mcp

General mitigation guidance

Mitigations center on preventing untrusted input from influencing shell command structure and reducing the blast radius if a flaw occurs.

Common defensive patterns include:

  • Avoiding direct shell execution where possible: use APIs or libraries that accept structured arguments instead of building shell command strings.
  • If shell invocation is unavoidable, strictly separate command and arguments and pass untrusted data as non-interpreted parameters rather than part of a concatenated command line.
  • Implement allowlist-based validation for all command parameters, restricting inputs to expected formats (e.g., fixed tokens, numeric ranges, safe character sets).
  • Remove or significantly narrow any "pass-through" mechanisms that forward raw user input into r2_cmd_str() or similar sinks.
  • Run radare2-mcp under a dedicated, least-privileged account and apply OS-level sandboxing or containment (e.g., chroot, containers, seccomp, or similar) to limit the effects of a compromise.
  • Restrict network exposure of the JSON-RPC interface using firewalls, access control lists, or application-layer authentication where feasible.

How teams detect issues like this

Detection typically focuses on both code-level patterns and runtime behavior:

  • Static analysis: Search for instances where untrusted JSON-RPC parameters are concatenated into command strings passed to r2_cmd_str(), system(), popen(), or equivalent shell-executing functions. Flag uses of user input adjacent to shell metacharacters or format strings that construct command lines.
  • Code review: Examine JSON-RPC handlers for places where user input reaches command execution without strict input validation or proper argumentization. Pay attention to incomplete filters, blacklist-based sanitization, or ad-hoc escaping.
  • Policy enforcement: Enforce a development policy that forbids building shell commands from untrusted input and requires argument-based execution wrappers. Integrate this policy into code review checklists and CI pipelines.
  • Runtime monitoring: Use host-based intrusion detection, logging, and process monitoring to alert on suspicious child processes spawned by radare2-mcp, unusual command lines, or unexpected network connections originating from the radare2-mcp process.

Sources

SourceLink
github.comgithub.com/radareorg/radare2-mcp/commit/482cde6500009112a8bc0b3fa8d2ef6180581ec0
github.comgithub.com/radareorg/radare2-mcp/issues/45
vulncheck.comvulncheck.com/advisories/radare2-mcp-os-command-injection-via-shell-metacharacter-bypass

Frequently asked

questions

Yes. As described, a remote attacker who can reach the radare2-mcp JSON-RPC endpoint can exploit this issue without local access, provided the service is network-exposed.

No. The vulnerability is exploitable without authentication when the JSON-RPC interface is accessible, making it particularly dangerous in exposed environments.

The safest pattern is to remove any direct shell command construction from untrusted input. Use structured API calls or argumentized execution functions where user input is treated strictly as data, combined with allowlist validation and consistent input normalization.

Establish a secure coding guideline that prohibits concatenating user input into shell commands, require security-focused code review for all command execution paths, and employ static analysis checks aimed at identifying command injection sinks in JSON-RPC and other API handlers.

Find out what's already
exploitable in your codebase.