Stored Iframe Injection & Permanent Open Redirection - Zero Day
A stored iframe injection in the Discourse mermaid theme component allowed an attacker to embed a malicious iframe in a post or comment. When another user viewed the post, the iframe's script redirected the top-level page to an attacker-controlled site, causing a permanent open redirection.
Published on shahjerry33.medium.com
An iFrame is a way to embed a webpage within another webpage. It’s like a small window that shows content from a different website.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Discourse is a forum platform where users create topics and reply to them. Topic bodies and replies are written in Markdown, and the rendered output is shown to every other user who opens the topic. One of the ways Discourse renders content is through the discourse-mermaid-theme-component, which lets authors draw diagrams with the Mermaid syntax inside a fenced code block.
The report describes a stored iframe injection in that component: a payload placed in a topic or a comment is stored and rendered for other users, and because the injected frame loads attacker-controlled HTML, the page can be redirected away from Discourse. The researcher chained the injection with an open redirection to raise the impact, and the issue was assigned CVE-2022-46180.

Setup
The researcher used two accounts on the same Discourse instance:
- Account A to create a post.
- Account B to visit that post and leave a comment.
No special role is described beyond the ability to create a post and a reply. The attacker also needs a domain they control to host the redirection page; in this case it was ispsolutions.inn, and the redirect target was https://00eth0.xss.ht.
Finding it
The starting point was the Mermaid rendering path. A fenced mermaid block is processed by the component and its output is inserted into the page. The researcher found that HTML placed inside the Mermaid block was not neutralised, so an <iframe> element survived into the rendered post. Because the rendered post is stored and served to every reader, the frame is stored as well: it appears in the topic body and in the comment section.
On its own the injection only affects Integrity in the CIA triad. The researcher then chained it with an open redirection, which brought Availability into play as well and moved the severity to medium.
Exploitation
Step 1: create the post and open it from a second account
Account A creates a post. Account B visits it and prepares a comment, which is where the payload will be stored.

Step 2: inject the iframe through a Mermaid block
The payload is a Markdown fenced block using the Mermaid feature, with an iframe appended to the diagram source:
```mermaid height=180,auto
classDiagram
Class08 ←> C2: Cool label<iframe/src=’https://ispsolutions.inn/'>
How the pieces work:
- The
<html>and<body>tags give the page its structure. - The
<script>tag holds JavaScript;languagesays the language is JavaScript andtypesays the script istext/javascript. - The
tryblock runs the redirection:rurlis set tohttps://00eth0.xss.ht?&.window.top.location.replace(rurl)replaces the location of the top-level page with that URL, so the whole tab navigates away from Discourse.
- If the
tryblock throws, thecatchblock writes a message, "This page has moved, Click here to go there.", with a link tohttp://ww6.gsrtc.com?&&jserror=1, which is the fallback destination.
In short, the script tries to send the user to https://00eth0.xss.ht, and if that fails it sends them to http://ww6.gsrtc.com?&&jserror=1 instead.
Root cause
The redirection works because of window.top.location.replace(). That function is meant to navigate the browser to a new page by replacing the current URL in the address bar. When the attacker's page is loaded inside an iframe on Discourse, the function still acts on window.top, which is the Discourse page itself, not the frame. The top-level document is therefore replaced with the attacker's URL, and the user leaves Discourse.
Two conditions make this possible. First, the Mermaid rendering path does not strip or encode the HTML in the fenced block, so the <iframe> is stored and rendered for other users. The redirection works because of window.top.location.replace(): when the attacker's page is loaded in an iframe, the function acts on the top-level Discourse page. The report does not describe the component's parsing code, so the exact place where the tag escapes filtering is not shown.

Impact
Any user who injects this payload into a reply, or into a newly created post, causes every other user who opens that post to be redirected to the attacker's site before they can read it. The same payload can be used to send users to other malicious websites. The researcher rates the issue as medium, with the vector:
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
That is a score of 5.4, reflecting low integrity and low availability impact, no confidentiality impact, and the requirement for a low-privileged authenticated account.
Fix
The report recommends four measures:
- Filter user input when it is received.
- Encode data when it is sent back from the server.
- Implement CSP with proper response headers such as
X-Frame-Options. - Restrict harmful tags from being loaded.
The researcher obtained CVE-2022-46180 for identifying this vulnerability.
Variants to test
- Other Markdown renderers with HTML passthrough. Try fenced blocks for diagram or chart features (Mermaid, and similar renderers) with an
<iframe>appended to the diagram source. A positive result is the frame appearing in the rendered post for a second account. - Direct HTML in posts and comments. Where raw HTML is allowed, submit an iframe pointing at a page you control. A positive result is the frame loading for another user who opens the post.
- Top-window navigation from a frame. Host a page that calls
window.top.location.replace()and load it in any frame the application renders. A positive result is the whole tab navigating to your URL. - Frame-busting headers. Check whether responses carry
X-Frame-Optionsor a CSPframe-ancestorsdirective. A positive result is a missing or permissive header that lets the application be framed. - Stored versus reflected placement. Submit the payload in a reply rather than the topic body, and view it from a different account. A positive result is the payload persisting and firing for every reader.
Special thanks from the researcher go to Jinay Patel for help in exploiting the vulnerability.

What happened, in plain words
Discourse is a forum platform. People create topics (posts) and reply to them, and everyone who opens a topic sees the same content. Topic bodies and replies are written in Markdown, a simple way of formatting text with symbols, and the platform turns that text into a web page.
One of the ways Discourse turns text into a page is a component called discourse-mermaid-theme-component. Mermaid is a tool that draws diagrams from text: you write a few lines describing boxes and arrows, and it draws a picture. On Discourse, an author can put a Mermaid diagram inside a fenced code block, which is a chunk of text marked off by three backticks (```). The component reads that block and inserts the drawn diagram into the page.
The researcher found that this component did not clean up HTML placed inside the Mermaid block. HTML is the language web pages are written in, and an <iframe> is an HTML element that embeds one web page inside another, like a small window showing another site. Because the bad HTML survived, an iframe ended up in the rendered post. And because a post is stored on the server and shown to every reader, the iframe was stored too: it appeared in the topic body and in the comment section.
On its own, that only affects Integrity in the CIA triad. The CIA triad is a simple way of describing what a security problem can damage: Confidentiality (keeping secrets secret), Integrity (keeping data correct and unaltered) and Availability (keeping the service usable). An iframe that shows attacker content changes what the page displays, which is an integrity problem.
The researcher then chained the injection with an open redirection. An open redirection is when a site can be made to send a visitor to another site chosen by an attacker. That brought Availability into play as well, because a reader who is sent away cannot use the forum, and the severity moved to medium. The issue was assigned CVE-2022-46180. A CVE is a public identifier given to a known security flaw so people can track it.

