T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:95
- Finding
- Workspace Boundary Bypass Through Unsafe String-Prefix Validation<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, line 95 **Vulnerability Type**: Improper path containment validation **Risk Level**: High ### Vulnerable Code ```markdown 2. **Path traversal prevention:** Always resolve with `realpath` and verify the result starts with the workspace root. ``` The equivalent instruction is duplicated in the translated section at line 173. ### Technical Analysis The Skill instructs the agent to validate a canonical file path by checking whether it starts with the workspace root. A plain string-prefix comparison does not reliably prove that the file is inside the intended directory. For example, if the workspace root is `/work/app`, the path `/work/application/secret.pdf` starts with `/work/app` as a string but is not contained within that directory. Using `realpath` resolves `..` components and symbolic links, but it does not make an unsafe prefix comparison directory-boundary-aware. Because successful validation is followed by uploading the selected file to Telegram, this flaw can cross a local confidentiality boundary. ### Attack Path 1. Determine or infer the workspace root, such as `/work/app`. 2. Identify a sibling directory whose name begins with the same prefix, such as `/work/application`. 3. Request a file such as `/work/application/secret.pdf`. 4. The Skill resolves the path with `realpath`. 5. A naive check such as `candidate.startsWith(workspaceRoot)` returns true. 6. The out-of-workspace file is submitted to the Telegram Bot API. 7. The recipient obtains data that the workspace restriction was intended to protect. ### Impact Assessment A successful exploit can disclose any agent-readable file located under a path that shares the workspace root's textual prefix. The vulnerability does not itself grant additional operating-system privileges, but it can expose files accessible to the current agent account and transmit them to an external Telegram chat. The precise scope depends on filesystem ...[truncated 49 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Canonicalize both the workspace root and candidate path using `realpath`. 2. Use a directory-boundary-aware containment check rather than a raw prefix comparison. 3. Accept the candidate only when it is equal to the workspace root or begins with the canonical root followed by the platform's directory separator. 4. Prefer a platform-native relative-path or containment API where available. 5. Confirm that the candidate is a regular file and revalidate it immediately before upload to reduce time-of-check/time-of-use risk. 6. Open the validated file without following symbolic links where the platform supports that behavior. A safe conceptual check is: ```text candidate == root OR candidate starts with root + directory_separator ``` Tests should cover sibling paths such as `/work/application` when the allowed root is `/work/app`. ]]>
