T09 · Insecure Skill Coding Practices
- Location
index.js:117- Finding
Conversation records are permanently deleted without backup or importance validation
- Content
View full analysis
{ const aPath = path.join(CONFIG.memoryDir, a); const bPath = path.join(CONFIG.memoryDir, b); return fs.statSync(aPath).mtimeMs - fs.statSync(bPath).mtimeMs; }); const toDelete = sorted.slice(0, sorted.length - CONFIG.maxConversations); toDelete.forEach(file => { const filePath = path.join(CONFIG.memoryDir, file); fs.unlinkSync(filePath); log(`🗑️ 删除:${file}`, 'INFO'); }); log(`✅ 清理了 ${toDelete.length} 个旧会话记录`, 'SUCCESS'); } ``` ### Technical Analysis When more than ten matching conversation records exist, the function sorts them by modification time and permanently deletes the oldest entries with `fs.unlinkSync`. It does not create a backup, move records to an archive, validate their importance, or request confirmation. This behavior conflicts with the safeguards documented in `SKILL.md:133-138`, which claim that files are backed up before destructive processing and their importance is checked before deletion. Consequently, operators may rely on protections that are not actually implemented. The deletion loop also lacks per-file exception handling. A filesystem error can terminate the entire memory-management run after some files have already been deleted, leaving the operation only partially completed. ### Attack Path 1. The memory directory contains more than the configured maximum of ten files whose names match `conversation-*.json`. 2. An actor with write access to that directory can add matching files or manipulate file mod ...[truncated 913 chars]- Remediation
View remediation
