CVE-2023-22491 gatsby-transformer-remark vulnerable to unsanitized JavaScript code injection

High 8.1 Published Updated

Attackers can execute arbitrary JavaScript on the build server by injecting code into Markdown files processed by the Gatsby remark plugin.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-22491?

CVE-2023-22491 is a high-severity code injection vulnerability in gatsbyjs gatsby, published on 13 Jan 2023. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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 `[email protected]` and `[email protected]` 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.

Weakness: CWE-79, CWE-89, CWE-20

Which versions are affected by CVE-2023-22491?

4 open source packages ship an affected version, including gatsby-transformer-remark. It affects 1 product.

PackageAffectedFixed in
gatsby-transformer-remark npmAll versions5.25.1
gatsby-transformer-remark npmAll versions5.25.1
gatsby-transformer-remark npmFrom 6.0.06.3.2
gatsby-transformer-remark npmFrom 6.0.06.3.2

Products include Gatsbyjs Gatsby-Transformer-Remark.

How do I fix CVE-2023-22491?

Upgrade gatsby-transformer-remark to a fixed version for your release line: 5.25.1 or 6.3.2.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2023-22491 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-22491 exists.

Sources

Also known as GHSA-7ch4-rr99-cqcw, UBUNTU-CVE-2023-22491.

Is CVE-2023-22491 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free