[theacademy.upserve.com] Reflected XSS Query-String
A reflected cross-site scripting flaw existed on the roles page, where a crafted query string was echoed unescaped into the page's HTML. An attacker could send a victim a link that runs script in the site's context.
- Triaged in 27 hours
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 3 months
Summary by the program
The reporter discovered an unauthenticated reflected cross-site scripting vulnerability in theacademy.upserve.com by setting the XSS payload as a GET parameter.
The report
Steps To Reproduce: Open URL in FireFox:
https://theacademy.upserve.com/roles/?%22%3E%3Cscript//src=data:,alert(location)//
HTTP Request
GET /roles/?%22%3E%3Cscript//src=data:,alert(location)// HTTP/1.1
Host: theacademy.upserve.com
HTTP Response
<a class="category dropdown-item name-sort sorting-desc" href="/roles/?"><script//src=data:,alert(location)//&orderby=name&order=DESC">Name</a>
<a class="category dropdown-item views-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=views&order=DESC" >Views</a>
<a class="category dropdown-item duration-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=duration&order=DESC">Duration</a>
Impact
Reflected XSS
What the report shows
The target is theacademy.upserve.com, a site with a /roles/ page that lists roles and offers sorting links (by name, views and duration). The researcher found an unauthenticated reflected cross-site scripting issue that is triggered through the query string: the payload is placed directly in the URL as a GET parameter, and the application reflects it back into the HTML of the page.
The reproduction is a single URL, opened in Firefox:
https://theacademy.upserve.com/roles/?%22%3E%3Cscript//src=data:,alert(location)//
Decoded, the query string closes the attribute it is reflected into, closes the surrounding tag, and opens a script element whose source is a data: URI containing alert(location). The // sequences act as comment markers so the rest of the reflected context does not break the payload.
The corresponding request is minimal, with no cookies or authentication headers:
GET /roles/?%22%3E%3Cscript//src=data:,alert(location)// HTTP/1.1
Host: theacademy.upserve.com
The response shows where the value lands. The payload is reflected inside the href attribute of the sorting links, and because the injected " and > are not encoded, the browser parses the remainder as markup rather than as part of the attribute:
<a class="category dropdown-item name-sort sorting-desc" href="/roles/?"><script//src=data:,alert(location)//&orderby=name&order=DESC">Name</a>
<a class="category dropdown-item views-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=views&order=DESC" >Views</a>
<a class="category dropdown-item duration-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=duration&order=DESC">Duration</a>
The impact stated in the report is reflected XSS. The report was rated low severity and a bounty of 250.00 USD was paid; it was disclosed on 2018-10-19. The report does not describe a fix.
Root cause
The page builds its sorting links by taking the current query string and writing it back into the href attribute of each link without HTML-encoding it. The response shows the query string written back into the href attribute of each link without HTML-encoding. so the double quote in the payload terminates the attribute and the following > closes the anchor element. Everything after that is treated as new markup, which is why the injected script element executes. The same value is reflected in three separate links.
Impact
Because the request needs no authentication, any crafted link to the /roles/ page can carry the payload. An attacker who convinces a victim to open such a link runs script in the origin of theacademy.upserve.com, in the victim's browser session. What that script can reach depends on what the site stores in the victim's session and on the site's cookies; the report itself only demonstrates alert(location) and states reflected XSS as the impact, so no account takeover or data theft is shown here. The report was rated low severity.
How this kind of bug works
Reflected XSS happens when input from the request is written into the response without context-appropriate encoding, and the browser then interprets part of that input as code or markup. The critical detail is context: a value placed between tags, inside an attribute, inside a URL or inside a script block each needs different handling. Here the value lands inside a double-quoted attribute, so the dangerous characters are the quote that ends the attribute and the angle brackets that start a new element. HTML-encoding those characters turns them into inert text.
The bug class persists because templating and string concatenation make it easy to forget encoding. Defences that stop it are output encoding matched to the context, a restrictive Content Security Policy that blocks inline and data: script sources, and treating the query string as untrusted data everywhere it is echoed.
How to test for it
- Map every place where request data appears in the response: search parameters, path segments, headers that get echoed (such as the referrer or user agent), and error messages.
- For each reflection, note the context: between tags, inside an attribute (single or double quoted, or unquoted), inside a URL attribute, or inside a script or style block.
- Send a benign marker first to confirm the value is reflected verbatim and to see whether it is encoded. A marker containing a quote and angle brackets shows immediately whether encoding happens.
- If the marker survives unencoded, build a payload for that context. In an attribute, break out with a quote and a closing angle bracket, then introduce an element that executes, such as a
scripttag or an event handler attribute. - Confirm execution in a real browser rather than relying on the response body alone, and check whether the payload fires without any cookies, as in this report.
A positive result is a response where the injected markup is not encoded and the browser executes it. Common false positives are reflections that are encoded but look alarming in the raw response, payloads that only appear inside a JavaScript string where quotes are escaped, values reflected into a context the browser does not execute (such as a comment), and cases where a Content Security Policy blocks the payload even though the reflection is unencoded. Also check whether the reflection is server-side or produced by client-side rendering, since the latter changes where the fix belongs.
How it is fixed
The standard fix is context-aware output encoding of every value taken from the request before it is written into the page, so quotes, angle brackets and ampersands become entities inside attributes. Where the value is used to build a URL, it should be URL-encoded as well. A Content Security Policy that disallows inline script and restricts script sources adds defence in depth. Frameworks with auto-escaping templates remove most of this class of bug when used consistently, and the shared code that generates the sort links should be corrected once so all three links are covered.
Hunting notes
Reflected XSS tends to hide in features that echo state back into links and navigation: sorting and filtering controls, pagination, search result pages, language and theme switchers, and redirect or return-to parameters. Pages that rebuild their own URLs, as the sort links do here, are a strong signal, because the current query string is often copied into several attributes at once. During recon, look for parameters that reappear in href, src or action attributes, and for applications that reflect the whole query string rather than a single named parameter.
What happened, in plain words
A security researcher found a bug on theacademy.upserve.com, a website that belongs to Upserve. The site has a page at /roles/ that lists roles and offers links to sort that list by name, by views and by duration. The bug is a reflected cross-site scripting (XSS) flaw, and it can be triggered without logging in.
To understand it, start with two everyday ideas. A request is what your browser sends to a web server when you open a page or click a link: it is a message asking for something. A response is what the server sends back, usually the HTML that makes up the page. A query string is the part of a web address after the ? sign, used to pass small pieces of information to the server, like a search term or a sort order.
Reflected XSS means the server takes something from the request and writes it straight back into the page it returns, without cleaning it up. If that something is written in a way the browser treats as code, the browser runs it. A useful comparison: imagine a receptionist who reads out a visitor's name over the office speaker. If a visitor writes "and everyone should leave the building" on the sign-in sheet, the receptionist reads that out too, and people act on it. The receptionist did not mean to cause trouble; they simply repeated untrusted input.
The steps to reproduce
The researcher opened this URL in Firefox:
https://theacademy.upserve.com/roles/?%22%3E%3Cscript//src=data:,alert(location)//
The part after ? is the query string. It looks unreadable because many characters are percent-encoded: a way of writing characters that are not allowed in a URL by replacing them with a % and two hex digits. Decoded, %22 is a double quote ("), %3E is > and %3C is <. So the query string contains a double quote, a closing angle bracket, then <script, then //src=data:,alert(location)//.
Line by line, the payload does this:
"closes the attribute the value is being written into.>closes the HTML tag that attribute belonged to.<scriptstarts a new script element, which tells the browser to run code.//src=data:,alert(location)//gives that script a source.data:is adata:address, a way of embedding content directly in a URL instead of fetching it from a server. The content isalert(location), a tiny piece of JavaScript that pops up a box showing the current page address.- The
//sequences act as comment markers, so the leftover text around the payload does not break it.
Opening that URL matters because it shows the whole attack in one action: no login, no special tools, just a crafted link.
The request
The request the browser sends is minimal:
GET /roles/?%22%3E%3Cscript//src=data:,alert(location)// HTTP/1.1
Host: theacademy.upserve.com
GET is the method used to ask for a page. The path and query string follow, then HTTP/1.1, the version of the protocol. Host names the website being asked. There are no cookies here: a cookie is a small piece of data a site stores in your browser, often to remember that you are logged in. Their absence is the point: the bug works for anyone, logged in or not.
The response
The server sent back HTML in which the payload appears inside the sorting links:
<a class="category dropdown-item name-sort sorting-desc" href="/roles/?"><script//src=data:,alert(location)//&orderby=name&order=DESC">Name</a>
<a class="category dropdown-item views-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=views&order=DESC" >Views</a>
<a class="category dropdown-item duration-sort " href="/roles/?"><script//src=data:,alert(location)//&orderby=duration&order=DESC">Duration</a>
An <a> tag is a link, and href is the address it points to. The payload appears inside the href value of these links. Because the double quote and > from the payload were not encoded, the browser stops treating them as part of the address: the quote ends the href value, the > ends the link tag, and the <script that follows becomes a real script element. The same value appears in all three links.
The report states the impact as reflected XSS. It was rated low severity, a bounty of 250.00 USD was paid, and it was disclosed on 2018-10-19. The report does not describe a fix.
In general, how this kind of bug works
Reflected XSS happens when input from a request is written into the response without output encoding, which means converting characters such as <, > and " into harmless text so the browser displays them instead of acting on them. The key detail is context: a value placed between tags, inside an attribute, inside a URL or inside a script block each needs different handling. Here the value lands inside a double-quoted attribute, so the dangerous characters are the quote that ends the attribute and the angle brackets that start a new element.
The bug class persists because building pages by gluing strings together makes it easy to forget encoding, and because the same value is often reused in several places, as with the three sort links here. Defences are output encoding matched to the context, a Content Security Policy (a set of rules a site sends to tell the browser which scripts may run) that blocks inline and data: script sources, and treating the query string as untrusted data everywhere it is echoed.
How to test for it
- Find every place where request data appears in the response: search parameters, parts of the path, headers that get echoed, and error messages.
- For each one, note the context: between tags, inside an attribute, inside a URL attribute, or inside a script or style block.
- Send a harmless marker first to confirm the value comes back unchanged and to see whether it is encoded. A marker containing a quote and angle brackets shows immediately whether encoding happens.
- If the marker survives unencoded, build a payload for that context. In an attribute, break out with a quote and a closing angle bracket, then add an element that runs, such as a
scripttag. - Confirm execution in a real browser rather than trusting the response body alone, and check whether the payload fires without any cookies, as in this report.
A positive result is a response where the injected markup is not encoded and the browser runs it. Common false positives are reflections that are encoded but look alarming in the raw response, payloads that only appear inside a JavaScript string where quotes are escaped, values reflected into a context the browser does not execute, and cases where a Content Security Policy blocks the payload even though the reflection is unencoded. Also check whether the reflection is produced by the server or by JavaScript in the browser, since that changes where the fix belongs.
How it is fixed
The standard fix is context-aware output encoding of every value taken from the request before it is written into the page, so quotes, angle brackets and ampersands become entities inside attributes. Where the value is used to build a URL, it should be URL-encoded as well. A Content Security Policy that disallows inline script and restricts script sources adds defence in depth. Frameworks with auto-escaping templates remove most of this class of bug when used consistently, and the shared code that generates the sort links should be corrected once so all three links are covered.
Hunting notes
Reflected XSS tends to hide in features that echo state back into links and navigation: sorting and filtering controls, pagination, search result pages, language and theme switchers, and redirect or return-to parameters. Pages that rebuild their own URLs, as the sort links do here, are a strong signal, because the current query string is often copied into several attributes at once. During recon, look for parameters that reappear in href, src or action attributes, and for applications that reflect the whole query string rather than a single named parameter.
Glossary
- Request: the message a browser sends to a server asking for a page or other resource.
- Response: the message a server sends back, usually containing HTML or other data.
- Query string: the part of a URL after the
?, carrying small pieces of data to the server. - GET: the HTTP method used to ask for a page.
- Host: the header in a request that names the website being contacted.
- Cookie: a small piece of data a site stores in the browser, often used to remember a login.
- Reflected XSS: a flaw where input from a request is written back into the page unencoded and the browser runs it as code.
- Payload: the crafted piece of input designed to trigger the bug.
- Percent-encoding: writing characters in a URL as
%plus two hex digits. - Attribute: a setting inside an HTML tag, such as
hrefon a link. href: the attribute of a link that holds its destination address.data:URI: a URL that embeds content directly instead of fetching it from a server.- Output encoding: converting special characters into harmless text before writing them into a page.
- Context: the place in the HTML where a value lands, which decides which characters are dangerous.
- Content Security Policy: rules a site sends to the browser saying which scripts may run.
- False positive: a result that looks like a bug but is not exploitable.