CVE-2026-59952
ADVISORY - githubSummary
Summary
valibot 1.4.1 can throw a TypeError inside its flatten() helper when validation issues contain attacker-controlled object keys such as toString, valueOf, or hasOwnProperty.
The issue is reachable through normal record() validation. record() intentionally filters __proto__, prototype, and constructor, but it still accepts other own keys that collide with inherited Object.prototype properties. If the record key schema or value schema rejects such an entry, Valibot creates an issue path containing that key. Passing the resulting issues to Valibot's documented flatten() helper causes flatErrors.nested[dotPath] to resolve to the inherited method instead of an own error array, and the helper calls .push(...) on that function.
This is not a global prototype pollution issue. The impact is availability/error handling: applications that validate user-controlled objects with record() and flatten validation errors for API responses can crash the request path with a TypeError instead of returning structured validation errors.
Affected package
- Ecosystem: npm
- Package:
valibot - Affected version verified:
1.4.1 - Fixed version: none known
- Repository:
open-circle/valibot - Current main ref tested by source review:
9bb6617
Root cause
record() uses _isValidObjectKey() before validating record entries. The helper blocks the three classic prototype pollution keys:
key !== '__proto__' &&
key !== 'prototype' &&
key !== 'constructor'
It does not block other inherited Object.prototype names such as toString, valueOf, and hasOwnProperty. These remain valid own JSON object keys and can appear in issue paths when either the record key schema or value schema rejects the entry.
flatten() then creates nested error storage with an ordinary object:
flatErrors.nested = {};
For a dot path such as toString, this check reads the inherited Object.prototype.toString function:
if (flatErrors.nested![dotPath]) {
flatErrors.nested![dotPath]!.push(issue.message);
}
Because the inherited function is truthy, flatten() calls .push(...) on a function and throws TypeError: flatErrors.nested[dotPath].push is not a function.
Impact
A remote attacker can trigger this if an application:
- validates attacker-controlled JSON objects with
v.record(...); - receives an invalid key or invalid value under a key such as
toString; - uses Valibot's
flatten(result.issues)helper to prepare validation errors.
This is a common pattern in API/form validation: safeParse() collects issues and flatten() converts them into response-friendly error objects. Instead of a validation response, the request can hit an unexpected exception path.
The same root cause can also affect manually constructed issues or other schemas that place inherited Object property names into dot paths. I am reporting the record() path because it uses only public Valibot APIs and attacker-controlled JSON keys.
Local reproduction
Run in a disposable directory:
npm install valibot@1.4.1
node poc_record_flatten_inherited_key_dos.mjs
Minimal example:
import * as v from 'valibot';
const schema = v.record(v.string(), v.number());
const input = JSON.parse('{"toString":"not-a-number"}');
const result = v.safeParse(schema, input);
console.log(result.success); // false
console.log(result.issues[0].path.map((item) => item.key)); // ["toString"]
v.flatten(result.issues); // TypeError
Observed output from valibot@1.4.1:
{
"name": "record value schema rejects attacker-controlled value",
"key": "toString",
"success": false,
"issueCount": 1,
"firstPath": ["toString"],
"firstMessage": "Invalid type: Expected number but received \"not-a-number\"",
"flattened": {
"ok": false,
"exception": "TypeError",
"message": "flatErrors.nested[dotPath].push is not a function"
}
}
The local PoC also reproduces the same exception for valueOf, hasOwnProperty, isPrototypeOf, propertyIsEnumerable, and toLocaleString. A control case with an ordinary key produces normal flattened errors.
Duplicate checks performed before submission
- npm metadata confirmed current
valibotrelease is1.4.1and maps toopen-circle/valibot. gh api repos/open-circle/valibot/private-vulnerability-reportingreturned{"enabled":true}.npm auditfor a clean project containing onlyvalibot@1.4.1returned no vulnerabilities.- Repository advisories and the GitHub Advisory Database only returned the historical emoji ReDoS advisory fixed in
1.2.0. - OSV exact-version query for npm
valibot1.4.1returned no vulnerabilities. - Public issue/PR searches for
flatten toString,flatten hasOwnProperty,record toString,__proto__,constructor, andprototype pollutiondid not find a matching disclosure of thisrecord()issue-path /flatten()exception. - Reviewed related public PRs:
open-circle/valibot#67added prototype pollution mitigation forrecord()by blacklisting__proto__,prototype, andconstructor; it does not coverflatten()collisions with other inherited property names.open-circle/valibot#1429is an open plain-object /record()type semantics PR and does not disclose thisflatten()exception behavior.
Suggested remediation
Use null-prototype containers for flat error maps and/or perform own-property checks before appending:
- Initialize
flatErrors.nestedasObject.create(null). - Check nested entries with
Object.prototype.hasOwnProperty.call(flatErrors.nested, dotPath)rather than truthiness. - Consider filtering or escaping unsafe dot path segments in
getDotPath()/flatten(), including inherited Object property names. - Add regression tests for
flatten()with pathstoString,valueOf,hasOwnProperty,__proto__,prototype, andconstructor. - Consider using the same hardening for other accumulator objects that store attacker-controlled keys.
Common Weakness Enumeration (CWE)
Improper Handling of Exceptional Conditions
GitHub
-
CVSS SCORE
6.9medium| Package | Type | OS Name | OS Version | Affected Ranges | Fix Versions |
|---|---|---|---|---|---|
| valibot | npm | - | - | <=1.4.1 | 1.4.2 |
CVSS:4 Severity and metrics
The CVSS metrics represent different qualitative aspects of a vulnerability that impact the overall score, as defined by the CVSS Specification.
The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN to an administrative network zone). One example of an Adjacent attack would be an ARP (IPv4) or neighbor discovery (IPv6) flood leading to a denial of service on the local LAN segment (e.g., CVE-2013-6014).
Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.
The successful attack does not depend on the deployment and execution conditions of the vulnerable system. The attacker can expect to be able to reach the vulnerability and execute the exploit under all or most instances of the vulnerability.
The attacker is unauthenticated prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.
The vulnerable system can be exploited without interaction from any human user, other than the attacker. Examples include: a remote attacker is able to send packets to a target system a locally authenticated attacker executes code to elevate privileges.
There is no loss of confidentiality within the Vulnerable System.
There is no loss of confidentiality within the Subsequent System or all confidentiality impact is constrained to the Vulnerable System.
There is no loss of integrity within the Vulnerable System.
There is no loss of integrity within the Subsequent System or all integrity impact is constrained to the Vulnerable System.
Performance is reduced or there are interruptions in resource availability. Even if repeated exploitation of the vulnerability is possible, the attacker does not have the ability to completely deny service to legitimate users. The resources in the Vulnerable System are either partially available all of the time, or fully available only some of the time, but overall there is no direct, serious consequence to the Vulnerable System.
There is no impact to availability within the Subsequent System or all availability impact is constrained to the Vulnerable System.