T09 · Insecure Skill Coding Practices
Error
- Location
- src/lib/cookies.ts:146
- Finding
- Cross-Domain Forwarding of Authentication Cookies<![CDATA[ ## Vulnerability Details **File Location**: `src/lib/cookies.ts:146-164`; authentication header construction occurs at `src/lib/client.ts:104-109` **Vulnerability Type**: Cross-domain cookie-scope violation **Risk Level**: High ### Vulnerable Code ```ts // We need cookies from both startupschool.org and ycombinator.com // (SSO cookies may be on the ycombinator.com domain) const domains = [ "https://www.startupschool.org/", "https://account.ycombinator.com/", ]; if (chromeProfile || source !== "chrome") { log(`Reading cookies from ${source}${chromeProfile ? ` (profile: ${chromeProfile})` : ""}...`); const allCookies: Record<string, string> = {}; for (const url of domains) { const result = await getCookies({ url, browsers: [source], timeoutMs: 30_000, ...(chromeProfile ? { chromeProfile } : {}), }); Object.assign(allCookies, toCookieMap(result.cookies)); } ``` The merged collection is subsequently serialized without domain filtering: ```ts private baseHeaders(): Record<string, string> { return { "User-Agent": USER_AGENT, Cookie: cookiesToString(this.cookies), }; } ``` ### Technical Analysis The cookie extraction module retrieves cookies applicable to two distinct HTTPS origins: - `www.startupschool.org` - `account.ycombinator.com` It then merges the results into a single map that preserves only cookie names and values. Domain, path, security, expiration, and SameSite metadata are discarded. `YcClient` serializes every entry in this merged map into one `Cookie` header and sends it to `www.startupschool.org`. This behavior reproduces neither browser cookie-domain isolation nor standard cookie-jar matching. A cookie returned specifically for `account.ycombinator.com` can therefore be forwarded to `www.startupschool.org`, even if a browser would not attach that cookie to the request. Cookie-name collisions create an additional correctness issue: `Object.assign` causes cookies collected ...[truncated 1666 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Preserve full cookie metadata, including domain, host-only status, path, Secure, and expiration attributes. 2. Maintain separate cookie jars for `startupschool.org` and `account.ycombinator.com`. 3. Before each request, select cookies using standard URL matching rules rather than merging by name. 4. Explicitly allowlist the minimum cookie names required by Startup School. 5. Do not forward account-origin cookies merely because they appear session-related. 6. Handle duplicate cookie names according to domain and path specificity instead of using `Object.assign`. 7. Add tests proving that an account-only cookie is never attached to a Startup School request. 8. Consider using a standards-compliant cookie-jar library instead of constructing the `Cookie` header manually. ]]>
