T09 · Insecure Skill Coding Practices
- Location
scripts/write_ref_stub.py:13- Finding
Unrestricted Reference-Stub Path Allows Existing Files to Be Overwritten
- Content
View full analysis
{args.resonance_to}") for line in args.lines: lines.append(line) lines.append("") out = args.out out.parent.mkdir(parents=True, exist_ok=True) out.write_text("\n".join(lines), encoding="utf-8") ``` ### Technical Analysis The `--out` argument accepts an unrestricted absolute or relative filesystem path. The destination is not constrained to an approved workspace or reference directory. The script also does not validate the expected `.ref.txt` or `.md` extension, reject symbolic links, or refuse an existing destination. `Path.write_text()` opens the destination for truncating write. Consequently, an existing writable file is silently replaced. This behavior conflicts with the additive-only and no-overwrite guarantees declared in: - `SKILL.md:3` - `references/AGENT_CONTRACT.md:9,15` - `references/SECURITY.md:9,12` The vulnerability does not independently elevate operating-system privileges; it operates with the permissions of the invoking process. However, within that permission boundary, it provides an unrestricted file-overwrite primitive. ### Attack Path 1. An attacker influences a command, automation input, or agent-generated invocation of `write_ref_stub.py`. 2. The attacker supplies an existing writable file through `--out`, such as a project configuration, agent stat ...[truncated 1115 chars]- Remediation
View remediation
