Skip to content
XSS Write-up Intermediate

Persistent Cross-Site Scripting on redacted worth $2,000

A user could create a custom tag in a CRM's library feature containing a crafted payload that bypassed the XSS filter, leading to persistent cross-site scripting. This allowed the user's malicious tag to execute script in the browsers of all other users and admins in the organisation.

Muhammad Asim Shahzad Follow

Published on web.archive.org

Bounty$2,000 View original

{{media:0}}

protector47, on web.archive.org

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. 5 min read.

Context

The target was a CRM web application, part of a set of web services the researcher was invited to test through HackerOne. The feature involved is the Library functionality, which lets users create library entries and, alongside them, custom tags. Tags are the interesting part: they are user-defined labels that get rendered back in the interface.

The researcher's goal was a cross-site scripting issue that a low-privileged user could use against admins and other users of the same ORG. In a CRM where users and admins share data, a stored XSS in a shared object is exactly the kind of bug that escalates from one user to everyone in the organisation.

Setup

The report gives few operational details. The researcher received an invitation on HackerOne to test the web services, and worked against the CRM as a normal user with access to the Library functionality and its tag options. No tooling, versions or account setup beyond that are described. The precondition for the attack is simply an authenticated user who can create a library and add custom tags to it.

Finding it

The first attempt was in the Library functionality itself. The researcher created a library with an XSS payload in the fields:

HTML
"><script>alert(1)</script>#"><img src="x" onerror=prompt(1);>

This combines a quote-breakout with a script tag and an image with an onerror handler, so that whichever context the value lands in, one of the two vectors might fire. It did not work. Multiple payloads were tried in every field, and every time the response came back as plaintext: the input was being encoded or filtered on output.

Image for post
Why am I not expert in Javascript? From the original on web.archive.org

The screenshot marks the point where the researcher, by their own admission, was stuck on the JavaScript side of the problem.

While preparing to move on to another functionality, the researcher noticed the tags Options in Libraries, where users can create custom tags. A custom tag was created with an <img src xss> payload, and the response changed: the XSS still did not trigger, but the response contained a broken image. That broken image is the signal that matters. It means the tag value was being reflected into HTML without full encoding, and the browser was parsing it as an element, but the markup was being mangled somewhere between input and output, so the handler never ran.

Exploitation

Step 1: Analyse the reflected markup

The researcher inspected the output payload in the page source and built several payloads based on what the response looked like. None of them worked. The exact response markup is not reproduced in the report, so the precise transformation applied to the tag value is not documented here.

Step 2: Use a polyglot to survive the filter

Because the filter was still not bypassed, the researcher searched for payloads and polyglots and found one designed to break out of many different contexts at once:

