Skip to content
XSS Write-up Beginner

Stored XSS in Bug Bounty

The website stored user-supplied meeting proposals and profile headlines without filtering, allowing an attacker to inject JavaScript that executes when other users view the dashboard or the attacker's profile.

katsuragicsl Follow

Published on medium.com

{{media:0}}

KatsuragiCSL, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target was a website that helps users prepare for interviews. The author describes it as fairly large, with many users and partnerships with banks and firms. The site runs a bug bounty program, and the researcher had started taking part in bug bounty programs not long before this work.

The relevant feature is the dashboard. Users can submit meeting proposals, and each proposal is displayed on the dashboard. The dashboard is also the homepage of the website when you are logged in. Users can also add a comment to their own meeting proposal. Separately, the profile editing function has a field called the headline, shown directly under the username on a user's profile.

Setup

The researcher first browsed the site as a guest, then signed up an account to test functionality that requires authentication. No specific tools, versions or special preconditions are described. The testing account used for the profile demonstration is referred to as the researcher's own testing account, and the example profile in the screenshots uses the username "pk" with the headline "test".

Finding it

The first phase was a search for reflected XSS entry points, such as the search function and improper error messages. That search produced nothing. The researcher then signed up and looked at authenticated functionality, and noticed that meeting proposals are displayed on the dashboard for other users to see. Because the proposal content is user input that gets displayed to other users, it looked like a good place to test for stored XSS.

Image for post
Image for post From the original on medium.com

Within a proposal, a user can add a comment. The comment is the input that gets rendered on the dashboard.

Exploitation

Step 1: script in a meeting proposal comment

The researcher added a simple script as a comment on their own meeting proposal to see whether it would execute.

It executed. The comment is inserted into the HTML without any filtering, so the payload alerts '1' every time the dashboard is visited. Since the dashboard is the homepage when logged in, this fires on every visit by a logged-in user.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

Step 2: script in the profile headline

Encouraged by the first result, the researcher looked for other places that display user input without filtering. In the profile editing function there is a headline field, shown as "test" right under the username "pk". Because the headline is shown to every user who visits the profile, it is another stored input rendered to visitors of that profile.

Image for post
Image for post From the original on medium.com

The headline was not filtered either and was inserted directly into the HTML, giving a second stored XSS that triggers when a logged-in user visits the profile of the affected user.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

The report does not include the exact payload strings, HTTP requests or responses for either step; the screenshots are the only record of them.

Root cause

The report states this directly for both fields. Because the values are stored and rendered to other users later, the result is stored XSS rather than reflected XSS. The report does not describe any output encoding, Content Security Policy or other defence that was present and bypassed; the implication is that no output handling was applied to these fields at all.

Impact

A payload placed in a meeting proposal comment runs in the browser of any user who visits the dashboard, which is the logged-in homepage. A payload placed in a profile headline runs in the browser of any logged-in user who visits that profile. In both cases the script runs in the context of the victim's session on the site, so it can act as that user within the application. The report does not enumerate specific actions taken with the access, and does not state a severity, CVSS score or bounty amount.

Fix

The report does not say what the site changed. The fix implied by the root cause is to apply context-appropriate output encoding to the comment and headline when rendering them into HTML, and to validate or sanitise the input on the server so that markup and script are not stored as active content.

Variants to test

  1. Any field whose value is shown to other users: proposal or comment bodies, profile fields such as headline, display name or bio. A positive result is the script executing when a different logged-in account views the page.
  2. Fields rendered on a shared landing page or dashboard, since these reach every logged-in visitor. A positive result is execution on page load without any interaction beyond visiting.
  3. Fields that are edited in one place and displayed in another (profile editing versus public profile), where filtering may exist on one path but not the other. A positive result is execution on the display path even if the edit form appears to sanitise.
  4. Reflected entry points such as search and error messages, which the researcher checked here without success. A positive result is the payload reflected unencoded into the response and executing in the browser.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

What happened, in plain words

A security researcher was taking part in bug bounty programmes. A bug bounty programme is an offer from a company: if you find a security problem in our website and report it responsibly, we may pay you. The researcher was still new to this.

While testing a website that helps people prepare for job interviews, the researcher found two places where a visitor could type text that the site would later show to other people, and where that text was not cleaned up before being put into the page. Because of that, a visitor could type a small piece of JavaScript (the programming language that web pages run in your browser) and have it run inside the browser of everyone who later looked at that page. This kind of problem is called stored XSS, or stored cross-site scripting. "Stored" means the harmful text is saved on the server and shown again later; "cross-site scripting" means someone else's script ends up running as if it were part of the site.

The researcher describes the site as fairly large, with many users and partnerships with banks and firms. The site runs a bug bounty programme, and the researcher had started taking part in such programmes not long before this work.

The two features involved are the dashboard and the profile headline. The dashboard is the page you see after logging in; on this site it is also the homepage when you are logged in. Users can submit meeting proposals, and each proposal is displayed on the dashboard. Users can also add a comment to their own meeting proposal. Separately, the profile editing function has a field called the headline, which is shown directly under the username on a user's profile.

How the researcher got started

The first phase was a search for reflected XSS entry points. Reflected XSS is the simpler cousin of stored XSS: you put something into a form, the site immediately sends it back in the page it shows you, and if the site does not clean it up, the script runs in your own browser. It is called "reflected" because the input bounces straight back. Typical places to look are a search box (you search for something and the page says "results for ...") and error messages that repeat what you typed.

That search produced nothing. The researcher then signed up for an account, because some features only exist once you are logged in, and looked at what those features do.

Image for post
Image for post From the original on medium.com

