---
id: "CVE-2026-129948"
page: "https://infrastack.ai/live/CVE-2026-129948"
kind: "vulnerability"
aliases: ["CVE-2026-129948"]
title: "Contentlayer: crafted content files run JavaScript during builds"
severity: "high"
cvss: 8.8
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "@contentlayer/source-files", "fixed": [], "affected": "<= 0.3.4", "ecosystem": "npm"}]
ecosystems: []
tags: ["build-time-rce", "ci", "contentlayer", "gray-matter", "mdx", "next.js", "npm", "package"]
not_affected_if: ["content-written-by-trusted-team-only", "no-ci-secrets-on-build"]
published_at: "2026-11-16T15:17:29+00:00"
first_seen_at: "2026-11-16T15:37:57+00:00"
updated_at: "2026-11-16T15:42:30+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-129948", "first_seen_at": "2026-11-16T15:37:57+00:00"}, {"source": "analyst", "url": "https://github.com/contentlayerdev/contentlayer/issues/688", "first_seen_at": "2026-11-16T15:42:30+00:00", "cites": ["https://github.com/contentlayerdev/contentlayer/issues/688", "https://github.com/advisories/GHSA-j9gx-vjm3-jpmm", "https://github.com/jonschlinkert/gray-matter/issues/182"]}]
exploit_sources: []
---

# Contentlayer: crafted content files run JavaScript during builds

Link for people: https://infrastack.ai/live/CVE-2026-129948 (this .md is for agents)

The @contentlayer/source-files npm package passes Markdown and MDX frontmatter to gray-matter, whose JavaScript engine is still enabled, so a ---js or ---javascript block in a content file runs as code. An attacker who can place or edit content files can run code during the build and read CI build secrets.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- npm:@contentlayer/source-files affected <= 0.3.4 fixed no fixed version listed

## How to check

- Run `npm ls @contentlayer/source-files gray-matter` (or check the lockfile). Affected: @contentlayer/source-files <= 0.3.4.
- Confirm whether content files (.md/.mdx) can come from outside contributors, PRs from forks, or external sources and whether the build has CI secrets.
- Search content for files starting with `---js` or `---javascript`.

## Fix

No patched version of @contentlayer/source-files as of 2026-11-16; last affected is 0.3.4 and the maintainers have not responded on issue #688. gray-matter 4.0.3 also has no upstream fix. Workaround: build only trusted content, keep secrets out of the build environment, or patch gray-matter so engines.javascript throws (as other projects do).

## Timeline

- 2026-11-16T15:37:57+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-129948
- 2026-11-16T15:42:30+00:00 analyst https://github.com/contentlayerdev/contentlayer/issues/688 — VulnCheck advisory + reporter's issue contentlayer#688 (open, no maintainer reply, no fix as of 2026-11-16). gray-matter 4.0.3 JS engine still enabled upstream (CVE-2026-78847, gray-matter#182 open). No PoC link, no exploitation seen. Nothing marked verified: no vendor/maintainer page.

## Documents

- [advisory] Third-party advisory: www.vulncheck.com https://www.vulncheck.com/advisories/contentlayer-contentlayer-source-files-through-0.3.4-code-injection-via-javascript-frontmatter
- [describes] Contentlayer #688 Security review: frontmatter evaluation https://github.com/contentlayerdev/contentlayer/issues/688
- [mentions] gray-matter eval of js frontmatter (CVE-2026-78847) https://github.com/advisories/GHSA-j9gx-vjm3-jpmm
- [mentions] gray-matter #182 Remove RCE-vulnerable JavaScript engine (open) https://github.com/jonschlinkert/gray-matter/issues/182

## From the sources

Contentlayer @contentlayer/source-files through 0.3.4 contains a code injection vulnerability that allows attackers who control content files to execute JavaScript by abusing gray-matter's still-enabled JavaScript engine in parseMarkdown(). Attackers can start a Markdown or MDX file with a ---js or ---javascript frontmatter delimiter to run code during build, exposing CI build secrets.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
