T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/browser_ctl.mjs:328
- Finding
- Unprotected Plaintext Export of Authentication Cookies## Vulnerability Details **File Location**: `scripts/browser_ctl.mjs`, lines 328-337 **Vulnerability Type**: Plaintext credential exposure through an insufficiently protected command channel **Risk Level**: High ### Vulnerable Code ```javascript } else if (op === 'cookies') { // Export all cookies, including HttpOnly cookies such as SESSDATA try { const cookies = await ctx.cookies(); fs.writeFileSync(path.join(ROOT, 'cookies.json'), JSON.stringify(cookies, null, 2)); const names = cookies.map(c => c.name); log('[cookies] dumped', cookies.length, 'cookies;', 'SESSDATA=' + (names.includes('SESSDATA') ? 'present' : 'absent'), '| bili_jct=' + (names.includes('bili_jct') ? 'present' : 'absent')); } catch (e) { log('[cookies err]', e.message.slice(0, 100)); } } ``` ### Technical Analysis The browser controller uses a persistent browser profile and exposes a filesystem command channel through `cmd.txt`. When that file contains the `cookies` command, the controller calls `ctx.cookies()`, which returns all cookies available to the browser context, including HttpOnly authentication cookies. The complete cookie objects and their plaintext values are then written to `cookies.json` in the work directory. The implementation does not: - Restrict exported cookies to the current target domain. - Exclude authentication or anti-CSRF tokens. - Require interactive user confirmation. - Apply an explicit restrictive file mode such as `0600`. - Encrypt the exported data. - Automatically remove the file after use. Because browser cookies frequently function as bearer credentials, possession of this file may be sufficient to impersonate the authenticated user without knowing the account password. This behavior also conflicts with the statement in `README.md` that the tool does not store credentials. ### Attack Path 1. The user signs in to a supported website through the persiste ...[truncated 1261 chars]
- Remediation
- ## Remediation Suggestions 1. Remove the `cookies` command unless cookie export is essential to the documented workflow. 2. If export must remain, require explicit, interactive user approval for every export. 3. Restrict retrieval to an allowlisted domain associated with the current task. 4. Exclude known authentication, session, and anti-CSRF cookies by default. 5. Avoid writing cookie values to disk. Pass narrowly scoped values directly to the process that requires them. 6. If temporary storage is unavoidable, create the file atomically with mode `0600`, use a dedicated private directory, and delete it immediately after use. 7. Add warnings identifying the file as equivalent to an active login session. 8. Update the documentation so it accurately discloses any credential storage or export behavior. 9. Consider isolating each service in a separate browser context so a request for one service cannot expose cookies belonging to another service.
