High priorityDisclosed

Advisory · CVE-2026-129948

Contentlayer runs JavaScript hidden in frontmatter during builds

Contentlayer's Markdown parser still has its JavaScript engine enabled, so a ---js frontmatter block in a content file executes code during the build, exposing CI secrets. No fix exists; the project is unmaintained.

Vendor
Contentlayer
Product
@contentlayer/source-files
Identifier / CWE
CVE-2026-129948
CWE-95
Action timing
Immediate
ELI5

Explain it like I’m five

Contentlayer reads the little header at the top of each Markdown file, and that reader still understands JavaScript. A content file that starts with a special JavaScript marker runs code while the site is being built, with access to everything the build can see.

SIMPLIFIED_ATTACK_PATH04 STEPS
  1. 01Attacker controls a content file

    An attacker who can add or edit content files starts a Markdown or MDX file with a ---js or ---javascript frontmatter delimiter.

  2. 02Build parses the file

    Contentlayer's parseMarkdown() hands the frontmatter to gray-matter with its JavaScript engine still enabled.

  3. 03Embedded code runs

    The JavaScript in the frontmatter executes during the build, in the same environment as the build process.

  4. 04Secrets exposed

    Code running in CI can read build secrets, environment variables, and tokens available to the build job.

What happened

Contentlayer’s @contentlayer/source-files through version 0.3.4 contains a code injection vulnerability. Attackers who control content files can execute JavaScript by abusing gray-matter’s still-enabled JavaScript engine in parseMarkdown(). Starting a Markdown or MDX file with a —js or —javascript frontmatter delimiter runs the embedded code during the build, exposing CI build secrets. The issue is rated CVSS 8.7.

The project is unmaintained, NVD marks the CVE as unsupported-when-assigned, and no fixed release exists. There is no version to upgrade to; the only defenses are controlling who can contribute content and moving off the project.

What to do

  1. Restrict who can add or edit content files in any repository built with Contentlayer, and review content contributed by outside parties before it reaches a build.
  2. Scan content repositories for files starting with —js or —javascript frontmatter delimiters.
  3. Audit CI logs and secret usage for builds that processed untrusted content, and rotate any build secrets that may have been exposed.
  4. Plan migration off Contentlayer to a maintained content layer, since no patch is coming for this or future issues in the project.
  5. Until migration is complete, run builds with least-privilege credentials and avoid giving build jobs access to production secrets.

Management note

This one reaches CI directly: a malicious content file can run code inside the build and walk away with its secrets. If your site takes content from contributors, treat this as a supply-chain exposure and rotate build credentials after checking what ran.