Setting up the test
The researcher used two accounts on the same Discourse instance:
- Account A to create a post.
- Account B to visit that post and leave a comment.
Two accounts are used because the point is to show that one person's content affects another person. Account A is the attacker, account B is the victim. No special role is described beyond the ability to create a post and a reply, so an ordinary logged-in user is enough.
The attacker also needs a domain they control to host the redirection page. A domain is a website address you own, like example.com. In this case it was ispsolutions.inn, and the redirect target was https://00eth0.xss.ht.
Finding it
The starting point was the Mermaid rendering path. A fenced mermaid block is processed by the component and its output is inserted into the page. The researcher found that HTML placed inside the Mermaid block was not neutralised, so an <iframe> element survived into the rendered post. Because the rendered post is stored and served to every reader, the frame is stored as well: it appears in the topic body and in the comment section.
On its own the injection only affects Integrity in the CIA triad. The researcher then chained it with an open redirection, which brought Availability into play as well and moved the severity to medium.
Exploitation
Step 1: create the post and open it from a second account
Account A creates a post. Account B visits it and prepares a comment, which is where the payload will be stored. A payload is simply the piece of content that carries the attack.

Step 2: inject the iframe through a Mermaid block
The payload is a Markdown fenced block using the Mermaid feature, with an iframe appended to the diagram source:
```mermaid height=180,auto
classDiagram
Class08 ←> C2: Cool label<iframe/src=’https://ispsolutions.inn/'>
How the pieces work:
- The
<html>and<body>tags give the page its structure. Every web page has an outer<html>wrapper and a<body>where the visible content lives. - The
<script>tag holds JavaScript, the programming language browsers run.languagesays the language is JavaScript andtypesays the script istext/javascript. - The
tryblock runs the redirection:rurlis set tohttps://00eth0.xss.ht?&. This is just a variable, a named box holding a value, so the address is written once and used below.window.top.location.replace(rurl)replaces the location of the top-level page with that URL, so the whole tab navigates away from Discourse.window.topmeans the outermost page in the browser tab, not the small frame.location.replacechanges the address bar and loads the new page.
- If the
tryblock throws, thecatchblock writes a message, "This page has moved, Click here to go there.", with a link tohttp://ww6.gsrtc.com?&&jserror=1, which is the fallback destination. Acatchblock is the safety net: it runs only if something intryfails, for example if the browser blocks the redirect.
In short, the script tries to send the user to https://00eth0.xss.ht, and if that fails it sends them to http://ww6.gsrtc.com?&&jserror=1 instead.
Root cause
The redirection works because of window.top.location.replace(). That function is meant to navigate the browser to a new page by replacing the current URL in the address bar. When the attacker's page is loaded inside an iframe on Discourse, the function still acts on window.top, which is the Discourse page itself, not the frame. The top-level document is therefore replaced with the attacker's URL, and the user leaves Discourse.
Two conditions make this possible. First, the Mermaid rendering path does not strip or encode the HTML in the fenced block, so the <iframe> is stored and rendered for other users. The redirection works because of window.top.location.replace(): when the attacker's page is loaded in an iframe, the function acts on the top-level Discourse page. The report does not describe the component's parsing code, so the exact place where the tag escapes filtering is not shown.

Impact
Any user who injects this payload into a reply, or into a newly created post, causes every other user who opens that post to be redirected to the attacker's site before they can read it. The same payload can be used to send users to other malicious websites. The researcher rates the issue as medium, with the vector:
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
That is a score of 5.4, reflecting low integrity and low availability impact, no confidentiality impact, and the requirement for a low-privileged authenticated account. CVSS is a standard scoring system for security flaws; the vector string is a compact way of writing down the conditions, and the score is the number derived from it.
Fix
The report recommends four measures:
- Filter user input when it is received. Filtering means checking incoming content and removing anything dangerous before it is stored.
- Encode data when it is sent back from the server. Encoding means turning characters like
<into harmless text so the browser shows them instead of treating them as HTML. - Implement CSP with proper response headers such as
X-Frame-Options. CSP (Content Security Policy) is a set of rules a site sends to the browser saying what it is allowed to load and do;X-Frame-Optionsis a header that tells the browser whether the page may be shown inside a frame at all. - Restrict harmful tags from being loaded. In practice this means not letting elements like
<iframe>through the renderer.
The researcher obtained CVE-2022-46180 for identifying this vulnerability.
Variants to test
- Other Markdown renderers with HTML passthrough. Try fenced blocks for diagram or chart features (Mermaid, and similar renderers) with an
<iframe>appended to the diagram source. A positive result is the frame appearing in the rendered post for a second account. - Direct HTML in posts and comments. Where raw HTML is allowed, submit an iframe pointing at a page you control. A positive result is the frame loading for another user who opens the post.
- Top-window navigation from a frame. Host a page that calls
window.top.location.replace()and load it in any frame the application renders. A positive result is the whole tab navigating to your URL. - Frame-busting headers. Check whether responses carry
X-Frame-Optionsor a CSPframe-ancestorsdirective. A positive result is a missing or permissive header that lets the application be framed. - Stored versus reflected placement. Submit the payload in a reply rather than the topic body, and view it from a different account. A positive result is the payload persisting and firing for every reader.
Special thanks from the researcher go to Jinay Patel for help in exploiting the vulnerability.

Glossary
- Availability: one part of the CIA triad; whether a service stays usable for the people who need it.
- Catch block: the part of JavaScript that runs only if the code in the
tryblock fails. - CIA triad: a simple model of what a security problem can damage: Confidentiality, Integrity and Availability.
- Component: an add-on piece of software that gives a platform extra features, here the Mermaid diagram renderer for Discourse.
- Confidentiality: one part of the CIA triad; whether secrets stay secret.
- CSP (Content Security Policy): rules a site sends to the browser saying what content and scripts it may load.
- CSS: not used here; styling language for web pages.
- CVE: a public identifier for a known security flaw, so people can track it.
- CVSS: a standard scoring system for security flaws, with a vector string and a numeric score.
- Discourse: a forum platform where users create topics and reply to them.
- Domain: a website address you own, such as example.com.
- Encoding: turning special characters into harmless text so a browser displays them instead of treating them as code.
- Fenced code block: a chunk of text in Markdown marked off by three backticks, often with a language name after the opening fence.
- Filtering: checking incoming content and removing anything dangerous before storing it.
- HTML: the language web pages are written in.
- Header: extra information a server sends with a response, such as rules about framing.
- Iframe: an HTML element that embeds one web page inside another, like a small window showing another site.
- Integrity: one part of the CIA triad; whether data stays correct and unaltered.
- JavaScript: the programming language browsers run to make pages interactive.
- Markdown: a simple way of formatting text with symbols, which the platform turns into a web page.
- Mermaid: a tool that draws diagrams from text.
- Open redirection: when a site can be made to send a visitor to another site chosen by an attacker.
- Payload: the piece of content that carries the attack.
- Stored: saved on the server and shown to every reader, as opposed to reflected, which only appears in one response.
- Try block: the part of JavaScript that attempts to run code, with a catch block as a safety net.
- Vector: the route an attack takes into an application.
window.top: the outermost page in a browser tab, as opposed to a frame inside it.window.top.location.replace(): a JavaScript function that changes the address bar of the top-level page and loads a new page.X-Frame-Options: a response header that tells the browser whether the page may be shown inside a frame.