Vulnerabilities in pkg:npm/@conform-to/zod

PACKAGE
Advisory Identifier: GHSA-624g-8qjg-8qxf
Advisory Summary

CVE-2024-32866 is a HIGH (CVSS 8.6) conform contains a prototype pollution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting @conform to/dom libraries in the npm ecosystem. The issue involves conform contains a prototype pollution vulnerability in `parsewith...` function. Remediation is available by upgrading affected packages to version 1.1.1, 0.9.2.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@conform-to/zod

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@conform-to/zod. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-624g-8qjg-8qxf CVE-2024-32866 HIGH Conform contains a Prototype Pollution Vulnerability in `parseWith...` function

CVE-2024-32866 at a Glance

CVE Identifier CVE-2024-32866
GHSA Identifier GHSA-624g-8qjg-8qxf
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product @conform to/dom
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability High (A:H)

How to Fix CVE-2024-32866

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

@conform-to/dom fixed: 1.1.1
npm install @conform-to/dom@1.1.1
@conform-to/zod fixed: 1.1.1
npm install @conform-to/zod@1.1.1
@conform-to/yup fixed: 1.1.1
npm install @conform-to/yup@1.1.1
@conform-to/zod fixed: 0.9.2
npm install @conform-to/zod@0.9.2
@conform-to/yup fixed: 0.9.2
npm install @conform-to/yup@0.9.2
@conform-to/dom fixed: 0.9.2
npm install @conform-to/dom@0.9.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 @conform-to/dom

How to Check if You Are Affected

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

npm ls @conform-to/dom

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

Note: The npm ls @conform-to/dom 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 @conform to/dom, 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 Conform allows the parsing of nested objects in the form of `object.property`. Due to an improper implementation of this feature, an attacker can exploit it to trigger prototype pollution by passing a crafted input to `parseWith...` functions. ### PoC ```javascript const { parseWithZod } = require('@conform-to/zod'); const { z } = require("zod"); const param = new URLSearchParams("__proto__.pollution=polluted"); const schema = z.object({ "a": z.string() }); parseWithZod(param, { schema }); console.log("pollution:", ({}).pollution); // should print "polluted" ``` ### Details The invocation of the `parseWithZod` function in the above PoC triggers the `setValue` function through `getSubmissionContext` and `parse`, executing the following process, resulting in prototype pollution: ```javascript let pointer = value; pointer.__proto__ = pointer.__proto__; pointer = pointer.__proto__; pointer.polluted = "polluted"; ``` This is caused by the lack of object existence checking on [line 117 in formdata.ts](https://github.com/edmundhung/conform/blob/59156d7115a7207fa3b6f8a70a4342a9b24c2501/packages/conform-dom/formdata.ts#L117), where the code only checks for the presence of `pointer[key]` without proper validation. ### Impact Applications that use conform for server-side validation of form data or URL parameters are affected by this vulnerability.

CVE-2024-32866 Affected @conform to/dom Versions

6 component(s)
Fixed Versions:
1.1.10.9.2
Product / Package Ecosystem Affected Versions Fixed Version
@conform-to/dom
npm
≥ 1.0.0
< 1.1.1
1.1.1
@conform-to/zod
npm
≥ 1.0.0
< 1.1.1
1.1.1
@conform-to/yup
npm
≥ 1.0.0
< 1.1.1
1.1.1
@conform-to/zod
npm
< 0.9.2
0.9.2
@conform-to/yup
npm
< 0.9.2
0.9.2
@conform-to/dom
npm
< 0.9.2
0.9.2

References

Frequently Asked Questions

What is CVE-2024-32866?
CVE-2024-32866 is a security vulnerability in @conform to/dom involving Conform contains a Prototype Pollution Vulnerability in `parseWith...` function under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which @conform to/dom versions are affected?
Affected versions include releases prior to 1.1.1, 0.9.2 across affected packages: @conform-to/dom, @conform-to/zod, @conform-to/yup.
What version fixes CVE-2024-32866?
Upgrading to 1.1.1, 0.9.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @conform-to/dom affected?
Yes, @conform-to/dom is affected in releases prior to 1.1.1, 0.9.2. Upgrade your dependency to 1.1.1, 0.9.2 or later.
Is @conform-to/zod affected?
Yes, @conform-to/zod is affected in releases prior to 1.1.1, 0.9.2. Upgrade your dependency to 1.1.1, 0.9.2 or later.
What is the CVSS score of CVE-2024-32866?
CVE-2024-32866 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H.
What CWE is associated with CVE-2024-32866?
CVE-2024-32866 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-2024-32866?
Run the dependency tree command: 'npm ls @conform-to/dom'. 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-624g-8qjg-8qxf",
  "modified" : "2024-06-10T20:12:58Z",
  "published" : "2024-04-23T21:15:55Z",
  "aliases" : [ "CVE-2024-32866" ],
  "summary" : "Conform contains a Prototype Pollution Vulnerability in `parseWith...` function",
  "details" : "### Summary\nConform allows the parsing of nested objects in the form of `object.property`. Due to an improper implementation of this feature, an attacker can exploit it to trigger prototype pollution by passing a crafted input to `parseWith...` functions.\n\n### PoC\n```javascript\nconst { parseWithZod } = require('@conform-to/zod');\nconst { z } = require(\"zod\"); \n\nconst param = new URLSearchParams(\"__proto__.pollution=polluted\");\nconst schema = z.object({ \"a\": z.string() });\n\nparseWithZod(param, { schema });\nconsole.log(\"pollution:\", ({}).pollution); // should print \"polluted\"\n```\n\n### Details\n\nThe invocation of the `parseWithZod` function in the above PoC triggers the `setValue` function through `getSubmissionContext` and `parse`, executing the following process, resulting in prototype pollution:\n\n```javascript\nlet pointer = value;\n\npointer.__proto__ = pointer.__proto__;\npointer = pointer.__proto__;\n\npointer.polluted = \"polluted\";\n```\n\nThis is caused by the lack of object existence checking on [line 117 in formdata.ts](https://github.com/edmundhung/conform/blob/59156d7115a7207fa3b6f8a70a4342a9b24c2501/packages/conform-dom/formdata.ts#L117), where the code only checks for the presence of `pointer[key]` without proper validation.\n\n### Impact\nApplications that use conform for server-side validation of form data or URL parameters are affected by this vulnerability.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/dom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.1.0"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/zod"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.1.0"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/yup"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.1.0"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/zod"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/yup"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@conform-to/dom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/edmundhung/conform/security/advisories/GHSA-624g-8qjg-8qxf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-32866"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/edmundhung/conform/commit/4819d51b5a53fd5486fc85c17cdc148eb160e3de"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/edmundhung/conform/commit/cb604dd58b99e2d12716d901a23bfca724e741ef"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/edmundhung/conform"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/edmundhung/conform/blob/59156d7115a7207fa3b6f8a70a4342a9b24c2501/packages/conform-dom/formdata.ts#L117"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-23T21:15:55Z",
    "nvd_published_at" : "2024-04-23T21:15:48Z"
  }
}