Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1oM3BxLTY2N3gtcjc4Oc4AA95v

Plate media plugins has a XSS in media embed element when using custom URL parsers

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}
    // ...
  />
);

Patches

@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.

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

Permalink: https://github.com/advisories/GHSA-h3pq-667x-r789
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1oM3BxLTY2N3gtcjc4Oc4AA95v
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 4 months ago
Updated: 4 months ago


CVSS Score: 8.1
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N

Identifiers: GHSA-h3pq-667x-r789, CVE-2024-40631
References: Repository: https://github.com/udecode/plate
Blast Radius: 18.1

Affected Packages

npm:@udecode/plate-media
Dependent packages: 13
Dependent repositories: 171
Downloads: 339,947 last month
Affected Version Ranges: < 36.0.10
Fixed in: 36.0.10
All affected versions: 16.0.0, 16.0.1, 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.13.1, 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.3.2, 20.4.0, 20.5.0, 20.6.0, 20.6.3, 20.7.0, 20.7.2, 21.0.0, 21.1.5, 21.3.0, 21.3.2, 21.3.4, 21.4.1, 21.4.2, 21.5.0, 21.5.1, 22.0.0, 22.0.1, 22.0.2, 23.0.0, 23.3.0, 23.3.1, 23.6.0, 23.7.0, 23.7.4, 24.0.0, 24.0.1, 24.0.2, 24.2.0, 24.3.0, 24.3.1, 24.3.2, 24.3.5, 24.3.6, 24.4.0, 24.5.2, 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, 30.5.3, 31.0.0, 32.0.0, 33.0.0, 33.0.2, 34.0.0, 34.0.2, 34.1.0, 36.0.0
All unaffected versions: 36.0.10, 36.2.0, 36.2.2, 36.5.3, 36.5.9, 37.0.0, 38.0.0, 38.0.1, 38.0.6, 39.0.0, 39.2.0, 39.2.4, 39.2.13, 39.3.0, 39.3.1, 39.3.2, 39.3.3, 40.0.0, 40.2.0, 40.2.1, 40.2.3