T09 · Insecure Skill Coding Practices
- Location
SKILL.md:27- Finding
Unsanitized Numeric Input Is Interpolated into Executable JavaScript
- Content
View full analysis
- Remediation
View remediation
100) { throw new Error('Invalid cup count'); } let data = { water: [], sleep: [] }; try { data = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (error) { if (error.code !== 'ENOENT') { throw error; } } if (!Array.isArray(data.water) || !Array.isArray(data.sleep)) { throw new Error('Invalid health-data structure'); } data.water.push({ time: new Date().toISOString(), cups }); fs.writeFileSync(file, JSON.stringify(data)); ``` The update operation should use the same argument-based validation and should verify that a water record exists before attempting to modify the final entry. ]]>
