8.1high
Deserialization of Untrusted Data
- Severity
- 8.1high CVSS:3.1 by snyk
- Exploit likelihood
- 2.01% (higher than 81% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- snyk
- Also known as
- GHSA-mj46-r4gr-5x83SNYK-JS-GATSBYPLUGINMDX-2405699
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| gatsby-plugin-mdx | from unspecified before 2.14.1, from 3.0.0 before unspecified, from unspecified before 3.15.2 | CVE List |
| gatsby-plugin-mdx (npm) | before 2.14.1, from 3.0.0 before 3.15.2 | GitHub Advisory Database |
| gatsbyjs gatsby-plugin-mdx | before 2.14.1, from 3.0.0 before 3.15.2 | NVD |
All scores
| snyk | 8.1high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N/E:P |
| GitHub | 8.1high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.5high CVSS:2.0 | AV:N/AC:L/Au:N/C:P/I:P/A:P |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
Impact
The 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.
To 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:
---js
((require("child_process")).execSync("id >> /tmp/rce"))
---
Patches
A 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.
Workarounds
If an older version of gatsby-plugin-mdx must be used, input passed into the plugin should be sanitized ahead of processing.
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.
Credits
We 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.
For more information
Email us at security@gatsbyjs.com.
NVD (es)
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
References
| https://snyk.io/vuln/SNYK-JS-GATSBYPLUGINMDX-2405699 | exploit, third-party-advisory, web | |
| https://drive.google.com/file/d/1EoCzbwTWOM8-fjvwMbH3bqcZ2iKksxTW/view?usp=sharing | exploit, third-party-advisory, web | |
| https://github.com/gatsbyjs/gatsby/pull/35830 | exploit, patch, third-party-advisory, web | |
| https://github.com/gatsbyjs/gatsby/pull/35830/commits/f214eb0694c61e348b2751cecd1aace2046bc46e | patch, third-party-advisory, web | |
| https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-mj46-r4gr-5x83 | web | |
| https://nvd.nist.gov/vuln/detail/CVE-2022-25863 | advisory | |
| https://github.com/gatsbyjs/gatsby | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2022-25863 changed 2024-09-17 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-mj46-r4gr-5x83 changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2022-25863 changed 2026-09-29 | Public domain |