Contentlayer frontmatter can execute code inside the build
CVE-2026-129948 affects @contentlayer/source-files through 0.3.4. The vulnerable package passes Markdown content through a processing path where gray-matter's JavaScript engine remains enabled. A person who controls a content file can place a JavaScript expression in frontmatter and have it evaluated while the site or application is built. The CVSS 3.1 score is 8.8.
The trust boundary in a content pipeline
A Markdown file looks like data. The parser may treat part of that data as configuration, and some frontmatter engines support executable JavaScript. Contentlayer used that capability while parsing source files. Once executable syntax is accepted, a file from a content contributor, imported repository or third-party template sits at the same level as build code.
The public record says attackers who control content files can execute JavaScript through this path. It does not publish a complete exploit file, identify every deployment pattern or state that the package is used by every Contentlayer installation. Review the actual source adapter and build command before assigning scope.
Build-time execution can reach environment variables used during deployment, package-manager credentials, signing keys and source-repository tokens. It can also modify generated assets or add code to the output. The browser may never receive the malicious frontmatter directly. The consequence appears in the build worker and in artifacts produced after the content was accepted.
Find the package and the content path
Search dependency manifests and lockfiles for @contentlayer/source-files and confirm whether version 0.3.4 or an earlier release is installed. Contentlayer projects may use a wrapper, a monorepo cache or a generated directory that hides the direct package name. A search of the source tree and lockfile is more reliable than inspecting a single package file.
Map who can create or update files consumed by the build. That includes repository contributors, CMS exports, sync jobs, template repositories and generated content from external feeds. A private repository reduces exposure only if every contributor and automation with write access is trusted. Pull-request previews can be especially valuable because they often run a build with secrets or cloud credentials.
The reviewed public records do not identify a fixed release. If that is still true, remove the unsafe JavaScript frontmatter path or isolate the build. Disable JavaScript evaluation in the frontmatter parser where the application allows that configuration. If the package cannot be configured safely, pin it out of the build or replace the processing step with a parser that treats frontmatter as data.
Isolate the build worker
A content build should run with a short-lived identity and a narrow set of secrets. Pull-request builds should not receive production deployment credentials. Use a separate job for trusted releases, require review before a release job runs, and restrict network egress to the registries and services the build needs. These controls do not prevent code execution in the parser, but they reduce what a malicious content file can reach.
Logs should identify the commit, content file and build step that ran. If a suspicious build is found, preserve the workspace, dependency lockfile and generated output. Review cloud audit logs for the build identity, package registry events and artifact uploads. Rotate deployment tokens and signing keys that were available to the job. A cache that contains a malicious generated file should be discarded.
Treat content as code when the parser does
Security reviews often classify Markdown as low-risk input. That classification changes when a parser evaluates expressions inside it. The defensive rule is simple: content that can execute during a build needs the same review, isolation and audit trail as the build script. If the team does not want that burden, the parser must not execute content.
Top comments (0)