T09 · Insecure Skill Coding Practices
- Location
SKILL.md:10- Finding
Path Traversal Through Unvalidated Filename Parameter
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 10, 29, 45, and 108
Vulnerability Type: Path traversal and unintended local file disclosure
Risk Level: HighThe skill accepts a caller-controlled
filenameand directly interpolates it into input and output paths:text - filename: 文件名(例如:xxx.txt) {input_dir}/{filename} {output_dir}/{filename_去掉扩展名} {output_dir}/{filename_去掉扩展名}/figure_{index}.pngTechnical Analysis
The instructions do not require the agent to validate that
filenameis a simple file name. There is no rejection of absolute paths, path separators,..traversal segments, symbolic links, unexpected extensions, or resolved paths outside the configured directories.Although the skill describes the input and output directories as fixed, direct path interpolation does not enforce that boundary. A value containing traversal components could resolve outside
/home/xie/桌面/analysis. The resulting content would be parsed as image prompts and sent to Gemini, creating a potential external disclosure channel for unintended local files.The same unvalidated value is used to derive an output directory beneath
/home/xie/桌面/images. Traversal components could therefore redirect directory creation and predictablefigure_{index}.pngwrites outside the intended output tree, subject to the agent's filesystem permissions.Attack Path
- An attacker or untrusted caller supplies a
filenamecontaining traversal components instead of a simple.txtbasename. - The agent concatenates that value with the configured input directory without canonicalization or containment validation.
- The resulting path resolves to a readable file outside the intended analysis directory.
- The agent reads and parses the unintended file.
- Parsed content is submitted to Gemini as image-generation prompts, potentially disclosing local information to an external service.
- The agent derives the ...[truncated 850 chars]
- An attacker or untrusted caller supplies a
- Remediation
View remediation
Remediation Suggestions
- Require
filenameto be a basename rather than a path. - Apply a strict allowlist, such as
^[A-Za-z0-9._-]+\.txt$. - Reject absolute paths, path separators, null bytes, and
..components. - Resolve the candidate input path to its canonical form and verify that it remains beneath
/home/xie/桌面/analysis. - Derive the output directory only from a sanitized basename with the extension removed.
- Canonicalize the output parent and verify containment beneath
/home/xie/桌面/imagesbefore creating directories or writing files. - Refuse symbolic-link input files and symbolic-link output directories unless they have been explicitly approved.
- Use non-overwriting file creation or require confirmation before replacing existing output files.
- Confirm the selected input file and external disclosure scope with the user before submitting its content to Gemini.
- Stop with an explicit error state whenever validation or containment checks fail.
- Require
