T09 · Insecure Skill Coding Practices
- Location
scripts/chatgpt-handler.js:162- Finding
Unconditional Plaintext Retention of Potentially Sensitive ChatGPT Conversations
- Content
View full analysis
Vulnerability Details
File Location:
scripts/chatgpt-handler.js, lines 20 and 101–187
Vulnerability Type: Unprotected sensitive-data storage and unsafe temporary-file handling
Risk Level: MediumVulnerable Code
javascript const CONFIG = { chatgptUrl: 'https://chatgpt.com', timeout: 30000, waitAfterType: 500, waitAfterSubmit: 10000, screenshotDir: '/tmp/chatgpt-screenshots' };javascript // 10. 保存截图(可选) await saveScreenshot(browser, targetId, query);javascript async function saveScreenshot(browser, targetId, query) { try { // 创建截图目录 if (!fs.existsSync(CONFIG.screenshotDir)) { fs.mkdirSync(CONFIG.screenshotDir, { recursive: true }); } // 生成文件名 const filename = `chatgpt-${Date.now()}-${hashQuery(query)}.png`; const filepath = path.join(CONFIG.screenshotDir, filename); // 截图 await browser.screenshot({ targetId: targetId, path: filepath, fullPage: false }); console.log(`📷 截图已保存:${filepath}`); return filepath; } catch (error) { console.error(`截图失败:${error.message}`); return null; } }Technical Analysis
Every successful search unconditionally calls
saveScreenshot, despite the comment describing the operation as optional. The screenshot captures the visible ChatGPT page, which can contain the submitted query, contextual information, and the generated response.The resulting PNG is stored persistently in the shared
/tmp/chatgpt-screenshotsdirectory. The implementation does not explicitly apply restrictive directory or file permissions, obtain user consent, provide an opt-out, encrypt the content, or remove old screenshots. The query-derived hash in the filename does not protect the screenshot contents and is not a cryptographic access-control mechanism.This creates a local data-retention weakness when ...[truncated 1354 chars]
- Remediation
View remediation
Remediation Suggestions
- Disable screenshots by default and require an explicit configuration option or per-request user consent to enable them.
- Avoid taking screenshots when prompts or responses may contain credentials, tokens, personal information, proprietary code, or other secrets.
- Store screenshots in a per-user private directory rather than a shared temporary path.
- Create the storage directory with mode
0700and ensure screenshot files are created with mode0600, while accounting for the browser API’s file-creation behavior. - Use securely generated, non-predictable filenames instead of timestamp-and-hash identifiers.
- Implement automatic deletion immediately after the screenshot’s intended use, or enforce a documented short retention period with reliable cleanup.
- Return the screenshot path only when necessary and avoid logging sensitive paths in multi-user environments.
- Add a startup or shutdown cleanup routine for stale screenshots, with safeguards against symbolic-link and path-manipulation attacks.
- Update the documentation to accurately state when screenshots are captured, where they are retained, and how users can disable or delete them.