HTML
/*–>]]>%>?></object></script></title></textarea></noscript</style></xmp>’-/”/-alert(1)//><img src=1 onerror=alert(1)>’

The payload works by closing a long list of possible enclosing constructs before injecting the actual vector. The leading /*–>]]>%>?> sequence targets comment, CDATA, processing-instruction and similar wrappers; the closing tags </object></script></title></textarea></noscript</style></xmp> attempt to terminate any element the value might be embedded in; the ’-/”/- fragment breaks out of quoted attribute values; alert(1) provides a direct script execution path; and the trailing <img src=1 onerror=alert(1)> provides a second path that fires if the value ends up in an HTML body context where the image fails to load.

Step 3: Create the tag with the polyglot

The researcher used this payload as the value of a library tag. The XSS triggered successfully.

Image for post
Celebration Time :) From the original on web.archive.org

The alert firing confirms that the tag value was stored and later rendered into a page in a context the polyglot could escape, with no effective output encoding at render time.

Root cause

The report does not include the server-side code, so the exact mistake is not shown. What the behaviour implies is that the tag value was stored as supplied and rendered into HTML without context-aware output encoding. The library fields, by contrast, returned plaintext, so those fields were being encoded or filtered. The tag rendering path either lacked that encoding or applied an encoding that the polyglot could defeat, likely because the value was placed into a context the filter did not account for. The broken image from the first <img src xss> attempt shows the value reached the HTML parser; the polyglot simply supplied the syntax needed to escape the surrounding markup.

Impact

The attack is initiated by a single user and affects all admins and all users of the ORG. Because tags are shared within the organisation, any member who views the affected library entry, including administrators, runs the payload in their session. The report does not describe what actions were demonstrated beyond the alert, so the practical escalation (session theft, admin actions performed on the attacker's behalf) is implied by the context rather than shown.

Fix

The report states only that the vulnerability was fixed very quickly. No details of the change are given. The appropriate fix is context-aware output encoding of tag values at render time, plus server-side validation of tag content, so that stored values cannot introduce markup into the page.

Variants to test

  1. Secondary fields on shared objects. Create a library entry and put a polyglot in the tag field rather than the main fields. A positive result is a broken image or an alert in the rendered entry.
  2. Every context the value can reach. Submit the same polyglot and check the entry list, the detail view, search results and any export or preview page. A positive result is execution in any one of them, since each may use different encoding.
  3. Filter differentials. Compare how the main library fields and the tag fields render the same input. A field that returns plaintext is encoded; a field that returns parsed markup is a candidate.
  4. Polyglot against unknown wrappers. Where the surrounding markup is unclear, submit the polyglot above and inspect the source for which closing sequence was consumed. A positive result is execution without needing to know the wrapper in advance.

Reward

The researcher received $1500 plus a $500 bonus, and the report was selected as one of the best reports of August with a further $500 bonus.

Image for post
Image for post From the original on web.archive.org

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. 12 min read.

What happened, in plain words

A security researcher was invited to test a company's web services through a bug bounty platform called HackerOne. A bug bounty programme is a deal where a company says: if you find a security problem in our systems and tell us privately, we will pay you a reward (the bounty) instead of punishing you. The researcher found a bug in a CRM, which stands for Customer Relationship Management: software a company uses to keep track of its customers, contacts, deals and internal notes. Think of it as a shared digital filing cabinet that everyone in a company logs into.

The bug was a stored cross-site scripting (stored XSS) issue. To understand that, you first need to know what a web page actually is. When you visit a site, your browser receives a document written in HTML, a language made of tags such as <img> for an image or <script> for a piece of code. The browser reads those tags and draws the page. If an attacker can get their own HTML into a page that other people view, the browser cannot tell the difference between the site's own markup and the attacker's markup. It just runs it. That is XSS: tricking a site into delivering the attacker's code to someone else's browser.

"Stored" means the malicious text is saved on the server first, for example in a database, and then shown to everyone who opens the page later. Compare it to writing graffiti on a noticeboard in an office: you write it once, and every person who walks past reads it. In this CRM, the noticeboard was a custom tag attached to a library entry.

The important part is who reads the noticeboard. In a CRM, ordinary users and administrators share the same data. So a single low-privileged user could plant code that ran in the browser of every admin and every other user in the same organisation. The researcher was paid $2000 in total for this report.

The target and the goal

The target was a CRM web application, one of a set of web services the researcher was invited to test through HackerOne. The feature involved is the Library functionality, which lets users create library entries and, alongside them, custom tags. A tag is a short label you attach to something so it can be found or grouped later, like a sticky note on a folder. In this product, tags are user-defined.

That last point is what makes tags interesting. Anything a site shows back to other people is a place where stored XSS can live, because the site has to take your text and put it into a page. If it puts your text in without neutralising the HTML inside it, your text becomes part of the page's structure.

The researcher's goal was exactly that: a cross-site scripting issue that a low-privileged user could use against admins and other users of the same organisation. In a CRM where users and admins share data, a stored XSS in a shared object escalates from one user to everyone in the organisation.

Setup

The report gives few operational details. The researcher received an invitation on HackerOne to test the web services, and worked against the CRM as a normal user with access to the Library functionality and its tag options. No tooling, versions or account setup beyond that are described. The precondition for the attack is simply an authenticated user who can create a library and add custom tags to it. "Authenticated" just means logged in with a valid account.

Finding it

The first attempt was in the Library functionality itself. The researcher created a library with an XSS payload in the fields:

HTML
"><script>alert(1)</script>#"><img src="x" onerror=prompt(1);>

Line by line, in plain words:

  • "> is a double quote followed by a greater-than sign. Pages often place your input inside an attribute, something like <input value="YOUR TEXT">. The quote is meant to mark where your text ends. Sending a quote of your own tries to end the attribute early, and the > tries to close the tag, so that whatever follows is treated as new markup rather than as text.
  • <script>alert(1)</script> is a script tag containing a tiny piece of JavaScript. alert(1) makes the browser pop up a box showing the number 1. It does nothing harmful; researchers use it because a popup is unmistakable proof that code ran. The closing </script> ends the script.
  • # is just a hash character, often used as a harmless filler or to end a URL fragment.
  • "><img src="x" onerror=prompt(1);> is a second attempt in the same string. <img> asks the browser to load an image. src="x" points at an image called x, which does not exist. onerror=prompt(1); is an event handler: a piece of code the browser runs when something goes wrong, here when the image fails to load. prompt(1) shows a popup asking for input. So even if script tags are blocked, a broken image with an error handler can still run code.

The idea of combining several tricks in one string is that you do not always know where your input will land. If one vector is blocked, another might survive. It did not work. Multiple payloads were tried in every field, and every time the response came back as plaintext: the input was being encoded or filtered on output. "Encoded" means special characters are converted into harmless stand-ins, so a < becomes something the browser displays as text rather than treats as the start of a tag. "Filtered" means the site removes or rejects the dangerous parts.

Image for post
Why am I not expert in Javascript? From the original on web.archive.org

The screenshot marks the point where the researcher, by their own admission, was stuck on the JavaScript side of the problem.

While preparing to move on to another functionality, the researcher noticed the tags Options in Libraries, where users can create custom tags. A custom tag was created with an <img src xss> payload, and the response changed: the XSS still did not trigger, but the response contained a broken image.

That broken image is the signal that matters. It means the tag value was being placed into the page as HTML without full encoding, and the browser was parsing it as an element. If the site had encoded it properly, you would have seen the literal text <img src xss> on the page. Instead the browser tried to load an image and failed, which is why you see the broken-image icon. But the markup was being mangled somewhere between input and output, so the handler never ran.

Exploitation

Step 1: Analyse the reflected markup

The researcher inspected the output payload in the page source and built several payloads based on what the response looked like. "Page source" is what you see when you ask the browser to show the raw HTML it received, rather than the drawn page. Reading it tells you exactly how your input was placed into the page. None of the new payloads worked. The exact response markup is not reproduced in the report, so the precise transformation applied to the tag value is not documented here.

Step 2: Use a polyglot to survive the filter

Because the filter was still not bypassed, the researcher searched for payloads and polyglots. A polyglot is a single string built to work in many different situations at once, the way a phrasebook sentence might be understood in several countries. You do not need to know exactly where your input lands, because the string contains an escape for many possible containers. The researcher found one:

HTML
/*–>]]>%>?></object></script></title></textarea></noscript</style></xmp>’-/”/-alert(1)//><img src=1 onerror=alert(1)>’

What each part is trying to do:

  • /* opens a comment in many languages, and –> tries to close an HTML comment. ]]> closes a CDATA section, a wrapper used to mark text as literal data. %> closes a server-side template tag. ?> closes a processing instruction. These are all different kinds of wrapping that a value might be sitting inside, and the payload tries to break out of each in turn.
  • </object></script></title></textarea></noscript</style></xmp> is a run of closing tags. Each one tries to end an element the value might be embedded in: an object, a script, a page title, a text area, a noscript block, a style block, an xmp block. Whichever one matches, the value is now outside that element.
  • ’-/”/- mixes single quotes, a slash, a hyphen and double quotes. Attribute values in HTML can be wrapped in single or double quotes, so this fragment tries to close whichever kind is in use and break out of the attribute.
  • alert(1) is the direct execution path: if the value is now in a position where JavaScript runs, this popup fires.
  • //> comments out the rest of a line in JavaScript, so leftover characters do not cause a syntax error.
  • <img src=1 onerror=alert(1)> is the second execution path. If the value ends up in the body of the page as HTML, the browser tries to load an image called 1, fails, and runs alert(1) from the error handler.
  • The final ’ is a trailing quote, again trying to balance whatever quoting surrounds the value.

Step 3: Create the tag with the polyglot

The researcher used this payload as the value of a library tag. The XSS triggered successfully.

Image for post
Celebration Time :) From the original on web.archive.org

The alert firing confirms that the tag value was stored and later rendered into a page in a context the polyglot could escape, with no effective output encoding at render time. "At render time" means at the moment the server builds the page to send to a visitor. Encoding has to happen there, because that is the last point where the site still controls what the browser receives.

Root cause

The report does not include the server-side code, so the exact mistake is not shown. What the behaviour implies is that the tag value was stored as supplied and rendered into HTML without context-aware output encoding. "Context-aware" means the encoding matches the place the value lands: text between tags, inside an attribute, inside a script block and inside a URL all need different treatment. A single generic filter often misses one of these places.

The library fields, by contrast, returned plaintext, so those fields were being encoded or filtered. The tag rendering path either lacked that encoding or applied an encoding that the polyglot could defeat, likely because the value was placed into a context the filter did not account for. The broken image from the first <img src xss> attempt shows the value reached the HTML parser; the polyglot simply supplied the syntax needed to escape the surrounding markup.

Impact

The attack is initiated by a single user and affects all admins and all users of the organisation. A "session" is the logged-in state your browser keeps after you sign in, usually held in a cookie, which is a small piece of data the site stores in your browser and sends back with each request so it knows who you are. Code running in your session acts with your permissions. The report does not describe what actions were demonstrated beyond the alert, so the practical escalation, such as session theft or admin actions performed on the attacker's behalf, is implied by the context rather than shown.

Fix

The report states only that the vulnerability was fixed very quickly. No details of the change are given. The appropriate fix is context-aware output encoding of tag values at render time, plus server-side validation of tag content, so that stored values cannot introduce markup into the page. "Server-side validation" means the server checks the input itself, rather than trusting the browser to do it, because an attacker can always send requests without using the normal interface.

Variants to test

  1. Secondary fields on shared objects. Create a library entry and put a polyglot in the tag field rather than the main fields. A positive result is a broken image or an alert in the rendered entry.
  2. Every context the value can reach. Submit the same polyglot and check the entry list, the detail view, search results and any export or preview page. A positive result is execution in any one of them, since each may use different encoding.
  3. Filter differentials. Compare how the main library fields and the tag fields render the same input. A field that returns plaintext is encoded; a field that returns parsed markup is a candidate.
  4. Polyglot against unknown wrappers. Where the surrounding markup is unclear, submit the polyglot above and inspect the source for which closing sequence was consumed. A positive result is execution without needing to know the wrapper in advance.

Reward

The researcher received $1500 plus a $500 bonus, and the report was selected as one of the best reports of August with a further $500 bonus.

Image for post
Image for post From the original on web.archive.org

Glossary

  • Bug bounty programme: an arrangement where a company pays researchers who privately report security problems in its systems.
  • HackerOne: the platform through which the researcher was invited to test the company's web services.
  • CRM (Customer Relationship Management): software a company uses to manage customers, contacts and internal records, shared between users and administrators.
  • Library functionality: the CRM feature where users create library entries and attach custom tags.
  • Tag: a short user-defined label attached to an entry so it can be grouped or found later.
  • HTML: the markup language browsers use to build a page, made of tags such as <img> and <script>.
  • JavaScript: the programming language browsers run inside pages; alert(1) and prompt(1) are tiny examples that show a popup.
  • Cross-site scripting (XSS): getting an attacker's HTML or JavaScript into a page that other people view, so it runs in their browsers.
  • Stored XSS: XSS where the malicious text is saved on the server and shown to everyone who opens the page later.
  • Payload: the specific piece of text or code an attacker submits to try to trigger a bug.
  • Polyglot: a single payload built to break out of many different contexts at once, so it works without knowing exactly where the input lands.
  • Encoding (output encoding): converting special characters into harmless stand-ins so the browser displays them as text instead of treating them as markup.
  • Filtering: removing or rejecting dangerous input, either in the browser or on the server.
  • Context-aware encoding: encoding that matches where the value is placed (text, attribute, script, URL), since each place needs different treatment.
  • Attribute: a setting inside an HTML tag, such as src on an image or value on an input, usually written inside quotes.
  • Event handler: code attached to an element that runs when something happens, such as onerror when an image fails to load.
  • Page source: the raw HTML a browser received, viewable in the browser, used to see how input was placed into the page.
  • Render time: the moment the server builds the page to send to a visitor.
  • Server-side validation: input checks performed on the server rather than trusting the browser.
  • Authenticated: logged in with a valid account.
  • Session: the logged-in state a browser keeps after signing in, usually held in a cookie.
  • Cookie: a small piece of data a site stores in the browser and receives back with each request so it knows who you are.
  • Organisation (ORG): the group of users and admins sharing the same CRM data.
  • Administrator (admin): a user with elevated permissions over the shared data.
  • Root cause: the underlying mistake in the code that makes the bug possible.
  • Impact: what an attacker could actually do by exploiting the bug.
  • Bounty: the money paid for a valid report.

More by Muhammad Asim Shahzad

View all

6 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.