{
  "id": 21506895,
  "title": "Contentlayer frontmatter can execute code inside the build",
  "url": "https://urgent.news/2026/11/24/contentlayer-frontmatter-can-execute-code-inside-the-build",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-24T00:24:55.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/kozhevniko/contentlayer-frontmatter-can-execute-code-inside-the-build-2d87"
  },
  "original_language": "en",
  "account": "Contentlayer's frontmatter feature can execute JavaScript code during the build process, which has been identified as a vulnerability in the @contentlayer/source-files package. This occurs because the package passes Markdown content through a processing path where JavaScript remains enabled. If a user with control over a content file inserts a JavaScript expression in the frontmatter, it will be executed while the site or application is being built.\n\nThe severity of this vulnerability is rated at 8.8 on the CVSS 3.1 scale. The risk stems from the fact that a Markdown file, which is treated as data, may contain executable JavaScript code. This code can be executed as if it were part of the build, putting it on equal footing with legitimate build code. Once executable syntax is accepted, a file from a content contributor, an imported repository, or a third-party template can behave just like the build code itself.\n\nPotential attacks could involve executing arbitrary JavaScript, accessing or modifying environment variables, package-manager credentials, signing keys, or source-repository tokens. The malicious content might also modify generated assets or inject additional code into the output. Importantly, the malicious frontmatter may not be directly seen by the browser, as it is processed on the build worker before it reaches the public-facing browser.\n\nTo mitigate this risk, it is recommended to search dependency manifests and lockfiles for the vulnerable package and version. It's also important to map who can create or update files consumed by the build, as this includes repository contributors, CMS exports, sync jobs, template repositories, and external feeds. When possible, private repositories can reduce exposure if all contributors and automation with write access are trusted. Regularly reviewing build commands and configurations can also help identify and isolate vulnerable build steps.\n\nAdditional security measures include disabling JavaScript evaluation in the frontmatter parser, pinning unsafe versions of the package out of the build, isolating the build worker, and implementing strict logging and monitoring of build events. These controls can help limit the impact of a potentially malicious build, but they do not eliminate the possibility of code execution. Ultimately, treating content as code and applying the same rigorous review, isolation, and auditing that is applied to build scripts is the most effective way to secure a system where frontmatter can execute code.",
  "summary": "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…",
  "key_points": [
    "Contentlayer's frontmatter can execute JavaScript code during build process",
    "Security vulnerability rated 8.8 on CVSS 3.1 scale",
    "Mitigation includes disabling JavaScript, pinning versions, strict logging"
  ],
  "editors_take": "Treating Markdown data as executable code collapses the boundary between content and build scripts, granting any file contributor the same level of access as a trusted developer.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}