Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Markdown HTML Injection
Cyber Security

Markdown HTML Injection

← Back to Glossary
By NHI Mgmt Group Updated October 29, 2026 Domain: Cyber Security

Markdown HTML injection is the insertion of HTML through Markdown content when a renderer permits raw HTML or fails to sanitise it. It affects editors, documentation sites and chat tools, where malicious tags can alter page content, execute scripts, or create misleading links and forms.

How Markdown HTML injection works

Markdown html injection happens when a renderer allows raw HTML to pass through Markdown content without adequate sanitisation. The risk is not the Markdown syntax itself, but the trust placed in user-supplied text that the parser turns into active page markup.

In practice, the attack surface is broad because Markdown is often used in comment systems, wiki pages, issue trackers, documentation portals and chat tools. If the renderer preserves HTML tags, an attacker can reshape the document in ways that go far beyond ordinary formatting.

Why it is dangerous

The core danger is that content which appears to be plain text can become executable or deceptive page structure. That can include script execution, hidden or misleading links, form fields, iframe content, or layout manipulation that makes malicious content look trusted.

Even when scripts are blocked, injected HTML can still create phishing-style effects inside an otherwise legitimate application. Readers may click links, submit credentials, or follow instructions that were never intended by the content owner.

Where the exposure comes from

Exposure usually starts with user-generated Markdown that is rendered inside a browser or rich client. The issue becomes material when the application supports raw HTML, partially sanitises input, or applies sanitisation inconsistently across preview, saved content and rendered output.

Documentation systems, knowledge bases and collaboration tools are especially sensitive because content is repeatedly edited, quoted and embedded. A single unsafe renderer can turn a low-trust text field into a cross-user injection path that affects many readers.

Control and remediation focus

Defence depends on treating Markdown as untrusted input and enforcing a safe rendering policy. Where raw HTML is unnecessary, the strongest option is to disable it entirely; where it must be supported, sanitise allowed tags and attributes with a strict allowlist and keep the policy identical across all render paths.

It also helps to pair sanitisation with output encoding, CSP hardening and review of template behaviour, because unsafe composition often appears at the boundary between the Markdown engine and the surrounding page. For baseline application security guidance, OWASP Top 10 is a useful companion reference for understanding injection-style failures and their broader web application impact.

Risk and Threat Considerations

Markdown HTML injection can become a stored attack path when malicious markup is persisted and later rendered for many users. The same weakness can also support credential theft, interface spoofing, session abuse or defacement if the injected HTML changes page behaviour or misleads the reader.

Failure mechanism: The renderer trusts raw HTML embedded in Markdown or sanitises it incompletely, so attacker-controlled markup survives into the browser context.

Impact: The attacker can alter content, plant deceptive links or forms, and in some implementations trigger script execution or other browser-side abuse.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS provides the primary governance reference for this term.

FrameworkControl / ReferenceRelevance
OWASP ASVSV1 — Encoding and SanitizationMarkdown HTML injection is a sanitization failure in rendered content.
V13 — ConfigurationSafe Markdown handling depends on renderer and preview configuration.
V16 — Security Logging and Error HandlingInjection attempts and render failures should be observable during review.
Recommendation — Sanitise rendered Markdown with an allowlist and escape any untrusted HTML. Disable raw HTML in Markdown unless a strict policy is required and enforced. Log sanitisation failures and suspicious render inputs so abuse can be investigated.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 29, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org