{"id":"GHSA-8vch-m3f4-q8jf","summary":"Elysia affected by arbitrary code injection through cookie config","details":"Arbitrary code execution from cookie config. If dynamic cookies are enabled (ie there exists a schema for cookies), the cookie config is injected into the compiled route without first being sanitised.\n\nAvailability of this exploit is generally low, as it requires write access to either the Elysia app's source code (in which case the vulnerability is meaningless) or write access to the cookie config (perhaps where it is assumed to be provisioned by the environment). \n\nHowever when combined with GHSA-hxj9-33pp-j2cc, this vulnerability allows for a full RCE chain.\n\n### Impact\n- aot enabled (default)\n- cookie schema passed to route\n- Cookie config controllable eg. via env\n\nExample of vulnerable code\n```js\nnew Elysia({\n\tcookie: {\n\t\tsecrets: `' + console.log('pwned from secrets') + '`\n\t},\n})\n\t.get(\"/\", () =\u003e \"hello world\", {\n\t\tcookie: t.Cookie({\n\t\t\tfoo: t.Any(),\n\t\t}),\n\t})\n```\n\nPOC: https://github.com/sportshead/elysia-poc\n\n### Patches\nPatched by 1.4.17 (https://github.com/elysiajs/elysia/pull/1564)\n\nReference commit:\n- https://github.com/elysiajs/elysia/pull/1564/commits/26935bf76ebc43b4a43d48b173fc853de43bb51e\n- https://github.com/elysiajs/elysia/pull/1564/commits/3af978663e437dccc6c1a2a3aff4b74e1574849e\n\n### Workarounds\nSanitize cookie-related env input\n\n```typescript\nconst overrideUnsafeQuote = (value: string) =\u003e\n\t// '`' + value + '`'\n\t'`' + value.replace(/'/g, '\\\\`').replace(/\\${/g, '$\\\\{') + '`'\n```","aliases":["CVE-2025-66457"],"modified":"2026-02-04T03:09:32.992990Z","published":"2025-12-09T17:12:05Z","related":["CVE-2025-66456","CVE-2025-66457"],"database_specific":{"github_reviewed":true,"github_reviewed_at":"2025-12-09T17:12:05Z","nvd_published_at":"2025-12-09T20:15:54Z","cwe_ids":["CWE-94"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/elysiajs/elysia/security/advisories/GHSA-8vch-m3f4-q8jf"},{"type":"WEB","url":"https://github.com/elysiajs/elysia/security/advisories/GHSA-hxj9-33pp-j2cc"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-66457"},{"type":"WEB","url":"https://github.com/elysiajs/elysia/pull/1564"},{"type":"WEB","url":"https://github.com/elysiajs/elysia/commit/26935bf76ebc43b4a43d48b173fc853de43bb51e"},{"type":"WEB","url":"https://github.com/elysiajs/elysia/commit/3af978663e437dccc6c1a2a3aff4b74e1574849e"},{"type":"PACKAGE","url":"https://github.com/elysiajs/elysia"},{"type":"WEB","url":"https://github.com/sportshead/elysia-poc"}],"affected":[{"package":{"name":"elysia","ecosystem":"npm","purl":"pkg:npm/elysia"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.4.18"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/12/GHSA-8vch-m3f4-q8jf/GHSA-8vch-m3f4-q8jf.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}]}