T09 · Insecure Skill Coding Practices
- Location
SKILL.md:225- Finding
Unsafe Direct Repository Modification and Broad Git Staging
- Content
View full analysis
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: MediumVulnerable 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 rebuildThe 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
nbGit repository, bypassing the recommendednbinterface. 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 documentednb syncoperation can subsequently transmit that committed content to the configured remote.Using a fixed shared path such as
/tmp/note.mdis also unsafe in multi-user or adversarial environments when another process can replace or manipulate the source before it is copied.Attack Path
- 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. - The user or agent follows the documented import workflow.
cpdirectly inserts the selected temporary content into the notebook repository.git add .stages all modifications and untracked files in that repository, including unrelated content.git commitrecord ...[truncated 843 chars]
- 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
- Remediation
View remediation
Remediation Suggestions
-
Replace the direct-copy workflow with the supported
nbimport command, such as the already documentednb addinterface. -
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" -
Create temporary files securely with
mktemp, restrictive permissions, and cleanup traps rather than using a predictable shared filename. -
Validate that the source and destination are regular files and that the resolved destination remains inside the intended notebook.
-
Review staged changes with
git diff --cached --name-onlybefore committing. -
Avoid direct edits to
~/.nb/*so that validation, indexing, and commit behavior remain controlled by thenbCLI. -
Before synchronization, inspect repository history and staged or committed files to prevent unintended remote disclosure.
-
