T09 · Insecure Skill Coding Practices
- Location
obsidian_cleaner.py:16- Finding
Undocumented Classification and Movement of Obsidian Notes as Attachments
- Content
View full analysis
Vulnerability Details
File Location:
obsidian_cleaner.py:16
Vulnerability Type: Excessive file-type scope leading to unintended file relocation
Risk Level: MediumVulnerable Code
python SUPPORTED_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.webp', '.pdf', '.docx', '.doc', '.txt', '.md'}The documented auto-discovery behavior in
SKILL.mdlists PNG, JPG, GIF, JPEG, WEBP, PDF, and DOCX files. The implementation additionally classifies.doc,.txt, and.mdfiles as attachments.Markdown files are the primary note format used by Obsidian. Consequently, a normal cleanup operation can move root-level notes into the attachment directory even though the user only requested attachment cleanup. The operation is performed automatically unless the user explicitly selects dry-run mode.
Technical Analysis
The file allowlist violates the principle of least surprise and grants the cleanup operation a broader scope than its documented purpose. File extensions alone are used to determine whether a root-level file should be moved, without distinguishing notes from attachments or requesting confirmation for potentially sensitive document types.
This is particularly unsafe for
.mdfiles because changing their location can alter Obsidian path resolution, break external automation, and invalidate links that depend on the note's original location. Although the operation moves rather than deletes files, it still modifies user data and vault structure.Attack Path
- A vault contains one or more root-level Markdown or text notes.
- The user invokes the documented attachment cleanup command without
--dry-run. find_loose_attachments()treats.mdand.txtfiles as supported attachments.- The files are passed to the move operation.
- The notes are relocated from the vault root into the configured attachment directory.
- Links, scripts, integrations, or workflows that expect the orig ...[truncated 634 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove note and text formats from the default attachment allowlist:
python SUPPORTED_EXTENSIONS = { '.png', '.jpg', '.jpeg', '.gif', '.webp', '.pdf', '.docx' } -
If
.md,.txt, or.docsupport is required, place those extensions behind an explicit command-line option such as--include-documents. -
Require interactive confirmation before moving note formats, unless a separate non-interactive confirmation flag is supplied.
-
Make dry-run the default behavior and require an explicit
--applyoption to modify the vault. -
Keep the documented extension list synchronized with the implementation.
-
Add tests verifying that root-level Markdown notes are not moved by the default cleanup operation.
-
