T09 · Insecure Skill Coding Practices
- Location
SKILL.md:311- Finding
Remote Root Command Injection Through Unsanitized ROS Command Text
- Content
View full analysis
/dev/null 2>&1; ' "wait $E 2>/dev/null" ) cmd = f"{self._ros_env} && bash -c {repr(inner)}" _stdin, stdout, _stderr = self.ssh.exec_command(cmd, timeout=timeout + 10) ``` ### Technical Analysis The caller-provided `text` value is directly interpolated into a shell command enclosed in double quotes. The resulting command is passed to `bash -c` and remotely executed through an SSH session authenticated as `root`. Using `repr(inner)` only produces a Python representation of the complete command string. It does not make the embedded `text` safe for evaluation by the nested Bash process. Shell constructs accepted inside double quotes, including command substitution such as `$(...)` and backticks, can therefore be evaluated by Bash. For example, an input structurally equivalent to: ```text $(id) ``` would cause the remote shell to execute `id` while constructing the argument supplied to `rostopic`. Inputs containing quotes and shell operators may provide additional injection possibilities depending on the resulting quoting context. ### Attack Path 1. An attacker gains control of, or influences, the `text` argument passed to `send_cmd()`. 2. The value is embedded without shell-safe argument encoding into the `rostopic pub` command. 3. The client wraps the command in `bash -c`. 4. Paramiko sends the resulting command to the robot over SSH. 5. The remote Bash process interprets attacker-controlled shell syntax. 6. Because the SSH session uses the `root` account, injected commands execute with unrestricted system privileges. ### Impa ...[truncated 460 chars]- Remediation
View remediation
