T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Unvalidated Project-Controlled Pointer Allows Writes Outside the Intended Storage Root
- Content
View full analysis
//`, containing: - `backlog/R-###.md` requirement cards - `execution-plan.md` scheduling view - `plans/` implementation-plan archives - Bridge: the `.wdp-prd` file in the project root contains the absolute path to the project's global root, namely `//`. Read it before every command operation. ``` The unsafe pointer is subsequently used by write operations, including: ```markdown 4. Update the field, set `updated` to the current date, and preserve `created`. 5. Rewrite `execution-plan.md` when affected. ``` ```markdown After the subagent produces an implementation plan, archive it to `/plans/.md`. ``` ```markdown Create the new card as `backlog/R-###.md`. Rewrite `execution-plan.md`. ``` ### Technical Analysis The Skill treats `.wdp-prd`, a file located in and therefore potentially controlled by the current project, as an authoritative absolute filesystem pointer. The instructions do not require the agent to: - Canonicalize the pointer with a real-path operation. - Confirm that the resolved target is beneath the canonical `PRD_ROOT`. - Reject symbolic links or path redirections. - Verify ownership or expected directory structure. - Ask for approval when an existing pointer targets an unexpected directory. - Prevent overwriting pre-existing files unrelated to the current project. Multiple commands then perform writes relative to this pointer, inc ...[truncated 2340 chars]- Remediation
View remediation
//`. - Require `.wdp-prd` to resolve exactly to that directory unless the user explicitly approves a migration. - Validate the slug against a restrictive pattern such as `^[a-z0-9]+(?:-[a-z0-9]+)*$`. 3. **Defend against symbolic-link traversal** - Reject a `.wdp-prd` file that is itself a symbolic link. - Check every existing path component from `PRD_ROOT` to the destination. - Refuse writes when `backlog`, `plans`, `execution-plan.md`, or their parent components resolve through unexpected symbolic links. 4. **Require confirmation for existing unexpected pointers** - Display the canonical source and destination paths. - Stop the operation unless the destination matches the expected project storage directory. - Do not silently accept a pointer supplied by a cloned repository. 5. **Use safe file-write procedures** - Create files with exclusive-create semantics when replacement is not intended. - For intended updates, write to a temporary file inside the validated destination and atomically rename it. - Verify the final destination immediately before replacement to reduce path-swap risks. 6. **Add negative security tests** - Test a pointer outside `PRD_ROOT`. - Test relative paths and traversal sequences. - Test a symlinked `.wdp-prd`. - Test symlinked `backlog` and `plans` directories. - Test an unexpected existing `execution-plan.md`. - Confirm that all such cases stop before any read or write occurs. ]]>
