T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:15
- Finding
- Unrestricted Output Path Allows Arbitrary File Overwrite## Vulnerability Details **File Location**: `SKILL.md`, lines 15 and 41 **Vulnerability Type**: Unrestricted user-controlled file path **Risk Level**: Medium ### Vulnerable Code Snippet The following is an English translation of the relevant instructions: ```text - outputPath (optional): defaults to reports/{date}-daily-report.md ... 3) Write to outputPath (ensure the parent directory exists) ``` ### Technical Analysis The skill accepts `outputPath` as an input and instructs the agent to create its parent directory and write the generated report to that path. It does not require the resolved path to remain under the intended `reports/` directory, reject absolute paths, remove traversal components, or prevent overwriting an existing file. Consequently, a caller can provide a path containing `../` components or an absolute path. If the underlying agent follows these instructions literally, the report may be written to any location permitted by the agent process. Creating missing parent directories further expands the set of reachable destinations. This is an arbitrary file-write and overwrite weakness rather than a privilege-escalation mechanism. The write remains limited by the filesystem permissions of the process executing the skill. ### Attack Path 1. An attacker invokes the skill with otherwise valid report data. 2. The attacker supplies an `outputPath` such as `../../target-file` or an absolute filesystem path. 3. The skill normalizes the date and generates the Markdown report. 4. Following the documented behavior, the agent creates the supplied path's parent directories if necessary. 5. The agent writes the report to the attacker-selected destination. 6. If the destination already contains a writable configuration, source, state, or data file, its contents may be replaced by the generated report. Successful exploitation requires the selected destination to be writable by the agent process. ### Impact ...[truncated 475 chars]
- Remediation
- ## Remediation Suggestions 1. Use a fixed, dedicated output root such as `reports/`. 2. Reject absolute paths and input containing parent-directory traversal components. 3. Resolve the requested path to its canonical absolute form and verify that it remains beneath the canonical output root. 4. Treat the user input as a filename or safe relative path rather than an unrestricted filesystem path. 5. Reject symbolic-link destinations that resolve outside the approved output directory. 6. Do not overwrite existing files by default; require explicit authorization or use exclusive file creation. 7. Permit directory creation only beneath the approved output root. 8. Run the skill with least-privilege filesystem permissions and test validation against absolute paths, traversal sequences, symbolic links, and encoded traversal variants.
