Safeguard
Developer Tools•

Is MDX content code? Reviewing blog pull requests safely

MDX lets Markdown import and run JavaScript at build time. Treat content pull requests as code: review them, scan them and limit who can merge to main.

Safeguard Security Team
4 min read

Yes, in practice. MDX lets authors write Markdown that can include JavaScript expressions, imports and components, and those run when the site is built or rendered. A content pull request can therefore execute code, so it deserves review, scanning and limits on who can merge.

Markdown versus MDX

Plain Markdown is data. A converter turns it into HTML, and the worst case is odd markup. MDX is a superset that lets a file import modules and use JSX components. The upside is rich, interactive posts. The cost is that a document is no longer inert.

FeaturePlain MarkdownMDX
Raw HTMLOften allowed, depends on converterAllowed as components
ImportsNoYes
ExpressionsNoYes
Runs at build timeThe converterAuthor code can run
Review burdenLowSame as source code

What could go wrong

  1. A contributor imports a module that reads environment variables during the build and writes them into a page or sends them out.
  2. A component embeds a third-party script that loads on every visitor's page.
  3. A compromised contributor account pushes a content change that looks harmless.
  4. A new dependency is added in the same pull request as a blog post, so it slips past reviewers who skim just the prose.

None of these are exotic. They are the normal risks of running contributed code.

A safe workflow

  1. Protect the main branch. Require review before merge, and do not let authors approve their own changes.
  2. Use code owners. Assign component folders and configuration files to engineers, and prose folders to editors. Pull requests touching both need both.
  3. Block dependency changes in content PRs. A rule that fails when a manifest or lockfile changes in a pull request labelled as content catches the quiet addition of a package.
  4. Limit imports. If your editors need five components, expose those five and lint for anything else. Fewer allowed imports means a shorter review.
  5. Build previews without secrets. The preview that renders the post should not receive deploy or API keys. See should preview deployments be public.
  6. Run static analysis on components. Code in custom components is ordinary JavaScript and benefits from the same scanning as the rest of your source.
  7. Review the diff for external hostnames. Any new URL in a script, iframe or image tag is a new supplier.

If you do not need MDX

If posts are mostly text and images, consider a Markdown pipeline that does not execute code and sanitizes raw HTML. You can still add a small set of shortcodes that are implemented and reviewed once.

Try it yourself

The code scan demo shows how a static analysis finding is traced to a line and explained. Try it on a sample finding and think about what a similar rule would flag in a custom MDX component.

Click through it at your own pace, or open it full screen.

Where Safeguard fits

Safeguard provides code and dependency scanning with policy gates on pull requests, which suits a repository where content and code share a review flow. Free scan: gold.safeguard.sh/scan.

Quick check

Can plain Markdown be dangerous too?

If the converter passes raw HTML through, a post can include script tags. Sanitize or disable raw HTML for untrusted authors.

Should writers need an engineer to merge every post?

Not for prose in a folder with no code. Use code owners so engineers review just the changes that touch components or config.

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.