T09 · Insecure Skill Coding Practices
- Location
SKILL.md:14- Finding
Path Traversal Through Unsanitized Vocabulary Filenames
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 14-26
Vulnerability Type: Path traversal and arbitrary file write
Risk Level: MediumVulnerable Instruction Snippet
The following is an English translation of the complete relevant instruction block:
text Markdown file Save path: ~/.qclaw/workspace/vocabulary/words/ Filename: {word}.md Examples: context.md, proceed.md Interactive HTML learning card Save path: ~/.qclaw/workspace/vocabulary/words/ Filename: {word}.html Examples: context.html, proceed.htmlTechnical Analysis
The skill instructs the agent to place the user-supplied word directly into Markdown and HTML filenames. It does not require validation of the supplied value, removal of path separators, rejection of
..components, filename normalization, or verification that the resolved destination remains beneath the intended vocabulary directory.If the file-writing implementation follows these instructions literally, a value such as
../../targetcould resolve outside~/.qclaw/workspace/vocabulary/words/. Appending.mdor.htmldoes not prevent traversal because the directory components are processed before the final filename extension.This is an insecure filename-construction pattern under
T09: Insecure Skill Coding Practices.Attack Path
- An attacker supplies a purported vocabulary word containing path traversal components, such as
../../target. - The skill substitutes that value into
{word}.mdand{word}.html. - The resulting paths contain parent-directory references.
- The file-writing tool resolves the paths outside the intended vocabulary directory.
- Existing writable files may be overwritten, or new files may be created at attacker-selected locations.
- The effect is limited by the operating-system permissions of the account running the agent.
Impact Assessment
Successful exploitation could provide arbitrary file ...[truncated 521 chars]
- An attacker supplies a purported vocabulary word containing path traversal components, such as
- Remediation
View remediation
Remediation Suggestions
- Treat the supplied word as untrusted input and derive a safe basename rather than using it directly.
- Allow only explicitly supported characters, such as ASCII letters, hyphens, and apostrophes, or apply a carefully defined Unicode-letter policy.
- Reject
/,\, null bytes, control characters, absolute paths, drive prefixes, and.or..path components. - Apply a reasonable maximum filename length.
- Resolve the destination to a canonical path and verify that it remains beneath the canonical vocabulary directory before writing.
- Construct paths with a safe path-joining API rather than string concatenation.
- Avoid overwriting existing files by default. Use exclusive creation or request confirmation when a destination already exists.
- Apply the same validation independently to both the Markdown and HTML destinations.
- Add negative tests for values such as
../../target,..\..\target,/tmp/target, encoded separators, control characters, and excessively long names.
