T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:225
- Finding
- Unsafe Direct Repository Modification and Broad Git Staging## Vulnerability Details **File Location**: `SKILL.md`, lines 225–227; conflicting safety guidance appears at line 16 **Vulnerability Type**: Unsafe file handling and overly broad Git staging **Risk Level**: Medium ### Vulnerable Code ```bash # Write content to temp file first, then copy to nb cp /tmp/note.md ~/.nb/<notebook>/ cd ~/.nb/<notebook> && git add . && git commit -m "Add note" nb <notebook>: index rebuild ``` The workflow also contradicts the explicit instruction at line 16: ```markdown > ⚠️ **IMPORTANT:** Never edit files in nb git repos (`~/.nb/*`) by hand! Always use the `nb` CLI to ensure proper indexing and Git commits. ``` ### Technical Analysis The documented workflow copies a predictable temporary file directly into an internal `nb` Git repository, bypassing the recommended `nb` interface. This can undermine assumptions about indexing, validation, naming, and automatic commit behavior. More importantly, `git add .` stages every changed or untracked file under the notebook repository rather than only the newly imported note. Any unrelated file already present in the repository can therefore be included in the resulting commit. If notebook synchronization is configured, the documented `nb sync` operation can subsequently transmit that committed content to the configured remote. Using a fixed shared path such as `/tmp/note.md` is also unsafe in multi-user or adversarial environments when another process can replace or manipulate the source before it is copied. ### Attack Path 1. A sensitive, unrelated, or attacker-controlled file is present in the target notebook repository, or an attacker able to manipulate the shared temporary directory replaces `/tmp/note.md`. 2. The user or agent follows the documented import workflow. 3. `cp` directly inserts the selected temporary content into the notebook repository. 4. `git add .` stages all modifications and untracked files in that repository, including unrelated content. 5. `git commit` record ...[truncated 843 chars]
- Remediation
- ## Remediation Suggestions 1. Replace the direct-copy workflow with the supported `nb` import command, such as the already documented `nb add` interface. 2. Do not use `git add .` for single-note imports. If direct Git interaction is unavoidable, stage only the intended path: ```bash git add -- "exact-note-file.md" ``` 3. Create temporary files securely with `mktemp`, restrictive permissions, and cleanup traps rather than using a predictable shared filename. 4. Validate that the source and destination are regular files and that the resolved destination remains inside the intended notebook. 5. Review staged changes with `git diff --cached --name-only` before committing. 6. Avoid direct edits to `~/.nb/*` so that validation, indexing, and commit behavior remain controlled by the `nb` CLI. 7. Before synchronization, inspect repository history and staged or committed files to prevent unintended remote disclosure.
