High priorityDisclosed

Advisory · CVE-2026-129947

Contentlayer code injection hides in a content file name

A crafted content file name with embedded single quotes breaks out of the import specifier in Contentlayer's generated _index.mjs, executing injected JavaScript when the dev server imports the module. No fix exists; the project is unmaintained.

Vendor
Contentlayer
Product
@contentlayer/core
Identifier / CWE
CVE-2026-129947
CWE-94
Action timing
Immediate
ELI5

Explain it like I’m five

Contentlayer builds a little index file listing your content, but it pastes file names into that file without escaping them. A file whose name contains a quote can smuggle in JavaScript, which runs the next time the dev server loads the index.

SIMPLIFIED_ATTACK_PATH04 STEPS
  1. 01Attacker adds a content file

    An attacker who can add content files creates one whose name embeds single quotes and JavaScript.

  2. 02Index is generated

    Contentlayer's makeDataExportFile() writes the file name into the generated _index.mjs import specifier without escaping it.

  3. 03Dev server imports the module

    When contentlayer dev or a Next.js dev server imports the generated module, the injected code breaks out of the import string.

  4. 04Code executes

    The injected JavaScript runs with the developer's privileges on the machine hosting the dev server.

What happened

Contentlayer’s @contentlayer/core through version 0.3.4 contains a code injection vulnerability. An attacker who can add content files can embed single quotes in a file name to break out of the import specifier in the generated _index.mjs produced by makeDataExportFile(). The injected JavaScript executes when contentlayer dev or a Next.js dev server imports the generated module. The issue is rated CVSS 8.6.

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 add content and moving off the project.

What to do

  1. Treat content file names as untrusted input: restrict who can add or rename content files in any repository that builds with Contentlayer.
  2. Review content repositories for file names containing quotes or other unexpected characters, especially any added by outside contributors.
  3. Audit build and dev-server logs for unusual code execution and check whether injected content reached developer machines or CI.
  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, avoid running contentlayer dev against content from untrusted sources and keep dev servers off shared or sensitive machines.

Management note

This is a dev-time code execution flaw in an abandoned project, so the risk lands on developer machines and build pipelines rather than production servers. The exposure depends entirely on who can contribute content, so the immediate control is access, and the durable fix is migration.