Summary
Plate media plugins has a XSS in media embed element when using custom URL parsers
Workarounds
Ensure that any custom urlParsers do not allow javascript:, data: or vbscript: URLs to be returned in the url property of their return values.
If url is consumed directly, validate the URL protocol before passing it to the iframe element.
References
How to verify the protocol of a URL: https://stackoverflow.com/a/43467144
Impact
Editors that use MediaEmbedElement and pass custom urlParsers to the useMediaState hook may be vulnerable to XSS if a custom parser allows javascript:, data: or vbscript: URLs to be embedded. Editors that do not use urlParsers and instead consume the url property directly may also be vulnerable if the URL is not sanitised.
The default parsers parseTwitterUrl and parseVideoUrl are not affected.
Examples of vulnerable code:
const { embed } = useMediaState({
urlParsers: [
// Custom parser that does not use an allowlist or validate the URL protocol
(url) => ({ url }),
],
});
return (
<iframe
src={embed!.url}
// ...
/>
);
const { url } = useMediaState();
return (
<iframe
// url property used directly from useMediaState() with no sanitisation
src={url}
// ...
/>
);
const { url } = element;
return (
<iframe
// url property used directly from element with no sanitisation
src={url}
// ...
/>
);
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
CVE-2024-40631 has a CVSS score of 8.1 (High). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (36.0.10); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
@udecode/plate-media 36.0.10 resolves this issue by only allowing HTTP and HTTPS URLs during parsing. This affects only the embed property returned from useMediaState.
In addition, the url property returned from useMediaState has been renamed to unsafeUrl to indicate that it has not been sanitised. The url property on element is also unsafe, but has not been renamed. If you're using either of these properties directly, you will still need to validate the URL yourself.
Frequently Asked Questions
- What is CVE-2024-40631? CVE-2024-40631 is a high-severity cross-site scripting (XSS) vulnerability in @udecode/plate-media (npm), affecting versions < 36.0.10. It is fixed in 36.0.10. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- How severe is CVE-2024-40631? CVE-2024-40631 has a CVSS score of 8.1 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of @udecode/plate-media are affected by CVE-2024-40631? @udecode/plate-media (npm) versions < 36.0.10 is affected.
- Is there a fix for CVE-2024-40631? Yes. CVE-2024-40631 is fixed in 36.0.10. Upgrade to this version or later.
- Is CVE-2024-40631 exploitable, and should I be worried? Whether CVE-2024-40631 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2024-40631 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2024-40631? Upgrade
@udecode/plate-mediato 36.0.10 or later.