/

CVE-2026-117573

Severity:

HIGH RISK

(7.8)

OS Command Injection (CWE-78) in hagent MCP Tools

CVE-2026-117573

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(7.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

hagent contains an OS command injection vulnerability in the hagent_arduino and hagent_esp32 tools, where MCP-supplied arguments are incorporated into shell commands without adequate neutralization. An MCP client or prompt-injected agent may cause commands to run with the privileges of the hagent MCP server when crafted argument values reach the affected execution paths.

hagent contains an OS command injection vulnerability in the hagent_arduino and hagent_esp32 tools, where MCP-supplied arguments are incorporated into shell commands without adequate neutralization. An MCP client or prompt-injected agent may cause commands to run with the privileges of the hagent MCP server when crafted argument values reach the affected execution paths.

Affected context

The issue occurs in hagent deployments that expose the affected Arduino or ESP32 MCP tools and pass their args values into arduino-cli or idf.py command execution. Risk depends on whether an MCP client or an agent influenced by untrusted content can invoke these tools and whether the server process has access to sensitive files, credentials, devices, or other system resources.

The issue occurs in hagent deployments that expose the affected Arduino or ESP32 MCP tools and pass their args values into arduino-cli or idf.py command execution. Risk depends on whether an MCP client or an agent influenced by untrusted content can invoke these tools and whether the server process has access to sensitive files, credentials, devices, or other system resources.

Exploit preconditions

  • Attack surface: MCP tool interfaces for hagent_arduino and hagent_esp32
  • Required access: The ability to invoke the affected tools or influence an agent that can invoke them
  • Trigger point: Processing the tools' args parameter before subprocess execution
  • Why exploitation is possible: User-controlled argument data is interpolated into shell commands executed with shell=True, allowing shell metacharacters to alter command interpretation
  • Attack surface: MCP tool interfaces for hagent_arduino and hagent_esp32
  • Required access: The ability to invoke the affected tools or influence an agent that can invoke them
  • Trigger point: Processing the tools' args parameter before subprocess execution
  • Why exploitation is possible: User-controlled argument data is interpolated into shell commands executed with shell=True, allowing shell metacharacters to alter command interpretation

Why this happens

The vulnerability results from constructing shell commands with externally influenced argument values and passing them to subprocess.run(shell=True).

This pattern causes data intended as command arguments to be interpreted as shell syntax. It maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because input is not kept separate from executable command structure.

The vulnerability results from constructing shell commands with externally influenced argument values and passing them to subprocess.run(shell=True).

This pattern causes data intended as command arguments to be interpreted as shell syntax. It maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because input is not kept separate from executable command structure.

Potential impact

  • Execution of arbitrary commands as the hagent MCP server user
  • Access to files, environment variables, tokens, or source code available to that account
  • Modification of firmware projects, build artifacts, or local configuration
  • Installation of additional tooling or persistence within the runtime environment
  • Lateral movement or broader compromise where excessive permissions are available
  • Execution of arbitrary commands as the hagent MCP server user
  • Access to files, environment variables, tokens, or source code available to that account
  • Modification of firmware projects, build artifacts, or local configuration
  • Installation of additional tooling or persistence within the runtime environment
  • Lateral movement or broader compromise where excessive permissions are available

General mitigation guidance

Mitigation generally focuses on eliminating shell interpretation and reducing trust in tool arguments.

Common defensive patterns include:

  • Invoke subprocesses with argument arrays and shell execution disabled
  • Apply strict allowlists and type validation to tool parameters
  • Keep user-controlled values separate from command and option structure
  • Use secure-by-default tool interfaces that expose only required build operations
  • Run the MCP server with a dedicated least-privilege account and restricted filesystem access
  • Limit credentials, device permissions, network access, and environment exposure available to the process
  • Treat model-generated or prompt-derived tool arguments as untrusted input

Mitigation generally focuses on eliminating shell interpretation and reducing trust in tool arguments.

Common defensive patterns include:

  • Invoke subprocesses with argument arrays and shell execution disabled
  • Apply strict allowlists and type validation to tool parameters
  • Keep user-controlled values separate from command and option structure
  • Use secure-by-default tool interfaces that expose only required build operations
  • Run the MCP server with a dedicated least-privilege account and restricted filesystem access
  • Limit credentials, device permissions, network access, and environment exposure available to the process
  • Treat model-generated or prompt-derived tool arguments as untrusted input

How teams detect issues like this

Detection can focus on:

  • Static analysis rules identifying shell=True combined with interpolated or concatenated input
  • Searches for subprocess calls that construct commands through f-strings, formatting, or string concatenation
  • Code review checks for MCP tool parameters flowing into command execution without validation
  • Runtime monitoring for unexpected child processes, shell interpreters, or command-line changes
  • Policy enforcement that blocks shell-enabled subprocess APIs in services handling external or agent-generated input
  • Automated security review tools that flag command construction and untrusted data-flow paths

Detection can focus on:

  • Static analysis rules identifying shell=True combined with interpolated or concatenated input
  • Searches for subprocess calls that construct commands through f-strings, formatting, or string concatenation
  • Code review checks for MCP tool parameters flowing into command execution without validation
  • Runtime monitoring for unexpected child processes, shell interpreters, or command-line changes
  • Policy enforcement that blocks shell-enabled subprocess APIs in services handling external or agent-generated input
  • Automated security review tools that flag command construction and untrusted data-flow paths

Sources

SourceLink
github.comgithub.com/masc-ucsc/hagent
github.comgithub.com/masc-ucsc/hagent/blob/761eec627a1e6fb128a2a8ce9245aa595cc2f7af/hagent/mcp/mcp_arduino.py#L776
github.comgithub.com/masc-ucsc/hagent/blob/761eec627a1e6fb128a2a8ce9245aa595cc2f7af/hagent/mcp/mcp_esp32.py#L682
github.comgithub.com/masc-ucsc/hagent/issues/98
vulncheck.comvulncheck.com/advisories/hagent-through-commit-761eec6-os-command-injection-via-arduino-and-esp32-mcp-tools

Frequently asked

questions

Exploitability depends on how the MCP server is exposed. Any MCP client, integration, or prompt-injected agent able to invoke the affected tools may be able to reach the vulnerable command path.

The attacker generally needs tool-invocation access or the ability to influence an agent that has such access. The resulting impact is determined by the privileges of the hagent server process.

Avoid shell interpretation by using subprocess argument arrays with shell execution disabled, and validate tool parameters against narrowly defined allowlists.

Treat all client- and model-generated tool arguments as untrusted, enforce least privilege, review data flows into process execution, and use static or policy-based checks to prevent unsafe shell command construction.

Exploitability depends on how the MCP server is exposed. Any MCP client, integration, or prompt-injected agent able to invoke the affected tools may be able to reach the vulnerable command path.

The attacker generally needs tool-invocation access or the ability to influence an agent that has such access. The resulting impact is determined by the privileges of the hagent server process.

Avoid shell interpretation by using subprocess argument arrays with shell execution disabled, and validate tool parameters against narrowly defined allowlists.

Treat all client- and model-generated tool arguments as untrusted, enforce least privilege, review data flows into process execution, and use static or policy-based checks to prevent unsafe shell command construction.

Find out what's already
exploitable in your codebase.