T09 · Insecure Skill Coding Practices
- Location
optimize.js:82- Finding
Deterministic Archive Filename Causes Silent Backup Overwrite
- Content
View full analysis
详细日志: archive/${DATE_STR}-detail.md\n`; fs.writeFileSync(dailyFile, optimized); ``` ### Technical Analysis The archive filename is derived only from the current date. Consequently, every optimization performed on the same day writes to the same archive path. Node.js `fs.writeFileSync()` opens an existing file for truncation by default. The code does not check whether the archive already exists, use exclusive creation, generate a unique version, or preserve the previous archive. A repeated execution can therefore silently overwrite the only detailed backup. This behavior contradicts the backup-first guarantee documented in `SKILL.md`. The subsequent rewrite of the active daily-memory file makes the problem more significant: if the archive is overwritten with an already summarized or otherwise changed version, the original detailed content may no longer exist anywhere. ### Attack Path 1. A daily-memory file larger than 1 KB exists for the current date. 2. The optimizer runs and writes the detailed content to `memory/archive/YYYY-MM-DD-detail.md`. 3. The active daily-memory file is rewritten. 4. The active file is subsequently expanded above the optimization threshold again. 5. The optimizer runs a second time on the same date. 6. `fs.writeFileSync()` truncates and replaces the existing archive without warning. 7. The previously archived detailed memory is irreversibly lost unless an independent external backup exists. This issue can be triggered accidentally through repeated scheduled or manual execution. Any acto ...[truncated 593 chars]- Remediation
View remediation
