{"id":"GHSA-7ch4-rr99-cqcw","revision":"924c756398e14d0a8738d6d74f4b2029","records":[{"revision":"924c756398e14d0a8738d6d74f4b2029","observedAt":"2026-10-24T13:17:17.793+00:00","statement":{"source":"osv","id":"GHSA-7ch4-rr99-cqcw","aliases":["CVE-2023-22491"],"title":"gatsby-transformer-remark has possible unsanitized JavaScript code injection","description":"### 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).","state":0,"publishedAt":"2023-01-11T18:27:15+00:00","modifiedAt":"2026-09-10T03:49:51.0232905+00:00","affected":[{"ecosystem":"npm","name":"gatsby-transformer-remark","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"6.0.0"},{"kind":"fixed","version":"6.3.2"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"gatsby-transformer-remark","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"5.25.1"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-7ch4-rr99-cqcw","https://nvd.nist.gov/vuln/detail/CVE-2023-22491","https://github.com/gatsbyjs/gatsby"],"sourceUrl":"https://github.com/advisories/GHSA-7ch4-rr99-cqcw","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-7ch4-rr99-cqcw","identifiers":["GHSA-7ch4-rr99-cqcw","CVE-2023-22491"]},"retained":false,"historicalAffected":[]}],"coverage":[]}