/

CVE-2026-126774

Severity:

HIGH RISK

(8.2)

Code Injection (CWE-94) in @tinacms/mdx Serializer

CVE-2026-126774

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

JavaScript execution in visitor browsers and potentially on build or server-side rendering hosts

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The @tinacms/mdx serializer can write rich-text values into MDX expressions without escaping them, allowing crafted content to break out of those expressions. An authenticated content editor may be able to cause JavaScript to run when the content is rendered in a visitor's browser or processed by a build or server-side rendering host.

Affected context

The issue concerns MDX serialization in @tinacms/mdx. It becomes risky when authenticated editors can save rich-text values that the serializer places into list field or highlightColor expressions without context-appropriate escaping, and those stored files are later rendered or processed.

Exploit preconditions

  • Attack surface: MDX content serialization and subsequent rendering or processing
  • Required access: Authenticated content-editing access sufficient to save rich-text values
  • Trigger point: The crafted stored content is rendered in a browser or handled by a build or server-side rendering process
  • Why exploitation is possible: Unescaped values can break out of MDX expressions and be interpreted as executable code

Why this happens

The serializer places content values into MDX expression contexts without safely encoding them for those contexts. This is a code injection flaw mapped to CWE-94: Improper Control of Generation of Code, because data is incorporated into generated code in a way that can alter its intended structure and behavior.

Potential impact

  • JavaScript could execute in visitors' browsers when affected content is rendered.
  • Build or server-side rendering hosts may execute attacker-controlled code while processing stored MDX.
  • Browser sessions or data accessible to the affected page could be exposed or manipulated.
  • Build or rendering environments could be compromised, depending on their permissions and available resources.

General mitigation guidance

Defensive approaches focus on keeping content as data rather than allowing it to change generated code structure.

  • Use context-aware escaping or structured serialization for values inserted into MDX expressions.
  • Prefer safe-by-default APIs that separate data from executable expressions.
  • Validate content against strict schemas and reduce the amount of editor-controlled input accepted in expression contexts.
  • Apply least privilege and isolate build and rendering processes from sensitive resources.
  • Treat stored content as untrusted when it is rendered or processed.

How teams detect issues like this

  • Use static analysis to identify serializers that interpolate untrusted values into MDX, JavaScript, or other executable expressions.
  • Review code paths that generate list field or highlightColor expressions, checking whether values are encoded for their output context.
  • Test serialization and rendering boundaries with content containing syntax-significant characters, without relying on unsafe execution.
  • Enforce code review or CI policies that flag dynamic code generation and require safe serialization patterns.
  • Consider automated code review tools as an additional way to surface risky interpolation patterns.

Sources

SourceLink
github.comgithub.com/tinacms/tinacms/blob/%40tinacms/mdx%400.60.3/packages/%40tinacms/mdx/src/stringify/acorn.ts#L81
github.comgithub.com/tinacms/tinacms/commit/19285c6deeee52c380e8b2fdeafedc9530dc0618
github.comgithub.com/tinacms/tinacms/pull/7958
github.comgithub.com/tinacms/tinacms/releases/tag/%40tinacms/mdx%402.4.2
github.comgithub.com/tinacms/tinacms/security/advisories/GHSA-6vw5-w22x-ghxv
vulncheck.comvulncheck.com/advisories/tinacms-mdx-before-2.4.2-code-injection-via-mdx-serializer-rich-text-values

Frequently asked

questions

The described attack requires authenticated content-editing access sufficient to save crafted rich-text values.

No. The description also identifies potential code execution on build or server-side rendering hosts when they process the affected stored MDX.

Keep values as data and use structured serialization or context-aware escaping so content cannot alter the structure of generated MDX expressions.

Treat editor-provided content as untrusted, minimize its use in executable contexts, and review serialization boundaries with static analysis and security-focused tests.

Find out what's already
exploitable in your codebase.