{"id":"CVE-2023-22491","aliases":["CVE-2023-22491","GHSA-7ch4-rr99-cqcw"],"related":[],"kind":"vulnerability","state":"published","title":"gatsby-transformer-remark vulnerable to unsanitized JavaScript code injection","summary":"Gatsby is a free and open source framework based on React that helps developers build websites and apps. The gatsby-transformer-remark plugin prior to versions 5.25.1 and 6.3.2 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 in gatsby-transformer-remark when passing input in data mode (querying MarkdownRemark 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 by or added into a file processed by gatsby-transformer-remark. A patch has been introduced in `gatsby-transformer-remark@5.25.1` and `gatsby-transformer-remark@6.3.2` which mitigates the issue by disabling the `gray-matter` JavaScript Frontmatter engine. As a workaround, if an older version of `gatsby-transformer-remark` must be used, input passed into the plugin should be sanitized ahead of processing. It is encouraged for  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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Gatsby is a free and open source framework based on React that helps developers build websites and apps. The gatsby-transformer-remark plugin prior to versions 5.25.1 and 6.3.2 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 in gatsby-transformer-remark when passing input in data mode (querying MarkdownRemark 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 by or added into a file processed by gatsby-transformer-remark. A patch has been introduced in `gatsby-transformer-remark@5.25.1` and `gatsby-transformer-remark@6.3.2` which mitigates the issue by disabling the `gray-matter` JavaScript Frontmatter engine. As a workaround, if an older version of `gatsby-transformer-remark` must be used, input passed into the plugin should be sanitized ahead of processing. It is encouraged for  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.","source":"cvelist"},{"lang":"en","text":"### Impact\nThe gatsby-transformer-remark plugin prior to versions 5.25.1 and 6.3.2 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 in gatsby-transformer-remark when passing input in data mode (querying MarkdownRemark 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 by or added into a file processed by gatsby-transformer-remark.  The following 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-transformer-remark@5.25.1` and `gatsby-transformer-remark@6.3.2` 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 MarkdownRemark input is attempting to use the Frontmatter engine.\n\n### Workarounds\nIf an older version of `gatsby-transformer-remark` 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\n### For more information\nEmail us at [security@gatsbyjs.com](mailto:security@gatsbyjs.com).","format":"markdown","source":"ghsa"},{"lang":"es","text":"Gatsby es un framework gratuito y de código abierto basado en React que ayuda a los desarrolladores a crear sitios web y aplicaciones. El complemento gatsby-transformer-remark anterior a las versiones 5.25.1 y 6.3.2 pasa la entrada al paquete npm `gray-matter`, que es vulnerable a la inyección de JavaScript en su configuración predeterminada, a menos que la entrada esté desinfectada. La vulnerabilidad está presente en gatsby-transformer-remark cuando se pasa entrada en modo de datos (consultando nodos MarkdownRemark a través de GraphQL). El JavaScript inyectado se ejecuta en el contexto del servidor de compilación. Para explotar esta vulnerabilidad, la entrada no confiable/no desinfectada tendría que obtenerse o agregarse a un archivo procesado por gatsby-transformer-remark. Se introdujo un parche en `gatsby-transformer-remark@5.25.1` y `gatsby-transformer-remark@6.3.2` que mitiga el problema al deshabilitar el motor JavaScript Frontmatter de `materia gris`. Como workaround, si se debe utilizar una versión anterior de `gatsby-transformer-remark`, la entrada pasada al complemento debe desinfectarse antes del procesamiento. Se recomienda que los proyectos actualicen a la última versión principal de todos los complementos de Gatsby para garantizar que las últimas actualizaciones de seguridad y correcciones de errores se reciban de manera oportuna.","source":"nvd"}],"published":"2023-01-11T18:27:15.000Z","modified":"2026-09-29T15:06:00.643Z","severity":{"scorer":"GitHub_M","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"},"severities":[{"scorer":"GitHub_M","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":"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:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"}],"cwes":["CWE-20","CWE-79","CWE-89"],"affected":[{"ranges":[{"version":">= 6.0.0, < 6.3.2","status":"affected"},{"version":"< 5.25.1","status":"affected"}],"vendor":"gatsbyjs","product":"gatsby","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"6.0.0","status":"affected","fixed":"6.3.2"}],"ecosystem":"npm","package":"gatsby-transformer-remark","purl":"pkg:npm/gatsby-transformer-remark","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.25.1"}],"ecosystem":"npm","package":"gatsby-transformer-remark","purl":"pkg:npm/gatsby-transformer-remark","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.25.1"},{"status":"affected","introduced":"6.0.0","fixed":"6.3.2"}],"vendor":"gatsbyjs","product":"gatsby-transformer-remark","cpe":"cpe:2.3:a:gatsbyjs:gatsby-transformer-remark:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-7ch4-rr99-cqcw","tags":["exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22491","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/gatsbyjs/gatsby","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2025-03-11T13:33:35.839Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-22491","url":"https://www.cve.org/CVERecord?id=CVE-2023-22491","licence":"CVE Terms of Use","modified":"2025-03-11T13:34:01.261Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-7ch4-rr99-cqcw","url":"https://github.com/advisories/GHSA-7ch4-rr99-cqcw","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:51.023Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-22491","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22491","licence":"Public domain","modified":"2026-09-29T15:06:00.643Z"}],"updatedAt":"2026-11-25T22:58:21.595Z","epss":{"score":0.00605,"percentile":0.50331,"date":"2026-12-01T12:00:22.000Z"}}