GHSA-H3PQ-667X-R789

Vulnerability from github – Published: 2024-07-15 18:33 – Updated: 2024-07-15 21:38
VLAI?
Summary
Plate media plugins has a XSS in media embed element when using custom URL parsers
Details

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

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "@udecode/plate-media"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "36.0.10"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-40631"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-79"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-07-15T18:33:22Z",
    "nvd_published_at": "2024-07-15T19:15:03Z",
    "severity": "HIGH"
  },
  "details": "### Impact\nEditors 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.\n\nThe default parsers `parseTwitterUrl` and `parseVideoUrl` are not affected.\n\nExamples of vulnerable code:\n\n```tsx\nconst { embed } = useMediaState({\n  urlParsers: [\n    // Custom parser that does not use an allowlist or validate the URL protocol\n    (url) =\u003e ({ url }),\n  ],\n});\n\nreturn (\n  \u003ciframe\n    src={embed!.url}\n    // ...\n  /\u003e\n);\n```\n\n```tsx\nconst { url } = useMediaState();\n\nreturn (\n  \u003ciframe\n    // url property used directly from useMediaState() with no sanitisation\n    src={url}\n    // ...\n  /\u003e\n);\n```\n\n\n```tsx\nconst { url } = element;\n\nreturn (\n  \u003ciframe\n    // url property used directly from element with no sanitisation\n    src={url}\n    // ...\n  /\u003e\n);\n```\n\n### Patches\n`@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`.\n\nIn 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\u0027re using either of these properties directly, you will still need to validate the URL yourself.\n\n### Workarounds\nEnsure that any custom `urlParsers` do not allow `javascript:`, `data:` or `vbscript:` URLs to be returned in the `url` property of their return values.\n\nIf `url` is consumed directly, validate the URL protocol before passing it to the `iframe` element.\n\n### References\nHow to verify the protocol of a URL: https://stackoverflow.com/a/43467144",
  "id": "GHSA-h3pq-667x-r789",
  "modified": "2024-07-15T21:38:09Z",
  "published": "2024-07-15T18:33:22Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/udecode/plate/security/advisories/GHSA-h3pq-667x-r789"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-40631"
    },
    {
      "type": "WEB",
      "url": "https://github.com/udecode/plate/commit/1bc0971774fbfb770780c9bdb94746a6f0f196a0"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/udecode/plate"
    },
    {
      "type": "WEB",
      "url": "https://stackoverflow.com/a/43467144"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Plate media plugins has a XSS in media embed element when using custom URL parsers"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…