Packages / elysia / Security

HighVulnerabilityGHSA-8vch-m3f4-q8jfCVE-2025-66457Published 9 Dec 2025

Elysia affected by arbitrary code injection through cookie config

Your version

Affected releases · elysia

  • 1.x1.0.0 – 1.4.17Fixed in 1.4.18
  • 0.8.x and older0.1.0 – 0.8.17No fix, no longer updated

On 1.x, the newest line:

npm install elysia@1.4.18
Every release on a timeline
1.x
  1. Affected

    1.0.0 – 1.4.17

    121 releases

  2. Fixed

    1.4.18 – 1.4.30

    13 releases, latest

0.x
  1. Affected

    0.1.0 – 0.8.17

    132 releases

266 stable releases of elysia, oldest to newest, one row per major.

What happens

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.

Availability 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).

However when combined with GHSA-hxj9-33pp-j2cc, this vulnerability allows for a full RCE chain.

Impact

  • aot enabled (default)

  • cookie schema passed to route

  • Cookie config controllable eg. via env

Example of vulnerable code

new Elysia({
	cookie: {
		secrets: `' + console.log('pwned from secrets') + '`
	},
})
	.get("/", () => "hello world", {
		cookie: t.Cookie({
			foo: t.Any(),
		}),
	})

POC: github.com/sportshead/elysia-poc

Patches

Patched by 1.4.17 (#1564)

Reference commit:

Workarounds

Sanitize cookie-related env input

const overrideUnsafeQuote = (value: string) =>
	// '`' + value + '`'
	'`' + value.replace(/'/g, '\\`').replace(/\${/g, '$\\{') + '`'