react-doctor/mdx-ssr-execution-risk
Compiling untrusted MDX with the full pipeline runs attacker-supplied JSX and expressions on your server, which can lead to code execution.
- Category: Security
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: production source files (.js/.ts/.jsx/.tsx, etc.); test/build/doc/generated paths skipped
- Tags: security-scan
- Default: Enabled
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires when an MDX library surface (@mdx-js/mdx, next-mdx-remote, or MDXRemote/compileMDX/evaluateMdx) is followed within ~700 chars by an untrusted-source or dangerous-flag marker: repo/customer/tenant/user-content|markdown|mdx|input|provided|generated|submitted/untrusted/searchParams/req./request./fetch(/prisma./db./database/rehypeRaw/allowDangerousHtml. Comments are stripped first. FALSE POSITIVE: the file compiles its own first-party, build-time MDX (docs/blog content from the repo's own content/ directory) with no attacker-controlled source — generic library usage co-occurring with a word like content is not itself a vulnerability; a bare evaluate/compile not tied to an MDX surface is also excluded.
Fix prompt
Use this once validation confirms the diagnostic is real.
Never compile or evaluate attacker-controlled MDX with the full pipeline. For untrusted content, use a constrained compiler: disable JSX, expressions, and raw HTML (do not enable rehype-raw or allowDangerousHtml), render through a sandbox with an allowlisted component set, and prefer plain Markdown that cannot run code. Do not cache one tenant's rendered output where another tenant can read it.
Related rules
More Security rules from the rules reference:
react-doctor/nextjs-no-side-effect-in-get-handler: Move the side effect to a POST handler and use a <form> or fetch with method POST — GET requests can be triggered by prefetching and are vulnerable to CSRFreact-doctor/no-danger: Flag dangerouslySetInnerHTML — raw HTML injection bypasses JSX escaping and invites cross-site scripting.react-doctor/no-eval: Use `JSON.parse` for serialized data, `Function(...)` (still careful) for trusted templates, or refactor to avoid dynamic code executionreact-doctor/no-secrets-in-client-code: Move secrets to server-only code. Public client environment variables are bundled into browser code and must not contain secretsreact-doctor/nosql-injection-risk: Building a NoSQL query from raw client input lets an attacker inject operator-shaped keys or `$where` code and read or alter data they should not.