T09 · Insecure Skill Coding Practices
- Location
SKILL.md:134- Finding
Forced Replacement of an Existing CLAUDE.md File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 134–138
Vulnerability Type: Unsafe forced symbolic-link creation
Risk Level: MediumVulnerable Code
markdown - **CLAUDE.md compatibility** — After generating AGENTS.md, create a symbolic link in the repository root pointing to AGENTS.md: ```bash ln -sf AGENTS.md CLAUDE.mdtext ### Technical Analysis The Skill instructs the agent to execute `ln -sf AGENTS.md CLAUDE.md`. The `-f` option forces removal of an existing destination before creating the symbolic link. Consequently, an existing regular file or symbolic link named `CLAUDE.md` may be replaced without confirmation or backup. Although the Skill requires preservation and merge handling for an existing `AGENTS.md`, it provides no equivalent safeguard for `CLAUDE.md`. A repository may maintain independent, user-authored agent instructions in that file. Unconditional replacement can therefore destroy those instructions and redirect subsequent Claude-compatible agents to the generated `AGENTS.md`. This is an unsafe file-operation practice rather than privilege escalation: the command operates with the invoking agent's existing filesystem permissions and does not independently obtain additional privileges. ### Attack Path 1. A repository contains an existing, legitimate `CLAUDE.md` with project-specific instructions. 2. A user invokes this Skill to generate or update repository guidance. 3. The Skill generates or merges `AGENTS.md`. 4. It executes `ln -sf AGENTS.md CLAUDE.md`. 5. The existing `CLAUDE.md` entry is removed and replaced with a symbolic link. 6. The original content is lost unless separately recoverable through version control or backups. 7. Future Claude-compatible agents read generated `AGENTS.md` content through the link instead of the original instructions. ### Impact Assessment The impact is limited to files writable by the invoking process. No additional system privileges are gained. Within the targ ...[truncated 383 chars]- Remediation
View remediation
Remediation Suggestions
- Test for an existing destination before creating the link:
bash if [ ! -e CLAUDE.md ] && [ ! -L CLAUDE.md ]; then ln -s AGENTS.md CLAUDE.md else echo "CLAUDE.md already exists; preserving it." fi- If replacement is desired, require explicit user confirmation rather than using
-f. - Preserve an existing regular file by merging its relevant content or creating a timestamped backup before any replacement.
- Distinguish regular files, valid symbolic links, broken symbolic links, and directories, and handle each case safely.
- Avoid forced unlinking by default.
- If updates are necessary, use an atomic workflow: create a temporary link in the same directory, validate it, preserve the destination, and then rename it into place.
- Extend the Skill's existing merge-preservation policy to cover
CLAUDE.md, not onlyAGENTS.md.
