T09 · Insecure Skill Coding Practices
- Location
SKILL.md:5- Finding
Unsanitized Path Parameter Enables Directory Traversal, Unintended File Disclosure, and File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:5-6, 25, 79-81; parameter definition atconfig.yaml:9-12
Vulnerability Type: Path traversal caused by unsafe parameter interpolation
Risk Level: MediumVulnerable Code
SKILL.md:5-6:markdown - **Input file**: `/home/xie/桌面/papers/{{paper_name}}.pdf` - **Output file**: `/home/xie/桌面/analysis/{{paper_name}}.txt`SKILL.md:25:markdown Always use browser-file-upload to upload the file: `/home/xie/桌面/papers/{{paper_name}}.pdf`SKILL.md:79-81:markdown - **Target path**: `/home/xie/桌面/analysis/{{paper_name}}.txt` - **Write mode**: overwrite.config.yaml:9-12:yaml paper_name: type: string description: The paper filename without the .pdf or .txt suffix (for example: An_Evidential-Enhanced_Method) required: trueTechnical Analysis
The required
paper_nameparameter is interpolated directly into local input and output paths. Its schema accepts an unrestricted string and does not prohibit path separators,..components, absolute-path syntax, or other filesystem metacharacters. The workflow also explicitly instructs the agent to upload the resolved input file to an external Gemini service and overwrite the resolved output file.A crafted value containing traversal components can therefore cause path resolution outside the intended
papersoranalysisdirectory. Appending fixed.pdfand.txtsuffixes limits candidate filenames but does not prevent traversal to another file carrying the corresponding suffix.Successful exploitation depends on the MCP tools accepting the resulting path and the service account having permission to read or write the targeted file.
Attack Path
- An attacker supplies a crafted
paper_name, such as a value containing../path components. - The skill concatenates that value into
/home/xie/桌面/papers/{{paper_name}}.pdfwithout validation. - The filesystem normalizes the traversal components, ...[truncated 971 chars]
- An attacker supplies a crafted
- Remediation
View remediation
Remediation Suggestions
-
Restrict
paper_nameto a filename basename using a strict allowlist, such as:regex ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$ -
Explicitly reject:
/and\..path components- Absolute paths
- NUL and control characters
- Platform-specific drive or network-path prefixes
-
Resolve each constructed path to its canonical form before use and verify containment under the expected canonical directory:
- Input must remain under
/home/xie/桌面/papers/. - Output must remain under
/home/xie/桌面/analysis/.
- Input must remain under
-
Verify that the input is a regular PDF file rather than a symbolic link, device, or other special file. Where supported, open it with protections equivalent to
O_NOFOLLOW. -
Create output files safely:
- Refuse symbolic-link targets.
- Use least-privilege filesystem permissions.
- Prefer atomic creation or replacement.
- Require explicit confirmation before overwriting an existing file.
-
Display the canonical input and output paths and obtain user confirmation before uploading data externally or overwriting a local file.
-
Enforce validation in executable tooling or the MCP boundary rather than relying only on natural-language instructions in
SKILL.md.
-
