8.3high
Arbitrary DOM attributes in element.attributes and leaf.attributes in Platejs
- Severity
- 8.3high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.52% (higher than 45% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-73rg-f94j-xvhx
Description
Plate is a javascript toolkit that makes it easier for you to develop with Slate, a popular framework for building text editors. 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. 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. 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. 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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| udecode plate | >= 37.0.0, < 38.0.6, >= 22.0.0, < 36.5.9, < 21.5.1 | CVE List |
| @udecode/plate-core (npm) | from 37.0.0 before 38.0.6, from 22.0.0 before 36.5.9, before 21.5.1 | GitHub Advisory Database |
All scores
| GitHub_M | 8.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L |
| GitHub | 8.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L |
| GitHub | high CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
Plate is a javascript toolkit that makes it easier for you to develop with Slate, a popular framework for building text editors. 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. 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. 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. 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.
GitHub Advisory Database
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/plate-core@21.5.1 and @udecode/plate-core@36.5.9 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.
NVD (es)
Plate es un conjunto de herramientas de JavaScript que facilita el desarrollo con Slate, un popular framework de trabajo para crear editores de texto. Una característica de larga data de Plate es la capacidad de agregar atributos DOM personalizados a cualquier elemento u hoja utilizando la propiedad `attributes`. Estos atributos se pasan al componente de nodo utilizando la propiedad `nodeProps`. Nos hemos dado cuenta de que esta característica se puede utilizar con fines maliciosos, incluido cross-site scripting (XSS) y la exposición de información (específicamente, las direcciones IP de los usuarios y si han abierto o no un documento malicioso). Tenga en cuenta que el riesgo de exposición de información a través de atributos solo es relevante para aplicaciones en las que las solicitudes web a URL arbitrarias no están permitidas normalmente. Los editores de Plate que permiten a los usuarios incrustar imágenes desde URL arbitrarias, por ejemplo, ya conllevan el riesgo de filtrar las direcciones IP de los usuarios a terceros. Todos los editores de Plate que utilizan una versión afectada de @udecode/plate-core son vulnerables a estos ataques de exposición de información a través del atributo style y otros atributos que pueden hacer que se envíen solicitudes web. Además, la vulnerabilidad de un editor de Plate a ataques de cross site scripting mediante atributos depende de varios factores. Los atributos DOM que tienen más probabilidades de ser vulnerables son href y src en enlaces e iframes respectivamente. Cualquier componente que extienda {...nodeProps} en un elemento <a rel="nofollow"> o y no anule posteriormente href o src será vulnerable a XSS. En las versiones parcheadas de Plate, hemos deshabilitado element.attributes y leaf.attributes para la mayoría de los nombres de atributos de forma predeterminada, con algunas excepciones que incluyen target, alt, width, height, colspan y rowspan en los complementos de enlaces, imágenes, videos, celdas de tablas y celdas de encabezado de tablas. Si este es un cambio importante para usted, puede volver a habilitar de forma selectiva los atributos para ciertos complementos de la siguiente manera. Investigue y evalúe cuidadosamente las implicaciones de seguridad de cualquier atributo que permita, ya que incluso los atributos aparentemente inocuos, como style, pueden usarse de forma maliciosa. Si no puede actualizar a ninguna de las versiones parcheadas, debe usar una herramienta como patch-package o yarn patch para eliminar la lógica de @udecode/plate-core que agrega atributos a nodeProps.</a>
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-47061 changed 2024-09-20 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-73rg-f94j-xvhx changed 2024-09-20 | CC-BY-4.0 |
| NVD | CVE-2024-47061 changed 2026-06-17 | Public domain |