Elysia vulnerable to prototype pollution with multiple standalone schema validation

Description

Prototype pollution vulnerability in mergeDeep after merging results of two standard schema validations with the same key. Due to the ordering of merging, there must be an any type that is set as a standalone guard, to allow for the __proto__ prop to be merged.

When combined with GHSA-8vch-m3f4-q8jf this allows for a full RCE by an attacker.

Impact

Routes with more than 2 standalone schema validation, eg. zod

Example vulnerable code:

import { Elysia } from "elysia"
import * as z from "zod"

const app = new Elysia()
    .guard({
        schema: "standalone",
        body: z.object({
            data: z.any()
        })
    })
    .post("/", ({ body }) => ({ body, win: {}.foo }), {
        body: z.object({
            data: z.object({
                messageId: z.string("pollute-me"),
            })
        })
    })

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

Remove __proto__ key from body

Example plugin for removing __proto__ from body

new Elysia()
    .onTransform(({ body, headers }) => {
        if (headers['content-type'] === 'application/json')
            return JSON.parse(JSON.stringify(body), (k, v) => {
                if (k === '__proto__') return

                return v
            })
    })

Basic information

Type
reviewed
Severity
critical
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2025-12-09 17:11:53 UTC
Updated
2025-12-09 21:37:10 UTC
GitHub reviewed
2025-12-09 17:11:53 UTC
NVD published
2025-12-09

EPSS Score

Score Percentile
0.20% 42.10%

CVSS Scores

Base score Version Severity Vector
9.1 4.0
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network.
Attack complexity (AC:L)
Exploitation conditions are straightforward and stable.
Attack requirements (AT:P)
Additional preconditions must be present for exploitation.
Privileges required (PR:N)
No privileges are required.
User interaction (UI:N)
No user interaction is required.
Vulnerable system confidentiality impact (VC:H)
High confidentiality impact on the vulnerable system.
Vulnerable system integrity impact (VI:H)
High integrity impact on the vulnerable system.
Vulnerable system availability impact (VA:N)
No availability impact on the vulnerable system.
Subsequent system confidentiality impact (SC:N)
No confidentiality impact on subsequent systems.
Subsequent system integrity impact (SI:N)
No integrity impact on subsequent systems.
Subsequent system availability impact (SA:N)
No availability impact on subsequent systems.

Identifiers

CWEs

CWE id Name
CWE-1321 Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

Credits

  • sportshead (finder)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
npm elysia >= 1.4.0, < 1.4.17 1.4.17

References

cvelogic Threat Intelligence