T09 · Insecure Skill Coding Practices
- Location
scripts/lib-cdp.mjs:117- Finding
Substring-based browser target selection exposes request data to unrelated pages ## Remediation Suggestions - Compare parsed, exact origins rather than matching substrings of complete URLs. - Bind execution to a specific CDP target ID and revalidate its origin immediately before evaluating requests. - Abort if the target navigates outside the authorized origin. - Avoid placing credentials in an untrusted page’s main-world JavaScript environment. - Add regression tests with attacker URLs containing the legitimate host in their query string, path, or hostname suffix.
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib-cdp.mjs:117–140;scripts/api_run.mjs:137–157;scripts/probe.mjs:56–79
Vulnerability Type: Incorrect origin validation and sensitive request exposure
Risk Level: HighTechnical Analysis
Browser targets are selected by checking whether their entire URL contains the intended host string:
js const list = await listTargets(port); const pages = list.filter(t => t.type === 'page'); let hit = urlPart ? pages.find(p => (p.url || '').includes(urlPart)) : pages[0];Both API execution and probing attach using this host substring:
js const cdp = await Cdp.attach({ port, urlPart: host }); await cdp.enableSession();The probe copies recorded headers and constructs a request that executes in the selected page:
js const hdrs = { ...(target.headers || {}) }; delete hdrs['content-type']; async function callUrl(url) { const expr = `(async () => { try { const opt = { method: ${JSON.stringify(target.method || 'GET')}, credentials: 'include' ${Object.keys(hdrs).length ? `, headers: ${JSON.stringify(hdrs)}` : ''} ${target.body ? `, body: ${JSON.stringify(target.body)}` : ''} }; const r = await fetch(${JSON.stringify(url)}, opt); const t = await r.text(); return JSON.stringify({ ok: true, status: r.status, ct: r.headers.get('content-type') || '', len: t.length, body: t.slice(0, 200000) }); } catch (e) { return JSON.stringify({ ok: false, err: String(e && e.message || e) }); } })()`;An unrelated page can include the expected host in its path or query string. If selected, its JavaScript environment receives the request arguments. An overridden
window.fetchcan inspect those arguments before any network request occurs; CORS does not prevent this interception.Attack Path
- An attacker gets a page opened in the debugging browser with a URL containing the authorized service host, such as `https://attacker.example/?target=servic ...[truncated 852 chars]
