T09 · Insecure Skill Coding Practices
- Location
SKILL.md:143- Finding
Unrestricted Report Path Allows Arbitrary File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 143–145
Vulnerability Type: Arbitrary file overwrite through an unvalidated output path
Risk Level: MediumComplete Code Snippet:
python if output: with open(output, "w", encoding="utf-8") as f: json.dump(report, f, ensure_ascii=False, indent=2)Technical Analysis
The
report()method accepts a caller-suppliedoutputpath and opens it in truncating write mode ("w"). The implementation does not constrain the destination to an approved directory, normalize and validate the path, reject symbolic links or traversal sequences, check whether the destination already exists, or request confirmation before replacing it.Consequently, any caller capable of controlling the
outputargument can direct the process to replace an arbitrary file writable by the Agent's operating-system account. The replacement content is limited to the generated JSON report, so this is an arbitrary-location overwrite rather than an arbitrary-content write.Attack Path
- An attacker influences the report destination supplied to
DataAnalyzer.report(). - The attacker provides a traversal path, absolute path, or path to a symbolic link targeting an existing writable file.
open(output, "w")follows the supplied path and immediately truncates the target.json.dump()replaces the target's prior contents with the generated analysis report.- A configuration file, project artifact, data file, or writable script may consequently become corrupted or unusable.
Exploitation requires control over the
outputargument and write permission to the selected target through the Agent process.Impact Assessment
The vulnerability does not independently grant additional operating-system privileges. Its scope is limited to files writable by the account running the Skill. Within that boundary, exploitation can cause data loss, configuration co ...[truncated 235 chars]
- An attacker influences the report destination supplied to
- Remediation
View remediation
Remediation Suggestions
- Write reports only beneath a dedicated, application-controlled output directory.
- Resolve the canonical destination and verify that it remains inside the approved directory before opening it.
- Reject absolute paths, parent-directory traversal, and unexpected filename characters.
- Prevent symbolic-link attacks by rejecting symlink destinations and using platform-supported no-follow semantics where available.
- Use exclusive creation mode (
"x") when replacement is unnecessary. - If replacement is supported, require explicit overwrite authorization and validate that the existing destination is an expected regular file.
- Run the Skill with least-privilege filesystem permissions.
- Consider generating the report in a safely created temporary file and atomically moving it to the validated destination.
