Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

CVE-2025-66457

Elysia affected by arbitrary code injection through cookie config
Back to all
CVE

CVE-2025-66457

Elysia affected by arbitrary code injection through cookie config

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

Patches

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

Reference commit:

  • https://github.com/elysiajs/elysia/pull/1564/commits/26935bf76ebc43b4a43d48b173fc853de43bb51e
  • https://github.com/elysiajs/elysia/pull/1564/commits/3af978663e437dccc6c1a2a3aff4b74e1574849e

Workarounds

Sanitize cookie-related env input

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

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
7.5
-
4.0
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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
C
H
U
0
-
C
H
U
7.2
-
3.1
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

Related Resources

No items found.

References

https://github.com/elysiajs/elysia/security/advisories/GHSA-8vch-m3f4-q8jf, https://github.com/elysiajs/elysia/security/advisories/GHSA-hxj9-33pp-j2cc, https://nvd.nist.gov/vuln/detail/CVE-2025-66457, https://github.com/elysiajs/elysia/pull/1564, https://github.com/elysiajs/elysia/commit/26935bf76ebc43b4a43d48b173fc853de43bb51e, https://github.com/elysiajs/elysia/commit/3af978663e437dccc6c1a2a3aff4b74e1574849e, https://github.com/elysiajs/elysia, https://github.com/sportshead/elysia-poc

Severity

7.2

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
7.2
EPSS Probability
0.00066%
EPSS Percentile
0.20595%
Introduced Version
0,1.4.12-beta.1,1.3.0-exp.30,1.3.0-exp.24,1.2.0-exp.35,1.2.0-rc.1,1.2.0-exp.0,1.1.25,1.1.0-exp.18,1.1.0-exp.1,0.8.11,1.0.0-exp.0,0.7.0-beta.0
Fix Available
1.4.18

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading