{"id":"CVE-2022-25863","aliases":["CVE-2022-25863","GHSA-mj46-r4gr-5x83","SNYK-JS-GATSBYPLUGINMDX-2405699"],"related":[],"kind":"vulnerability","state":"published","title":"Deserialization of Untrusted Data","summary":"The package gatsby-plugin-mdx before 2.14.1, from 3.0.0 and before 3.15.2 are vulnerable to Deserialization of Untrusted Data when passing input through to the gray-matter package, due to its default configurations that are missing input sanitization. Exploiting this vulnerability is possible when passing input in both webpack (MDX files in src/pages or MDX file imported as a component in frontend / React code) and data mode (querying MDX nodes via GraphQL). Workaround: If an older version of gatsby-plugin-mdx must be used, input passed into the plugin should be sanitized ahead of processing.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"The package gatsby-plugin-mdx before 2.14.1, from 3.0.0 and before 3.15.2 are vulnerable to Deserialization of Untrusted Data when passing input through to the gray-matter package, due to its default configurations that are missing input sanitization. Exploiting this vulnerability is possible when passing input in both webpack (MDX files in src/pages or MDX file imported as a component in frontend / React code) and data mode (querying MDX nodes via GraphQL). Workaround: If an older version of gatsby-plugin-mdx must be used, input passed into the plugin should be sanitized ahead of processing.","source":"cvelist"},{"lang":"en","text":"### Impact\nThe gatsby-plugin-mdx plugin prior to versions 3.15.2 and 2.14.1 passes input through to the `gray-matter` npm package, which is vulnerable to JavaScript injection in its default configuration, unless input is sanitized.  The vulnerability is present when passing input in both webpack (MDX files in `src/pages` or MDX file imported as component in frontend / React code) and data mode (querying MDX nodes via GraphQL).  Injected JavaScript executes in the context of the build server.\n\nTo exploit this vulnerability untrusted/unsanitized input would need to be sourced or added into an MDX file.  The following MDX payload demonstrates a vulnerable configuration:\n```\n---js\n((require(\"child_process\")).execSync(\"id >> /tmp/rce\"))\n--- \n```\n\n### Patches\nA patch has been introduced in `gatsby-plugin-mdx@3.15.2` and `gatsby-plugin-mdx@2.14.1` which mitigates the issue by disabling the `gray-matter` JavaScript Frontmatter engine.  The patch introduces a new option, `JSFrontmatterEngine` which is set to `false` by default.  When setting `JSFrontmatterEngine` to `true`, input passed to `gatsby-plugin-mdx` must be sanitized before processing to avoid a security risk.  Warnings are displayed when enabling `JSFrontmatterEngine` to `true` or if it appears that the MDX input is attempting to use the Frontmatter engine.\n\n### Workarounds\nIf an older version of `gatsby-plugin-mdx` must be used, input passed into the plugin should be sanitized ahead of processing.\n\n**We encourage projects to upgrade to the latest major release branch for all Gatsby plugins to ensure the latest security updates and bug fixes are received in a timely manner.**\n\n### Credits\nWe would like to thank Snyk [snyk.io] for initially bringing the issue to our attention, as well as Feng Xiao and Zhongfu Su, who reported the issue to Snyk.\n\n### For more information\nEmail us at [security@gatsbyjs.com](mailto:security@gatsbyjs.com).","format":"markdown","source":"ghsa"},{"lang":"es","text":"El paquete gatsby-plugin-mdx versiones anteriores a 2.14.1, a partir de la 3.0.0 y anteriores a 3.15.2, es vulnerable a una Deserialización de Datos No Confiables cuando es pasada la entrada mediante el paquete gray-matter, debido a sus configuraciones por defecto que carecen de saneo de entrada. La explotación de esta vulnerabilidad es posible cuando es pasada la entrada tanto en modo webpack (archivos MDX en src/pages o archivo MDX importado como componente en código frontend / React) como en modo datos (consulta de nodos MDX por medio de GraphQL). Mitigación: Si es debido usar una versión anterior de gatsby-plugin-mdx, la entrada que es pasada al plugin debe ser saneada antes del procesamiento","source":"nvd"}],"published":"2022-06-03T22:32:06.000Z","modified":"2026-09-29T15:50:31.907Z","severity":{"scorer":"snyk","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N/E:P","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"snyk","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N/E:P","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","score":7.5,"rating":"HIGH"}],"cwes":["CWE-502"],"affected":[{"ranges":[{"type":"custom","introduced":"unspecified","fixed":"2.14.1","status":"affected"},{"type":"custom","introduced":"3.0.0","fixed":"unspecified","status":"affected"},{"type":"custom","introduced":"unspecified","fixed":"3.15.2","status":"affected"}],"product":"gatsby-plugin-mdx","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.14.1"}],"ecosystem":"npm","package":"gatsby-plugin-mdx","purl":"pkg:npm/gatsby-plugin-mdx","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"3.0.0","status":"affected","fixed":"3.15.2"}],"ecosystem":"npm","package":"gatsby-plugin-mdx","purl":"pkg:npm/gatsby-plugin-mdx","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.14.1"},{"status":"affected","introduced":"3.0.0","fixed":"3.15.2"}],"vendor":"gatsbyjs","product":"gatsby-plugin-mdx","cpe":"cpe:2.3:a:gatsbyjs:gatsby-plugin-mdx:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://snyk.io/vuln/SNYK-JS-GATSBYPLUGINMDX-2405699","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://drive.google.com/file/d/1EoCzbwTWOM8-fjvwMbH3bqcZ2iKksxTW/view?usp=sharing","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gatsbyjs/gatsby/pull/35830","tags":["exploit","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gatsbyjs/gatsby/pull/35830/commits/f214eb0694c61e348b2751cecd1aace2046bc46e","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-mj46-r4gr-5x83","tags":["web"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-25863","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/gatsbyjs/gatsby","tags":["package"],"sources":["ghsa"]}],"credits":["Feng Xiao and Zhongfu Su"],"assigner":"snyk","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-25863","url":"https://www.cve.org/CVERecord?id=CVE-2022-25863","licence":"CVE Terms of Use","modified":"2024-09-17T00:31:34.621Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mj46-r4gr-5x83","url":"https://github.com/advisories/GHSA-mj46-r4gr-5x83","licence":"CC-BY-4.0","modified":"2026-07-08T06:50:01.480Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-25863","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-25863","licence":"Public domain","modified":"2026-09-29T15:50:31.907Z"}],"updatedAt":"2026-11-25T22:58:12.218Z","epss":{"score":0.02009,"percentile":0.81423,"date":"2026-12-01T12:00:22.000Z"}}