T09 · Insecure Skill Coding Practices
- Location
src/error-memory.js:25- Finding
Plaintext Cross-Session Storage of Conversation Content
- Content
View full analysis
Vulnerability Details
File Location:
src/error-memory.js:25, 41-56, 61-70, 87-94
Vulnerability Type: Plaintext sensitive-data persistence
Risk Level: MediumVulnerable Code
js const MEMORY_FILE = path.join(__dirname, '..', 'data', 'error-memory.json'); function loadMemory() { try { const dir = path.dirname(MEMORY_FILE); if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); if (!fs.existsSync(MEMORY_FILE)) return { errors: [], version: '1.0' }; const raw = fs.readFileSync(MEMORY_FILE, 'utf8'); return JSON.parse(raw); } catch { return { errors: [], version: '1.0' }; } } function saveMemory(data) { const dir = path.dirname(MEMORY_FILE); if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(MEMORY_FILE, JSON.stringify(data, null, 2), 'utf8'); } function logCorrection(category, detail, context = '') { if (!category || !CATEGORIES[category]) return { success: false, reason: 'Unknown error category' }; const memory = loadMemory(); const entry = { id: memory.errors.length + 1, category, detail: detail || '', context: context.slice(0, 200), timestamp: new Date().toISOString(), prevention: CATEGORIES[category].preventionPatterns, recurrenceCount: 0, }; memory.errors.push(entry); if (memory.errors.length > 200) { memory.errors = memory.errors.slice(-200); } saveMemory(memory); return { success: true, id: entry.id, recurrence: false }; }Technical Analysis
The exported
logCorrection()function stores caller-provided correction details and up to 200 characters of conversation context indata/error-memory.json. The information is serialized as plaintext and retained across sessions.The implementation does not:
- Require explicit consent before retaining conversation content.
- Detect or redact credentials, personal data, tokens, or other secrets.
- Encrypt retained content.
- configure restrictive fi ...[truncated 1839 chars]
- Remediation
View remediation
Remediation Suggestions
- Disable retention of raw conversation context by default and require explicit opt-in.
- Store only derived categories, counters, or keyed hashes where raw text is unnecessary.
- Apply secret and personal-data redaction before persistence.
- Use a configurable, user-specific application-data directory rather than the package installation directory.
- Create the directory with mode
0700and the state file with mode0600, subject to platform support. - Add tenant or user identifiers and enforce isolation when used in multi-user services.
- Implement time-based expiration in addition to the existing record-count limit.
- Document exactly what is retained, for how long, and how users can inspect or delete it.
- If raw context is operationally necessary, encrypt it using a key stored separately from the data file.
- Handle persistence failures explicitly rather than silently falling back to empty state, so operators can detect integrity and permission problems.
