T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/inject_cookies.js:26
- Finding
- Overbroad Collection and Cross-Domain Injection of Authentication Cookies<![CDATA[ ## Vulnerability Details **File Location**: `scripts/inject_cookies.js`, lines 26-68 **Related Instructions**: `SKILL.md`, lines 31-40; `references/cookie-guide.md`, lines 12-18 **Vulnerability Type**: Excessive credential collection and cross-domain session injection **Risk Level**: High ### Complete Code Snippet ```javascript function parseCookies(cookieStr, defaultDomain = '.ad.qq.com') { if (!cookieStr) { console.error('ERROR: Cookie字符串为空,请设置 RAW_COOKIE 环境变量或修改脚本'); process.exit(1); } const cookies = []; const pairs = cookieStr.split(';').map(s => s.trim()).filter(Boolean); for (const pair of pairs) { const eqIdx = pair.indexOf('='); if (eqIdx === -1) continue; const name = pair.substring(0, eqIdx).trim(); const value = pair.substring(eqIdx + 1).trim(); if (!name) continue; // 根据cookie名推断域名 let domain = defaultDomain; if (['ptcz', 'ptui_loginuin', 'RK', 'p_uin', 'p_skey', 'pt4_token'].includes(name)) { domain = '.qq.com'; } else if (['RIO_TOKEN', 'RIO_TOKEN_HTTPS', 'x_host_key_access_https', 'x-client-ssid', 'DiggerTraceId', 'DiggerTraceIdTs'].includes(name)) { domain = '.woa.com'; } const cookie = { name, value, domain, path: '/', }; // 敏感cookie加安全属性 if (['gdt_mlogin', 'gdt_protect', 'tap_free_login_token', 'RIO_TOKEN', 'RIO_TOKEN_HTTPS', 'x_host_key_access_https'].includes(name)) { cookie.secure = true; cookie.httpOnly = true; cookie.sameSite = 'None'; } cookies.push(cookie); } return cookies; } ``` The associated instructions tell the user to run `document.cookie` and send the complete result to the Agent rather than supplying only narrowly scoped credentials. ### Technical Analysis The parser accepts every cookie in the supplied string. It does not enforce an allowlist of cookies required for the declared `ad.qq.com` UX test. It also recognizes selected authentication and internal-ne ...[truncated 2092 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace permissive parsing with a strict allowlist containing only the minimum cookies proven necessary for the specific `ad.qq.com` test. 2. Reject unexpected cookies rather than silently retaining them. 3. Do not request, process, or inject general `.qq.com` or internal `.woa.com` session credentials. 4. Prefer a dedicated, short-lived test account with no production campaign authority. 5. Use a narrowly scoped authentication artifact or Playwright storage state generated specifically for the test environment. 6. Clearly warn users never to provide complete browser cookie output. 7. Validate the target account and hostname before injecting any credentials. 8. Revoke or rotate existing credentials if complete session cookies have already been shared. ]]>
