CVE-2026-31865 Overview
CVE-2026-31865 is a prototype pollution vulnerability affecting Elysia, a popular TypeScript framework used for request validation, type inference, OpenAPI documentation, and client-server communication. Prior to version 1.4.27, Elysia cookies can be overridden through prototype pollution using properties like __proto__. This vulnerability allows attackers to manipulate cookie values and potentially bypass security controls implemented through cookie-based authentication or session management.
Critical Impact
Attackers can exploit prototype pollution to override cookie values, potentially leading to authentication bypass, session hijacking, or unauthorized access to user data through manipulated cookie properties.
Affected Products
- Elysia versions prior to 1.4.27
- Applications using Elysia's cookie handling functionality without explicit t.Cookie validation
- Web services relying on Elysia's default cookie iteration behavior
Discovery Timeline
- 2026-03-18 - CVE CVE-2026-31865 published to NVD
- 2026-03-18 - Last updated in NVD database
Technical Details for CVE-2026-31865
Vulnerability Analysis
This vulnerability stems from improper handling of object initialization in Elysia's cookie management system. The framework's cookie constructor used a default empty object {} for initialization, which inherits from Object.prototype. This design flaw allows attackers to inject malicious properties through prototype pollution vectors such as __proto__, effectively overriding legitimate cookie values.
When an application iterates over cookies or accesses cookie properties, the polluted prototype chain can inject unexpected values, allowing attackers to manipulate authentication states, session identifiers, or other security-sensitive cookie data.
Root Cause
The root cause lies in the ElysiaCookie constructor within src/cookies.ts. The initial parameter was defined as private initial: Partial<ElysiaCookie> = {}, which creates an object that inherits from Object.prototype. This inheritance chain allows prototype pollution attacks where malicious __proto__ properties can cascade into cookie operations.
Attack Vector
The attack vector is network-based and requires no authentication or user interaction. An attacker can craft malicious HTTP requests containing prototype pollution payloads in cookie-related parameters. When Elysia processes these requests, the polluted prototype properties are inherited by the cookie object, allowing the attacker to:
- Override existing cookie values
- Inject arbitrary properties into the cookie object
- Bypass cookie-based validation or authentication checks
- Potentially access other users' session data through cookie manipulation
// Security patch in src/cookies.ts
constructor(
private name: string,
private jar: Record<string, ElysiaCookie>,
- private initial: Partial<ElysiaCookie> = {}
+ private initial: Partial<ElysiaCookie> = Object.create(null)
) {}
get cookie() {
Source: GitHub Commit Report
The fix replaces {} with Object.create(null), which creates an object with no prototype chain, effectively preventing prototype pollution attacks.
Detection Methods for CVE-2026-31865
Indicators of Compromise
- Unusual HTTP requests containing __proto__, constructor, or prototype strings in cookie headers or request bodies
- Unexpected cookie values appearing in application logs that don't match user input
- Authentication anomalies where users gain access to unauthorized resources
- Session inconsistencies where cookie-based state appears corrupted or manipulated
Detection Strategies
- Implement Web Application Firewall (WAF) rules to detect and block requests containing prototype pollution patterns (__proto__, constructor.prototype)
- Monitor application logs for cookie-related errors or unexpected property access
- Deploy runtime application self-protection (RASP) to detect prototype pollution attempts
- Use static analysis tools to identify vulnerable Elysia versions in your dependency tree
Monitoring Recommendations
- Enable detailed logging for cookie handling operations in Elysia applications
- Set up alerts for suspicious patterns in HTTP headers containing prototype pollution keywords
- Monitor for unusual authentication events or session anomalies that could indicate cookie manipulation
- Implement dependency scanning in CI/CD pipelines to detect vulnerable Elysia versions
How to Mitigate CVE-2026-31865
Immediate Actions Required
- Upgrade Elysia to version 1.4.27 or later immediately
- Audit applications for any custom cookie handling that may be similarly vulnerable
- Implement t.Cookie validation to enforce strict cookie value validation
- Review authentication and session management code for prototype pollution susceptibility
Patch Information
The vulnerability is patched in Elysia version 1.4.27. The fix modifies the cookie constructor to use Object.create(null) instead of an empty object literal, eliminating the prototype chain that enables this attack. The patch can be reviewed in the GitHub commit and the GitHub Security Advisory provides additional details.
Workarounds
- Use t.Cookie validation to enforce strict validation of cookie values and prevent prototype pollution
- Implement input sanitization to filter out prototype pollution vectors (__proto__, constructor, prototype) from user input
- Avoid iterating over cookies directly; use explicit property access with validated keys
- Consider implementing a custom cookie parser that uses Object.create(null) for cookie storage
# Update Elysia to patched version
npm update elysia@1.4.27
# Or install specific version
npm install elysia@^1.4.27
# Verify installed version
npm list elysia
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

