{"id":"GHSA-w3hv-x4fp-6h6j","summary":"@grackle-ai/server has Missing WebSocket Origin Header Validation","details":"### Impact\n\nThe WebSocket upgrade handler in the server validates authentication (API key token or session cookie) but does not check the `Origin` header. A malicious webpage on a different origin could initiate a WebSocket connection to `ws://localhost:3000/ws` if it can leverage the user's session cookie (which is `SameSite=Lax`, allowing top-level navigations).\n\nThis enables **cross-origin WebSocket hijacking** — if a user visits a malicious site while a Grackle session is active, the attacker's page could open a WebSocket and subscribe to real-time events (session output, task updates, environment state).\n\n**Affected code:**\n- `packages/server/src/ws-bridge.ts:80-91` — connection handler accepts WebSocket upgrades without checking `req.headers.origin`\n\n### Patches\n\n**Fix:** Validate `req.headers.origin` against an allowlist before accepting connections:\n```typescript\nconst origin = req.headers.origin || \"\";\nif (origin && !origin.includes(\"localhost\") && !origin.includes(\"127.0.0.1\")) {\n  ws.close(4003, \"Invalid origin\");\n  return;\n}\n```\n\n### Workarounds\n\nEnsure the Grackle server is only accessible on `127.0.0.1` (the default). Do not use `--allow-network` in untrusted network environments.\n\n### Resources\n\n- CWE-346: Origin Validation Error\n- File: `packages/server/src/ws-bridge.ts`","modified":"2026-03-25T17:32:33.983104Z","published":"2026-03-25T17:27:48Z","database_specific":{"github_reviewed_at":"2026-03-25T17:27:48Z","nvd_published_at":null,"cwe_ids":["CWE-346"],"severity":"HIGH","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/nick-pape/grackle/security/advisories/GHSA-w3hv-x4fp-6h6j"},{"type":"PACKAGE","url":"https://github.com/nick-pape/grackle"}],"affected":[{"package":{"name":"@grackle-ai/server","ecosystem":"npm","purl":"pkg:npm/%40grackle-ai/server"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.70.3"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 0.70.2","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-w3hv-x4fp-6h6j/GHSA-w3hv-x4fp-6h6j.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N"}]}