T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:95
- Finding
- Unvalidated Cross-Agent Input Reaches Privileged SSH Commands## Vulnerability Details **File Location**: `SKILL.md`, lines 95–102 **Vulnerability Type**: Command injection and path traversal through unvalidated request parameters **Risk Level**: High **Vulnerable Code**: ```markdown When another agent sends a file request via sessions_send: ### Store a file: ssh USER@NAS-IP "mkdir -p ~/_agents/[agent]/[subfolder]/" # Copy/create file there ### Retrieve a file: ssh USER@NAS-IP "cat ~/_agents/[agent]/[file]" ``` ### Technical Analysis The File Master is instructed to incorporate the requesting agent's `agent`, `subfolder`, and `file` values into shell commands executed through SSH. The instructions do not require an allowlist, shell escaping, canonical-path validation, or containment beneath an approved storage root. If the File Master translates incoming natural-language requests directly into these command templates, a malicious or compromised agent could supply shell metacharacters or path traversal sequences. For example, separators, substitutions, or redirection syntax could alter the intended remote command. A path containing `../` could escape the expected agent directory even without successful shell injection. The vulnerability is especially significant because the command executes under the NAS account held by the centralized File Master. ### Attack Path 1. An attacker controls or compromises an agent permitted to communicate with the File Master. 2. The attacker sends a storage or retrieval request containing a crafted agent name, subfolder, or filename. 3. The File Master interpolates the supplied value into the documented `mkdir` or `cat` SSH command. 4. The remote shell interprets traversal sequences or injected shell syntax. 5. The attacker causes unauthorized file access or remote command execution with the NAS user's privileges. 6. Retrieved information or command output may be returned through the agent communication channel. ### Impact Assessment ...[truncated 553 chars]
- Remediation
- ## Remediation Suggestions - Do not construct shell commands from free-form agent messages. - Define a strict request schema with separate operation, agent identifier, and relative-path fields. - Allow only predefined agent identifiers and reject all unknown values. - Reject absolute paths, `..` components, control characters, and shell metacharacters. - Resolve the requested path to its canonical form and verify that it remains beneath the authorized agent root before every read or write. - Pass validated values as safely quoted arguments rather than concatenating them into a remote shell command. - Prefer a constrained storage service or SFTP library that does not invoke a shell. - Run the NAS connection under a dedicated, non-administrative account with access limited to the required storage root. - Record normalized operation details and reject ambiguous natural-language requests instead of attempting to infer executable commands.
