When generating an ESTree from a value with a property named __proto__, valueToEstree would generate an object that specifies a prototype instead.
Example:
import { generate } from 'astring'
import { valueToEstree } from 'estree-util-value-to-estree'
const estree = valueToEstree({
['__proto__']: {}
})
const code = generate(estree)
console.log(code)
Output:
{
"__proto__": {}
}
This was fixed in version 3.3.3.
If you control the input, don’t specify a property named __proto__. If you don’t control the output, strip any properties named __proto__ before passing it to valueToEstree.
{
"cwe_ids": [
"CWE-1321"
],
"github_reviewed": true,
"github_reviewed_at": "2025-04-07T19:09:48Z",
"nvd_published_at": "2025-04-07T15:15:44Z",
"severity": "MODERATE"
}