Vulnerabilities in pkg:npm/flatted

PACKAGE
Advisory Identifier: GHSA-rf6f-7fwh-wjgh
Advisory Summary

CVE-2026-33228 is a HIGH prototype pollution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Flatted libraries in the npm ecosystem. The issue involves prototype pollution via parse() in nodejs flatted. Remediation is available by upgrading affected packages to version 3.4.2.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/flatted

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/flatted. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-rf6f-7fwh-wjgh CVE-2026-33228 HIGH Prototype Pollution via parse() in NodeJS flatted
GHSA-25h7-pfq9-p65f CVE-2026-32141 HIGH flatted vulnerable to unbounded recursion DoS in parse() revive phase

CVE-2026-33228 at a Glance

CVE Identifier CVE-2026-33228
GHSA Identifier GHSA-rf6f-7fwh-wjgh
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product Flatted
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-33228

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

flatted fixed: 3.4.2
npm install flatted@3.4.2
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 flatted

How to Check if You Are Affected

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

npm ls flatted

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

Note: The npm ls flatted 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-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In Flatted, 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

--- **Summary** The parse() function in flatted can use attacker-controlled string values from the parsed JSON as direct array index keys, without validating that they are numeric. Since the internal input buffer is a JavaScript Array, accessing it with the key "\_\_proto\_\_" returns Array.prototype via the inherited getter. This object is then treated as a legitimate parsed value and assigned as a property of the output object, effectively leaking a live reference to Array.prototype to the consumer. Any code that subsequently writes to that property will pollute the global prototype. --- **Root Cause** File: esm/index.js:29 (identical in cjs/index.js) ``` const resolver = (input, lazy, parsed, $) => output => { for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) { const k = ke[y]; const value = output[k]; if (value instanceof Primitive) { const tmp = input[value]; // Bug is here ``` No validation that value is a safe numeric index input is built as a plain Array. JavaScript's property lookup on arrays traverses the prototype chain for non-numeric keys. The key "\_\_proto\_\_" resolves to Array.prototype, which: - has type "object" → passes the typeof tmp === object guard at line 30 - is not in the parsed Set yet → passes the !parsed.has(tmp) guard. - The reference to Array.prototype is then enqueued in lazy and later unconditionally assigned to the output object. --- **Replication Steps** ``` const Flatted = require('flatted'); const parsed = Flatted.parse('[{"x":"__proto__"}]'); parsed.x.polluted = 'pwned'; console.log([].polluted); // Returns true ``` --- **Impact** An attacker can supply a crafted flatted string to parse() that causes the returned object to hold a live reference to Array.prototype, enabling any downstream code that writes to that property to pollute the global prototype chain, potentially causing denial of service or code execution. **Recommended solution** Validate that the index string represents an integer within the bounds of input before accessing it: // Before (vulnerable) const tmp = input[value]; // After (safe) const idx = +value; // coerce boxed String → number const tmp = (Number.isInteger(idx) && idx >= 0 && idx < input.length) ? input[idx] : undefined;

CVE-2026-33228 Affected Flatted Versions

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

References

Frequently Asked Questions

What is CVE-2026-33228?
CVE-2026-33228 is a security vulnerability in Flatted involving Prototype Pollution via parse() in NodeJS flatted under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which Flatted versions are affected?
Affected versions include releases prior to 3.4.2 across affected packages: flatted.
What version fixes CVE-2026-33228?
Upgrading to 3.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is flatted affected?
Yes, flatted is affected in releases prior to 3.4.2. Upgrade your dependency to 3.4.2 or later.
What CWE is associated with CVE-2026-33228?
CVE-2026-33228 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check npm dependencies for CVE-2026-33228?
Run the dependency tree command: 'npm ls flatted'. 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-rf6f-7fwh-wjgh",
  "modified" : "2026-10-05T15:48:46Z",
  "published" : "2026-03-19T17:43:54Z",
  "aliases" : [ "CVE-2026-33228" ],
  "summary" : "Prototype Pollution via parse() in NodeJS flatted",
  "details" : "---\n  **Summary**\n\n  The parse() function in flatted can use attacker-controlled string values from the parsed JSON as direct array index\n  keys, without validating that they are numeric. Since the internal input buffer is a JavaScript Array, accessing it\n  with the key \"\\_\\_proto\\_\\_\" returns Array.prototype via the inherited getter. This object is then treated as a legitimate\n   parsed value and assigned as a property of the output object, effectively leaking a live reference to Array.prototype\n   to the consumer. Any code that subsequently writes to that property will pollute the global prototype.\n\n  ---\n  **Root Cause**\n\n  File: esm/index.js:29 (identical in cjs/index.js)\n```\n  const resolver = (input, lazy, parsed, $) => output => {\n    for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {\n      const k = ke[y];\n      const value = output[k];    \n      if (value instanceof Primitive) {\n        const tmp = input[value];      // Bug is here\n```\n\nNo validation that value is a safe numeric index input is built as a plain Array. JavaScript's property lookup on arrays traverses the prototype chain for non-numeric  keys. The key \"\\_\\_proto\\_\\_\" resolves to Array.prototype, which:\n\n  - has type \"object\" → passes the typeof tmp === object guard at line 30\n  - is not in the parsed Set yet → passes the !parsed.has(tmp) guard.\n  - The reference to Array.prototype is then enqueued in lazy and later unconditionally assigned to the output object.\n  ---\n  **Replication Steps**\n```\n  const Flatted = require('flatted'); \n  const parsed = Flatted.parse('[{\"x\":\"__proto__\"}]');\n  parsed.x.polluted = 'pwned';\n  console.log([].polluted);  // Returns true\n``` \n ---\n  **Impact**\n An attacker can supply a crafted flatted string to parse() that causes the returned object to hold a live reference to Array.prototype, enabling any downstream code that writes to that property to pollute the global prototype chain, potentially causing denial of service or code execution.\n\n  **Recommended solution**\n Validate that the index string represents an integer within the bounds of input before accessing it:\n\n  // Before (vulnerable)\n  const tmp = input[value];\n\n  // After (safe)\n  const idx = +value;  // coerce boxed String → number\n  const tmp = (Number.isInteger(idx) && idx >= 0 && idx < input.length)\n    ? input[idx]\n    : undefined;",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "flatted"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.4.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.4.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/WebReflection/flatted/security/advisories/GHSA-rf6f-7fwh-wjgh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33228"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/WebReflection/flatted/commit/885ddcc33cf9657caf38c57c7be45ae1c5272802"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:13826"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:34342"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:9742"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/security/cve/CVE-2026-33228"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2449872"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/WebReflection/flatted"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/WebReflection/flatted/releases/tag/v3.4.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321", "CWE-915" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-19T17:43:54Z",
    "nvd_published_at" : "2026-03-20T23:16:46Z"
  }
}