T09 · Insecure Skill Coding Practices
- Location
scripts/context-snapshot.js:77- Finding
Snapshot Clear Operation Retains Sensitive Context
- Content
View full analysis
Vulnerability Details
File Location:
scripts/context-snapshot.js, lines 77-81
Vulnerability Type: Improper deletion of sensitive information
Risk Level: MediumVulnerable Code
javascript else if (cmd === 'clear') { const snapshot = loadSnapshot(); if (snapshot) { saveSnapshot(snapshot.task, snapshot.findings, snapshot.pending, snapshot._clearedAt = new Date().toISOString()); } console.log(JSON.stringify({ ok: true, message: 'Snapshot cleared.' })); }Technical Analysis
The
clearcommand does not delete the snapshot or sanitize its sensitive fields. Instead, it loads the existing snapshot and writes the originaltask,findings, andpendingvalues back to the same file. The clearing timestamp is passed as thelastErrorargument, so the rewritten snapshot still contains the data that the user intended to remove.The command then unconditionally reports
"Snapshot cleared.", creating a false assurance that deletion succeeded. Because snapshots are explicitly designed to contain high-fidelity raw findings and may also contain error details, retained content can include sensitive project information.Attack Path
- Snapshot support is enabled.
- The agent invokes
savewith sensitive task context, findings, pending work, or error information. - The user or agent invokes
node scripts/context-snapshot.js clear. - The script reloads the snapshot and rewrites its sensitive contents instead of deleting them.
- A later invocation of
node scripts/context-snapshot.js load, or direct access by another process running as the same operating-system user, recovers the supposedly cleared information.
Impact Assessment
This issue causes unintended local retention and disclosure of snapshot content. The affected scope is the project-specific snapshot file under the operating system's temporary directory.
The flaw does not grant elevated privileges, bypas ...[truncated 315 chars]
- Remediation
View remediation
Remediation Suggestions
Implement
clearby deleting the snapshot file withunlinkSyncor its asynchronous equivalent rather than rewriting the existing values. Handle deletion errors explicitly and report success only after deletion completes.Example:
javascript import { readFileSync, writeFileSync, existsSync, chmodSync, unlinkSync } from 'fs'; // ... else if (cmd === 'clear') { try { if (existsSync(SNAPSHOT_FILE)) { unlinkSync(SNAPSHOT_FILE); } console.log(JSON.stringify({ ok: true, message: 'Snapshot cleared.' })); } catch (error) { console.error(JSON.stringify({ ok: false, error: 'Failed to clear snapshot.' })); process.exit(1); } }Add automated tests verifying that:
- Saving and then clearing a snapshot removes the file.
loadreturns no snapshot after clearing.- Deletion failures produce a nonzero exit status and do not claim success.
- Repeated
clearoperations are safely idempotent.