The researcher noticed that meeting proposals are displayed on the dashboard for other users to see. Because the proposal content is text typed by a user and then shown to other users, it looked like a good place to test for stored XSS: if the site does not clean that text, a script typed into a proposal will run in the browser of everyone who views the dashboard.

Within a proposal, a user can add a comment. That comment is the input that gets rendered on the dashboard. "Rendered" means turned into what you actually see on the page: the server sends HTML (the language web pages are written in), and the browser draws it.

Step 1: a script in a meeting proposal comment

The researcher added a simple script as a comment on a meeting proposal, to see whether it would execute. "Execute" means the browser runs it as code rather than showing it as text.

The report does not include the exact payload string, HTTP request or response for this step; the screenshot is the only record of it.

It executed. The comment is inserted into the HTML without any filtering, so the payload alerts '1' every time the dashboard is visited. An alert is the small pop-up box a browser shows when a page calls the alert function; it is the classic harmless proof that a script ran. Since the dashboard is the homepage when logged in, this fires on every visit by a logged-in user.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

Step 2: a script in the profile headline

Encouraged by the first result, the researcher looked for other places that display user input without filtering. In the profile editing function there is a headline field, shown as "test" right under the username "pk". Because the headline is shown to every user who visits the profile, it is another stored input rendered to other users: type it once, and it is shown to everyone who looks at your profile afterwards.

Image for post
Image for post From the original on medium.com

The headline was not filtered either and was inserted directly into the HTML, giving a second stored XSS that triggers when a logged-in user visits the profile of the affected user.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

The report does not include the exact payload strings, HTTP requests or responses for either step; the screenshots are the only record of them.

Why it works

In both cases the application takes text supplied by a user (a proposal comment and a profile headline) and inserts it into the HTML of a page without filtering or encoding it. "Encoding" here means converting characters that have a special meaning in HTML, such as < and >, into harmless equivalents so the browser shows them as text instead of treating them as markup. The report states this lack of filtering directly for both fields.

Because the values are stored and rendered to other users later, the result is stored XSS rather than reflected XSS. A simple comparison: reflected XSS is like someone shouting an insult back at you the moment you say it; stored XSS is like writing the insult on a noticeboard in the office, where everyone who walks past reads it later.

The report does not describe any output encoding, Content Security Policy or other defence that was present and bypassed. A Content Security Policy is a set of rules a site can send to the browser saying which scripts are allowed to run; none is mentioned here. The implication is that no output handling was applied to these fields at all.

What an attacker could do with it

A payload placed in a meeting proposal comment runs in the browser of any user who visits the dashboard, which is the logged-in homepage. A payload placed in a profile headline runs in the browser of any logged-in user who visits that profile.

In both cases the script runs in the context of the victim's session on the site. A session is the site's way of remembering that you are logged in: after you log in, the site gives your browser a cookie (a small piece of data stored by the browser) or token, and the browser sends it with every request so the site knows who you are. A script running inside a page from that site can act with the same permissions as the logged-in user, because the browser treats it as part of the site. The report does not enumerate specific actions taken with that access, and does not state a severity, CVSS score or bounty amount.

How to fix it

The report does not say what the site changed. The fix implied by the cause is to apply context-appropriate output encoding to the comment and headline when rendering them into HTML, and to validate or sanitise the input on the server so that markup and script are not stored as active content. In plain terms: when the site builds the page, it should turn any special characters in user text into harmless text, and it should check incoming text on the server rather than trusting the browser.

Other places worth testing

  1. Any field whose value is shown to other users: proposal or comment bodies, profile fields such as headline, display name or bio. A positive result is the script executing when a different logged-in account views the page.
  2. Fields rendered on a shared landing page or dashboard, since these reach every logged-in visitor. A positive result is execution on page load without any interaction beyond visiting.
  3. Fields that are edited in one place and displayed in another (profile editing versus public profile), where filtering may exist on one path but not the other. A positive result is execution on the display path even if the edit form appears to sanitise.
  4. Reflected entry points such as search and error messages, which the researcher checked here without success. A positive result is the payload reflected unencoded into the response and executing in the browser.

Glossary

  • Bug bounty programme: a scheme where a company rewards people for finding and reporting security problems in its systems.
  • XSS (cross-site scripting): a flaw where text supplied by one person is treated as code by another person's browser.
  • Stored XSS: XSS where the harmful text is saved on the server and shown to later visitors.
  • Reflected XSS: XSS where the harmful text bounces straight back in the same response, usually from a search box or error message.
  • Payload: the piece of text or code an attacker submits to trigger a flaw.
  • JavaScript: the programming language that web pages run in the browser.
  • HTML: the language web pages are written in; it describes the structure and content of a page.
  • Rendered: turned into what you see on the page by the browser.
  • Execute: run as code rather than display as text.
  • Alert: a browser pop-up box, often used as harmless proof that a script ran.
  • Filtering: removing or blocking dangerous characters or markup from user input.
  • Encoding: converting special characters into harmless equivalents so they display as text.
  • Sanitise: clean user input so it cannot contain active markup or script.
  • Validate: check that input matches what is expected before using it.
  • Dashboard: the main page a user sees after logging in; here also the homepage when logged in.
  • Headline: a short text field on a profile, shown under the username.
  • Session: the site's way of remembering that you are logged in across requests.
  • Cookie: a small piece of data a site stores in your browser, often used to carry a session.
  • Token: a value used to prove identity or permission, often sent with requests.
  • Content Security Policy: rules a site can send to the browser saying which scripts may run.
  • CVSS: a scoring system for rating the severity of a security flaw.
  • Severity: a rating of how serious a flaw is.

More by katsuragicsl

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.