/

CVE-2026-129948

Severity:

HIGH RISK

(8.8)

Code Injection (CWE-95) in Contentlayer Source Files

CVE-2026-129948

Received

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Arbitrary JavaScript execution during builds

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Contentlayer's source-files package can execute JavaScript embedded in Markdown or MDX frontmatter during parsing. If an attacker can control content files that are processed in a build, they may run code in the build environment and expose accessible CI secrets.

Affected context

The issue occurs in Contentlayer's @contentlayer/source-files Markdown parsing path, where parseMarkdown() uses gray-matter with its JavaScript engine enabled. It becomes risky when attacker-controlled Markdown or MDX files are parsed during a build, particularly in CI environments that hold secrets or have access to other sensitive resources.

Exploit preconditions

  • Attack surface: Markdown or MDX content processed by the Contentlayer source-files parser
  • Required access: Ability to introduce or modify content files consumed by a build
  • Trigger point: Parsing frontmatter during the build
  • Why exploitation is possible: The parser permits JavaScript frontmatter to execute while processing the content

Why this happens

The root cause is evaluation of attacker-controlled input during frontmatter parsing. Allowing gray-matter's JavaScript engine to process content treats data as executable code, matching CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection').

Potential impact

  • Arbitrary JavaScript may run with the permissions of the build process
  • CI secrets available to that process could be exposed
  • Build artifacts or source content could be altered
  • Connected systems or resources accessible to the build environment could be affected

General mitigation guidance

Mitigation patterns focus on treating content as data rather than executable logic and limiting the consequences of a compromised build.

  • Disable JavaScript evaluation in frontmatter parsing and use non-evaluating parsing modes
  • Restrict who can contribute or modify content consumed by builds
  • Keep secrets out of untrusted build jobs and limit credentials to the minimum required
  • Isolate builds and restrict their access to networks, files, and other resources
  • Validate content against a narrow expected schema without executing it

How teams detect issues like this

Detection can include static analysis and code review for parser configurations that enable JavaScript evaluation, especially in Markdown or MDX frontmatter handling. Review content-processing pipelines for untrusted contributors and check CI policies for secret exposure, build isolation, and least-privilege permissions. Automated review tools can help flag risky parsing options and content-to-code execution paths.

Sources

SourceLink
github.comgithub.com/contentlayerdev/contentlayer/blob/v0.3.4/packages/@contentlayer/source-files/src/fetchData/makeCacheItemFromFilePath.ts#L221-L228
github.comgithub.com/contentlayerdev/contentlayer/issues/688
vulncheck.comvulncheck.com/advisories/contentlayer-contentlayer-source-files-through-0.3.4-code-injection-via-javascript-frontmatter

Frequently asked

questions

The described path requires attacker-controlled content to be processed by a build. Whether that is remotely exploitable depends on how content changes enter the build pipeline.

They need a way to add or modify Markdown or MDX files that Contentlayer parses. The resulting code runs with the build process's permissions.

Parse frontmatter without enabling JavaScript evaluation, and treat content strictly as data.

Restrict untrusted content in build pipelines, isolate build jobs, minimize secret access, and review parsing configurations for evaluation of input.

Find out what's already
exploitable in your codebase.