Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS03M3JnLWY5NGoteHZoeM4AA_tC
Plate allows arbitrary DOM attributes in element.attributes and leaf.attributes
Impact
One 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.
Note: The attributes
prop that is typically rendered alongside nodeProps
is unrelated.
[{
type: 'p',
attributes: { 'data-my-attribute': 'This will be rendered on the paragraph element' },
children: [{
bold: true,
attributes: { 'data-my-attribute': 'This will be rendered on the bold leaf element' },
text: 'Bold text',
}],
}]
const ParagraphElement = ({ attributes, nodeProps, children }) => (
<p
{...attributes}
{...nodeProps} // Arbitrary DOM attributes are injected here
>
{children}
</p>
);
const BoldLeaf = ({ attributes, nodeProps, children }) => (
<strong
{...attributes}
{...nodeProps} // Arbitrary DOM attributes are injected here
>
{children}
</strong>
);
It 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).
Note 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.
All 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.
In 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.
<a
href={sanitizedHref}
{...attributes}
{...nodeProps} // Definitely vulnerable to XSS since `href` can be overridden
>
<a
{...attributes}
{...nodeProps} // Probably not vulnerable to XSS via `href`
href={sanitizedHref}
>
<a
{...attributes}
{...nodeProps} // May be vulnerable to XSS via `href` if `href` is sometimes omitted from `sanitizedLinkProps`
{...sanitizedLinkProps}
>
React does not allow passing a string to event handler props like onClick
, so these are unlikely (but not impossible) to be vulnerable.
The 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
.
Potential attack vectors for delivering malicious Slate content to users include:
- Opening a malicious document stored on the server
- Pasting a malicious Slate fragment into a document
- Receiving malicious Slate operations on a collaborative document
Patches
In 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.
If 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.
Plate >= 37
For custom plugins, specify the list of allowed attribute names in the node.dangerouslyAllowAttributes
plugin configuration option.
const ImagePlugin = createPlatePlugin({
key: 'image',
node: {
isElement: true,
isVoid: true,
dangerouslyAllowAttributes: ['alt'],
},
});
To modify an existing plugin, use the extend
method.
const MyImagePlugin = ImagePlugin.extend({
node: {
dangerouslyAllowAttributes: ['alt'],
},
});
Plate < 37
Note that the patch has been backported to versions @udecode/[email protected]
and @udecode/[email protected]
only.
For custom plugins, specify the list of allowed attribute names in the dangerouslyAllowAttributes
plugin configuration option.
const createImagePlugin = createPluginFactory({
key: 'image',
isElement: true,
isVoid: true,
dangerouslyAllowAttributes: ['alt'],
});
To modify an existing plugin, pass dangerouslyAllowAttributes
to the plugin factory.
createImagePlugin({
dangerouslyAllowAttributes: ['alt'],
});
Workarounds
If you are unable to upgrade to any of the patched versions, you should use a tool like patch-package
or yarn patch
to remove the logic from @udecode/plate-core
that adds attributes
to nodeProps
.
This logic can be found in the getRenderNodeProps
function and looks something like this. The entire if
statment can safely be removed.
if (!newProps.nodeProps && attributes) {
newProps.nodeProps = attributes;
}
After applying the patch, be sure to test its effectiveness by rendering a Slate value containing an attributes
property on some element.
[{
type: 'p',
attributes: { 'data-vulnerable': true },
children: [{ text: 'My paragraph' }],
}]
If 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.
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS03M3JnLWY5NGoteHZoeM4AA_tC
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 23 days ago
Updated: 23 days ago
CVSS Score: 8.3
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L
Identifiers: GHSA-73rg-f94j-xvhx, CVE-2024-47061
References:
- https://github.com/udecode/plate/security/advisories/GHSA-73rg-f94j-xvhx
- https://github.com/udecode/plate/commit/16df6074edac22d56c60e0283eae0740230401c9
- https://nvd.nist.gov/vuln/detail/CVE-2024-47061
- https://www.npmjs.com/package/patch-package
- https://yarnpkg.com/cli/patch
- https://github.com/advisories/GHSA-73rg-f94j-xvhx
Blast Radius: 23.2
Affected Packages
npm:@udecode/plate-core
Dependent packages: 135Dependent repositories: 631
Downloads: 885,375 last month
Affected Version Ranges: < 21.5.1, >= 22.0.0, < 36.5.9, >= 37.0.0, < 38.0.6
Fixed in: 21.5.1, 36.5.9, 38.0.6
All affected versions: 1.0.0, 3.2.0, 3.4.0, 4.3.0, 4.3.7, 5.3.0, 5.3.1, 6.0.0, 6.2.0, 6.4.1, 7.0.0, 7.0.1, 7.0.2, 8.0.0, 8.1.0, 8.3.0, 9.0.0, 9.2.0, 9.2.1, 9.3.0, 9.3.1, 10.0.0, 10.1.0, 10.1.1, 10.1.2, 10.2.1, 10.2.2, 10.4.0, 10.4.1, 10.4.2, 10.5.0, 10.5.2, 10.5.3, 11.0.0, 11.0.1, 11.0.2, 11.0.3, 11.0.4, 11.0.5, 11.0.6, 11.1.0, 11.2.0, 11.2.1, 13.1.0, 13.5.0, 13.6.0, 13.7.0, 13.8.0, 14.0.0, 14.0.2, 14.4.2, 15.0.0, 15.0.3, 16.0.0, 16.0.2, 16.1.0, 16.2.0, 16.3.0, 16.5.0, 16.8.0, 17.0.0, 17.0.1, 17.0.2, 17.0.3, 18.1.1, 18.2.0, 18.6.0, 18.7.0, 18.9.0, 18.13.0, 18.15.0, 19.0.0, 19.0.1, 19.0.3, 19.1.0, 19.1.1, 19.2.0, 19.4.2, 19.4.4, 19.5.0, 19.7.0, 20.0.0, 20.4.0, 20.7.0, 20.7.2, 21.0.0, 21.1.5, 21.3.0, 21.3.2, 21.4.1, 21.4.2, 21.5.0, 22.0.0, 22.0.1, 22.0.2, 23.3.0, 23.3.1, 23.6.0, 23.7.4, 24.0.0, 24.0.1, 24.0.2, 24.3.0, 24.3.1, 24.3.2, 24.3.5, 24.3.6, 24.4.0, 25.0.0, 25.0.1, 27.0.0, 27.0.3, 28.0.0, 29.0.0, 29.0.1, 29.1.0, 30.0.0, 30.1.2, 30.4.5, 31.0.0, 31.3.2, 32.0.0, 32.0.1, 33.0.0, 33.0.3, 34.0.0, 34.0.1, 34.0.4, 36.0.3, 36.0.6, 36.2.1, 36.3.4, 36.3.7, 36.3.9, 37.0.0, 37.0.3, 37.0.4, 37.0.5, 37.0.7, 37.0.8, 38.0.0, 38.0.1, 38.0.2, 38.0.3, 38.0.4
All unaffected versions: 21.5.1, 36.5.9, 38.0.6, 39.0.0, 39.1.3, 39.1.4