Back to skill

Security audit

ROS2 Control Execution

Security checks for vulnerabilities and agentic risk

Overview

This ROS 2 control skill is mostly purpose-aligned, but its safety wrapper has a real command-execution weakness in a high-impact robotics context.

Review before installing. Use only in a trusted ROS workspace, inspect config/config.json before each use, and do not run it with elevated privileges or against real hardware until the setup path handling is fixed and operational safeguards such as confirmation or dry-run are added.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/safe_ros2_control_execution.py:43
Finding

Untrusted ROS setup script execution and shell injection through an unquoted configuration path

Content
View full analysis
/dev/null) if [ -z "$ROS2_BIN" ]; then echo "Error: ros2 not found in PATH. Please source your ROS 2 environment before running setup." exit 1 fi ROS_SETUP_PATH="$(dirname "$(dirname "$ROS2_BIN")")/setup.bash" ``` ### Technical Analysis The wrapper reads `ros_setup_path` from `config/config.json` and interpolates it directly into a command executed using `bash -c`. Although `os.path.isfile()` verifies that the referenced path exists, it does not make the path safe for shell interpretation. A valid filename can contain spaces and shell metacharacters, causing Bash to interpret portions of the configured value as additional syntax. More fundamentally, the referenced file is intentionally sourced as executable shell code. `scripts/setup.sh` determines this trusted setup file from whichever `ros2` executable appears first in the caller-controlled `PATH`. It does not canonicalize the result or verify that the executable and derived `setup.bash` belong to a trusted, administrator-owned ROS installation. The final ROS command uses an argument array and does not use `shell=True`, but that protection does not apply to the earlier environment-initialization command. Consequently, the documentation's ...[truncated 1896 chars]
Remediation
View remediation
` directory. 3. During setup, use `command -v ros2`, canonicalize the result, and reject executables or setup files located in user-writable or unexpected directories. 4. Verify ownership and permissions for the ROS executable, its installation directory, and `setup.bash`. For system installations, require administrator ownership and reject files writable by untrusted users or groups. 5. Protect `config/config.json` with restrictive permissions and write it atomically. Treat every value read from it as untrusted configuration rather than as executable shell input. 6. Prefer constructing the required ROS environment without sourcing dynamically selected shell code. If this cannot be avoided, configure the trusted setup file explicitly rather than inferring it from `PATH`. 7. Add regression tests covering paths containing spaces, semicolons, command substitutions, quotes, and newline characters, as well as tests ensuring that untrusted ROS installation roots are rejected. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared purpose is limited to sandboxed ROS 2 control state changes, but the skill also instructs environment sourcing, setup execution, environment inspection, and filesystem-writing behavior. This mismatch is dangerous because users and automated policy may trust the narrow description while the skill performs broader system-modifying actions, which can enable unauthorized setup-time changes or hide risky behavior behind an apparently constrained interface.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill advertises shell-capable behavior and setup steps but does not declare any explicit tool scope such as permissions or allowed-tools. That omission weakens policy enforcement and review because an agent may invoke file reads or shell actions without a clearly bounded contract, increasing the chance of unintended command execution in a sensitive robotics environment.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module advertises 'strict safety' while forwarding arbitrary extra CLI arguments directly to ros2 control, which can let users invoke additional options or alter behavior in ways the wrapper does not inspect. In a control-execution context, misleading safety claims increase operator trust and reduce scrutiny, making dangerous state-changing operations more likely to be executed under false assumptions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill metadata says it supports load, switch, and unload operations, but the implementation also permits additional state-changing commands such as setting controller or hardware component state and reloading controller libraries. This broadens the operational authority of the wrapper beyond the declared scope, increasing the chance of unexpected or unsafe robot state changes by callers who trust the manifest description.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
93% confidence
Finding

The wrapper constructs a shell command using a config-controlled path and executes it via bash -c, so a malicious or malformed ros_setup_path can inject arbitrary shell syntax. Because this runs before the final ROS command and is used to populate the environment, compromise of the config file or setup path leads directly to arbitrary command execution in the wrapper's context.

Content

Scanner excerpt · scripts/safe_ros2_control_execution.py (reported line 55)May include surrounding context.

python
# Build the environment
    env_command = f"source {ros_setup_path} && env"
    try:
        env_proc = subprocess.run(['bash', '-c', env_command], stdout=subprocess.PIPE, text=True, check=True)
        ros_env = {}
        for line in env_proc.stdout.splitlines():
            if '=' in line:

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/safe_ros2_control_execution.py (reported line 93)May include surrounding context.

python
cmd_array.extend(extra)

    # Execute safely without shell=True
    sys.exit(subprocess.call(cmd_array, env=ros_env))

if __name__ == "__main__":
    main()

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The wrapper executes state-changing ROS 2 control commands immediately without any confirmation, dry-run mode, or explicit warning about the operational effect. In robotics/control environments, accidental invocation can stop controllers, switch hardware states, or disrupt running systems, so the lack of friction increases the likelihood of unsafe or unintended changes.

Content

No source excerpt is available for this finding.