T09 · Insecure Skill Coding Practices
- Location
modules/priority.js:132- Finding
SQL Injection in Priority Cleanup Can Delete All Priority Records
- Content
View full analysis
- Remediation
View remediation
3650) { throw new TypeError('days must be an integer between 0 and 3650'); } const result = await this.db.run( `DELETE FROM memory_priorities WHERE priority_level = 4 AND created_at < datetime('now', ?)`, [`-${days} days`] ); return { deleted: result.changes }; } ``` Additionally: - Do not expose destructive cleanup methods directly to untrusted callers. - Require explicit authorization for retention or deletion operations. - Consider a dry-run mode that reports the number of records to be removed. - Execute destructive maintenance in a transaction and maintain a recoverable backup. - Add tests using quotes, comments, SQL operators, negative values, decimals, and excessively large values. ]]>
