CVE-2025-66457

CVE-2025-66457 is a high-severity code injection vulnerability in elysia (npm), affecting versions < 1.4.18. It is fixed in 1.4.18.

Summary

Elysia affected by arbitrary code injection through cookie config

Full technical description

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.

Workarounds

Sanitize cookie-related env input

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

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: https://github.com/sportshead/elysia-poc

Untrusted input is evaluated as executable code within the application's runtime environment. Typical impact: arbitrary code execution within the application's privilege context.

Affected versions

elysia (< 1.4.18)

Security releases

elysia → 1.4.18 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Patched by 1.4.17 (https://github.com/elysiajs/elysia/pull/1564)

Reference commit:

Frequently Asked Questions

  1. What is CVE-2025-66457? CVE-2025-66457 is a high-severity code injection vulnerability in elysia (npm), affecting versions < 1.4.18. It is fixed in 1.4.18. Untrusted input is evaluated as executable code within the application's runtime environment.
  2. Which versions of elysia are affected by CVE-2025-66457? elysia (npm) versions < 1.4.18 is affected.
  3. Is there a fix for CVE-2025-66457? Yes. CVE-2025-66457 is fixed in 1.4.18. Upgrade to this version or later.
  4. Is CVE-2025-66457 exploitable, and should I be worried? Whether CVE-2025-66457 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  5. What actually determines whether CVE-2025-66457 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  6. How do I fix CVE-2025-66457? Upgrade elysia to 1.4.18 or later.

Other vulnerabilities in elysia

Stop the waste.
Protect your environment with Kodem.