High, CVSS 8.1npmAmendedPublished
Unsanitized JavaScript code injection possible in gatsby-plugin-mdx
CVE-2022-25863 · GHSA-mj46-r4gr-5x83
- Affected
- npm gatsby-plugin-mdx < 2.14.1; >= 3.0.0, < 3.15.2
- Fixed in
- 3.15.22.14.1· Vendor fix available
- Issue
- 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: 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…
Recommended action: Upgrade to 3.15.2 or 2.14.1 by release line, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.