T09 · Insecure Skill Coding Practices
- Location
SKILL.md:36- Finding
Unsanitized Context Names Permit Path Traversal
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 36-58, 85-86, 111-112, 139-140, and 164-165
Vulnerability Type: Path traversal through user-controlled file names
Risk Level: HighVulnerable Code Snippets
md - `handoffs/sessions/<slot>.md`md - `projects/<project-name>.md` 项目名由用户指定;如果没有指定,先问。md 3. 写入: - `/root/.openclaw/workspace/handoffs/sessions/<slot>.md`md 2. 读取: - `/root/.openclaw/workspace/handoffs/sessions/<slot>.md`md 3. 写入: - `/root/.openclaw/workspace/projects/<project-name>.md`md 2. 读取: - `/root/.openclaw/workspace/projects/<project-name>.md`Technical Analysis
The Skill directly interpolates the user-provided
slotorproject-nameinto filesystem paths used for read and overwrite operations. Although it requires users to provide these names, it defines no validation rules, canonicalization procedure, or containment check.A crafted value containing parent-directory components such as
../can resolve outside the intendedhandoffs/sessionsorprojectsdirectory. Appending.mdlimits likely targets to Markdown files but does not prevent traversal.Because restore operations read and summarize the resolved file, this can expose accessible Markdown content. Because save operations overwrite the resolved file by default, it can also corrupt or replace accessible Markdown files. Actual reach depends on the filesystem permissions of the Agent process and the path produced after normalization.
Attack Path
- An attacker requests a session-context or project-summary save or restore operation.
- When prompted for a slot or project name, the attacker supplies a traversal value such as
../../projects/target. - The Skill constructs a path by inserting that value directly into the documented path template.
- Filesystem path normalization resolves the target outside the intended storage directory.
- For a restore operation, the Agent reads and s ...[truncated 637 chars]
- Remediation
View remediation
Remediation Suggestions
-
Accept only simple identifiers matching a strict allowlist, for example:
regex ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ -
Reject absolute paths,
.and..components, path separators, alternate separators, control characters, null bytes, and encoded separator variants. -
Construct the target from a fixed trusted base directory, resolve it canonically, and verify that the resolved path remains beneath that base directory before every read or write.
-
Apply the same validation and containment controls to both session slots and project names.
-
Reject symlinks and require the destination or source to be a regular file inside the approved directory.
-
For writes, use safe file-creation APIs and atomic replacement. Avoid following symlinks and consider requiring confirmation before replacing an existing file.
-
Add tests covering traversal inputs such as
../target,../../projects/target, absolute paths, mixed separators, and symlink-based escapes.
-
