CVE-2024-47061: @udecode/plate core Plate Allows Arbitrary DOM Attributes Vulnerability
HIGHCVE-2024-47061 is a HIGH (CVSS 8.3) plate allows arbitrary dom attributes vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @udecode/plate core libraries in the npm ecosystem. The issue involves plate allows arbitrary dom attributes in element.attributes and leaf.attributes. Remediation is available by upgrading affected packages to version 38.0.6, 36.5.9, 21.5.1.
CVE-2024-47061 at a Glance
Security Impact
CVSS: 8.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L).
How to Fix CVE-2024-47061
To remediate this vulnerability, upgrade all affected @udecode/plate core dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @udecode/plate-core@38.0.6
npm install @udecode/plate-core@36.5.9
npm install @udecode/plate-core@21.5.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @udecode/plate-core
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-47061, inspect your project dependencies using npm:
npm ls @udecode/plate-core
Analyze the terminal output to locate any version of @udecode/plate core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 38.0.6), your application is affected.
Note: The npm ls @udecode/plate-core 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In @udecode/plate core, 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
CVE-2024-47061 Affected @udecode/plate core Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@udecode/plate-core
|
npm |
≥ 37.0.0
< 38.0.6
|
38.0.6
|
|
@udecode/plate-core
|
npm |
≥ 22.0.0
< 36.5.9
|
36.5.9
|
|
@udecode/plate-core
|
npm |
< 21.5.1
|
21.5.1
|
References
Frequently Asked Questions
What is CVE-2024-47061?
Which @udecode/plate core versions are affected?
What version fixes CVE-2024-47061?
Is @udecode/plate-core affected?
What is the CVSS score of CVE-2024-47061?
What CWE is associated with CVE-2024-47061?
How can I check npm dependencies for CVE-2024-47061?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-73rg-f94j-xvhx",
"modified" : "2024-09-20T22:07:36Z",
"published" : "2024-09-20T14:41:02Z",
"aliases" : [ "CVE-2024-47061" ],
"summary" : "Plate allows arbitrary DOM attributes in element.attributes and leaf.attributes",
"details" : "### Impact\nOne longstanding feature of Plate is the ability to add custom DOM attributes to any element or leaf using the `attributes` property. These attributes are passed to the node component using the `nodeProps` prop.\n\nNote: The `attributes` prop that is typically rendered alongside `nodeProps` is unrelated.\n\n```ts\n[{\n type: 'p',\n attributes: { 'data-my-attribute': 'This will be rendered on the paragraph element' },\n children: [{\n bold: true,\n attributes: { 'data-my-attribute': 'This will be rendered on the bold leaf element' },\n text: 'Bold text',\n }],\n}]\n```\n\n```tsx\nconst ParagraphElement = ({ attributes, nodeProps, children }) => (\n <p\n {...attributes}\n {...nodeProps} // Arbitrary DOM attributes are injected here\n >\n {children}\n </p>\n);\n\nconst BoldLeaf = ({ attributes, nodeProps, children }) => (\n <strong\n {...attributes}\n {...nodeProps} // Arbitrary DOM attributes are injected here\n >\n {children}\n </strong>\n);\n```\n\nIt has come to our attention that this feature can be used for malicious purposes, including cross-site scripting (XSS) and information exposure (specifically, users' IP addresses and whether or not they have opened a malicious document).\n\nNote that the risk of information exposure via `attributes` is only relevant to applications in which web requests to arbitrary URLs are not ordinarily allowed. Plate editors that allow users to embed images from arbitrary URLs, for example, already carry the risk of leaking users' IP addresses to third parties.\n\nAll Plate editors using an affected version of `@udecode/plate-core` are vulnerable to these information exposure attacks via the `style` attribute and other attributes that can cause web requests to be sent. \n\nIn addition, whether or not a Plate editor is vulnerable to cross-site scripting attacks using `attributes` depends on a number of factors. The most likely DOM attributes to be vulnerable are `href` and `src` on links and iframes respectively. Any component that spreads `{...nodeProps}` onto an `<a>` or `<iframe>` element and does not later override `href` or `src` will be vulnerable to XSS.\n\n```tsx\n<a\n href={sanitizedHref}\n {...attributes}\n {...nodeProps} // Definitely vulnerable to XSS since `href` can be overridden\n>\n```\n\n```tsx\n<a\n {...attributes}\n {...nodeProps} // Probably not vulnerable to XSS via `href`\n href={sanitizedHref}\n>\n```\n\n```tsx\n<a\n {...attributes}\n {...nodeProps} // May be vulnerable to XSS via `href` if `href` is sometimes omitted from `sanitizedLinkProps`\n {...sanitizedLinkProps}\n>\n```\n\nReact does not allow passing a string to event handler props like `onClick`, so these are unlikely (but not impossible) to be vulnerable.\n\nThe attack surface is larger for users running older browsers, which may be vulnerable to XSS in DOM attributes that are less dangerous (although still vulnerable to information exposure) in modern browsers such as `style` or `background`.\n\nPotential attack vectors for delivering malicious Slate content to users include:\n\n- Opening a malicious document stored on the server\n- Pasting a malicious Slate fragment into a document\n- Receiving malicious Slate operations on a collaborative document\n\n### Patches\nIn patched versions of Plate, we have disabled `element.attributes` and `leaf.attributes` for most attribute names by default, with some exceptions including `target`, `alt`, `width`, `height`, `colspan` and `rowspan` on the link, image, video, table cell and table header cell plugins.\n\nIf this is a breaking change for you, you can selectively re-enable `attributes` for certain plugins as follows. Please carefully research and assess the security implications of any attribute you allow, as even seemingly innocuous attributes such as `style` can be used maliciously.\n\n#### Plate >= 37\n\nFor custom plugins, specify the list of allowed attribute names in the `node.dangerouslyAllowAttributes` plugin configuration option.\n\n```ts\nconst ImagePlugin = createPlatePlugin({\n key: 'image',\n node: {\n isElement: true,\n isVoid: true,\n dangerouslyAllowAttributes: ['alt'],\n },\n});\n```\n\nTo modify an existing plugin, use the `extend` method.\n\n```ts\nconst MyImagePlugin = ImagePlugin.extend({\n node: {\n dangerouslyAllowAttributes: ['alt'],\n },\n});\n```\n\n#### Plate < 37\n\nNote that the patch has been backported to versions `@udecode/plate-core@21.5.1` and `@udecode/plate-core@36.5.9` only.\n\nFor custom plugins, specify the list of allowed attribute names in the `dangerouslyAllowAttributes` plugin configuration option.\n\n```ts\nconst createImagePlugin = createPluginFactory({\n key: 'image',\n isElement: true,\n isVoid: true,\n dangerouslyAllowAttributes: ['alt'],\n});\n```\n\nTo modify an existing plugin, pass `dangerouslyAllowAttributes` to the plugin factory.\n\n```ts\ncreateImagePlugin({\n dangerouslyAllowAttributes: ['alt'],\n});\n```\n\n### Workarounds\n\nIf you are unable to upgrade to any of the patched versions, you should use a tool like [`patch-package`](https://www.npmjs.com/package/patch-package) or [`yarn patch`](https://yarnpkg.com/cli/patch) to remove the logic from `@udecode/plate-core` that adds `attributes` to `nodeProps`.\n\nThis logic can be found in the `getRenderNodeProps` function and looks something like this. The entire `if` statment can safely be removed.\n\n```ts\n if (!newProps.nodeProps && attributes) {\n newProps.nodeProps = attributes;\n }\n```\n\nAfter applying the patch, be sure to test its effectiveness by rendering a Slate value containing an `attributes` property on some element.\n\n```ts\n[{\n type: 'p',\n attributes: { 'data-vulnerable': true },\n children: [{ text: 'My paragraph' }],\n}]\n```\n\nIf the patch was successful, the `data-vulnerable=\"true\"` attribute should not be present on any DOM element when the Plate editor is rendered in the browser.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@udecode/plate-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "37.0.0"
}, {
"fixed" : "38.0.6"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@udecode/plate-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "22.0.0"
}, {
"fixed" : "36.5.9"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@udecode/plate-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "21.5.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/udecode/plate/security/advisories/GHSA-73rg-f94j-xvhx"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47061"
}, {
"type" : "WEB",
"url" : "https://github.com/udecode/plate/commit/16df6074edac22d56c60e0283eae0740230401c9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/udecode/plate"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/patch-package"
}, {
"type" : "WEB",
"url" : "https://yarnpkg.com/cli/patch"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-09-20T14:41:02Z",
"nvd_published_at" : "2024-09-20T19:15:16Z"
}
}