CVE-2025-66457: Elysia Elysia Affected By Arbitrary Code Vulnerability

HIGH
Advisory Identifier: GHSA-8vch-m3f4-q8jf
CWE-94
Published
Advisory Summary

CVE-2025-66457 is a HIGH elysia affected by arbitrary code vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Elysia libraries in the npm ecosystem. The issue involves elysia affected by arbitrary code injection through cookie config. Remediation is available by upgrading affected packages to version 1.4.18.

CVE-2025-66457 at a Glance

CVE Identifier CVE-2025-66457
GHSA Identifier GHSA-8vch-m3f4-q8jf
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Elysia
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2025-66457

To remediate this vulnerability, upgrade all affected Elysia dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

elysia fixed: 1.4.18
npm install elysia@1.4.18
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls elysia

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2025-66457, inspect your project dependencies using npm:

npm ls elysia

Analyze the terminal output to locate any version of Elysia in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.18), your application is affected.

Note: The npm ls elysia command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Elysia, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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 ```js 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 ```typescript const overrideUnsafeQuote = (value: string) => // '`' + value + '`' '`' + value.replace(/'/g, '\\`').replace(/\${/g, '$\\{') + '`' ```

CVE-2025-66457 Affected Elysia Versions

1 component(s)
Fixed Versions:
1.4.18
Product / Package Ecosystem Affected Versions Fixed Version
elysia
npm
< 1.4.18
1.4.18

References

Frequently Asked Questions

What is CVE-2025-66457?
CVE-2025-66457 is a security vulnerability in Elysia involving Elysia affected by arbitrary code injection through cookie config under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Elysia versions are affected?
Affected versions include releases prior to 1.4.18 across affected packages: elysia.
What version fixes CVE-2025-66457?
Upgrading to 1.4.18 (or the latest patched release for your respective branch) resolves the vulnerability.
Is elysia affected?
Yes, elysia is affected in releases prior to 1.4.18. Upgrade your dependency to 1.4.18 or later.
What CWE is associated with CVE-2025-66457?
CVE-2025-66457 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2025-66457?
Run the dependency tree command: 'npm ls elysia'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8vch-m3f4-q8jf",
  "modified" : "2025-12-09T21:37:17Z",
  "published" : "2025-12-09T17:12:05Z",
  "aliases" : [ "CVE-2025-66457" ],
  "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(\"/\", () => \"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) =>\n\t// '`' + value + '`'\n\t'`' + value.replace(/'/g, '\\\\`').replace(/\\${/g, '$\\\\{') + '`'\n```",
  "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "elysia"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.18"
      } ]
    } ]
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-12-09T17:12:05Z",
    "nvd_published_at" : "2025-12-09T20:15:54Z"
  }
}