Skip to content
XSS Write-up Intermediate

XSS to Database Credential Leakage & Database Access — Story of total luck!

A reflected XSS in a blog's search bar was found, and later stress testing with many payloads caused the application to crash and reveal a database connection string with credentials. The attacker used those credentials to log into a publicly accessible phpMyAdmin instance and access all databases.

Harsh Bothra Follow

Published on medium.com

{{media:0}}

Harsh Bothra, 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 in this write-up is referred to only as redacted.com. It ran a blog website on WordPress, hosted at the subdomain blog.redacted.com. The feature involved is the blog's search bar, which takes user input and reflects it back in the response. The researcher notes that WordPress offers relatively few attack vectors and that, as a third-party hosted service, not every functionality can be tested.

The write-up describes a reflected XSS that, through an accidental side effect, exposed a database connection string containing login credentials, which were then used to log in to a publicly reachable phpMyAdmin instance.

Setup

The report does not describe any accounts, roles or specific tool versions. The tools and conditions mentioned are:

  • A WordPress blog at blog.redacted.com.
  • The search bar of that blog as the injection point.
  • Burp Intruder, used to send a set of XSS payloads with the thread count set to 999.
  • A payload list assembled from online resources and PortSwigger Academy.
  • Recursive directory search, used later to look for additional paths.

Finding it

The researcher found a reflected XSS in the search bar within a couple of minutes, using this payload:

HTML
<img src=”x” onerror=alert(1)>

The payload is an image tag whose src points to a non-existent resource, so the onerror handler fires and calls alert(1). The report does not show the request or the response for this step, only the payload and the fact that it worked in the search bar.

The initial finding was reported, and the researcher then moved on to other areas of the application without further luck. Out of boredom, the plan changed to testing newly published XSS payloads from online resources and PortSwigger Academy to see how they behaved.

Exploitation

Step 1: Fuzzing the search bar with a payload list

The researcher ran Burp Intruder with all the collected payloads, using the maximum thread count of 999, and then left the machine for a walk. The report does not include the Intruder request, the payload file or the individual responses.

Step 2: Noticing the crash and the leaked connection string

On returning, the researcher navigated to blog.redacted.com to check for XML-RPC and other things. The application had crashed, and the error message revealed a database connection string containing login credentials. The report does not reproduce the error page or the connection string.

Step 3: Trying wp-admin

After some experimentation, the researcher tried to log in through the wp-admin endpoint using the leaked credentials. This did not work. The finding was reported anyway.

Step 4: Finding phpMyAdmin through directory search

The researcher then performed a recursive directory search and found the directory /server/phpmyadmin accessible publicly. Accessing that endpoint returned a phpMyAdmin login page.

Step 5: Logging in to phpMyAdmin

The credentials revealed in the error message were used on the phpMyAdmin login page. The login succeeded, and the researcher gained access to all databases.

Step 6: Updating the report

Comments were added and the initial proof of concept was updated. The report was triaged as P1 the same day and fixed in three days.

Root cause

The report gives a probable reason rather than a confirmed one. While searching for and retrieving data from the database, the malicious JavaScript payload likely broke the MySQL query string logic, which produced a temporary error message until the cache expired. That error message disclosed the database connection string with credentials.

The report describes reflected XSS in general terms as input reflected without sanitisation or filtration, but does not analyse why this particular search bar was vulnerable.

The phpMyAdmin instance under /server/phpmyadmin was reachable publicly, and the leaked credentials worked on it.

Impact

In this instance, sending a large set of payloads to the search functionality coincided with the application crashing and returning an error page containing database credentials. With those credentials, and with the publicly accessible phpMyAdmin instance, the attacker could log in and reach all databases. The report frames the crash as temporary, until the cache expires, and the credential leak as a side effect of that temporary error state.

Fix

The report states only that the issue was fixed in three days. Based on the root cause, the relevant fixes would be to sanitise and encode the search input so the payload is never reflected as executable markup, to stop returning raw database error details to clients, and to remove public access to the phpMyAdmin directory or restrict it to trusted networks.

Variants to test

  • Search and filter parameters on other WordPress blogs. Submit the same image payload and check whether it executes. A positive result is a JavaScript dialog firing from the reflected input.
  • Stress testing any functionality that talks to the database. If a bug is already found on such a feature, send a larger volume of requests, where testing is allowed. A positive result is a temporary error page that discloses connection strings, stack traces or other configuration details.
  • Recursive directory search for administrative panels. Look for paths such as phpMyAdmin installations. A positive result is a publicly reachable login page for a database management tool.
  • Reusing credentials from error messages against adjacent services. Take any credentials disclosed in an error and try them on the administrative endpoints found. A positive result is a successful login to a service that should not have been reachable with those credentials.

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

What happened, in plain words

A security researcher was testing a blog website for a common kind of bug called Cross-Site Scripting, or XSS for short. In an XSS bug, a website takes something a visitor types (like a search term) and shows it back on the page without cleaning it up first. If the visitor types ordinary text, nothing bad happens. But if the visitor types a small piece of code, the website treats that code as part of the page and runs it in the visitor's browser. That is the bug.

The researcher found this bug in the blog's search bar very quickly. Then, just for fun, they decided to throw a large number of different XSS test payloads at the search bar all at once, using an automated tool. They then went for a walk. When they came back, the website had crashed, and the error page it showed contained something it should never have shown: a database connection string with the login credentials for the database.

Those credentials did not work on the blog's own admin login page. But the researcher then searched the server for hidden folders and found a phpMyAdmin page, which is a web tool for managing databases, sitting in a publicly reachable folder. The leaked credentials worked there, and the researcher could see every database on the server.

The bug was reported, rated as a high priority (P1) the same day, and fixed within three days.

This article walks through the same story step by step, explaining every technical idea from scratch along the way.

The target and the setup

The write-up calls the target only redacted.com. That is a placeholder: the real domain name was hidden to protect the company. What we know is that redacted.com ran a blog at the subdomain blog.redacted.com.

A subdomain is a smaller name that sits under a main domain. If redacted.com is the main building, blog.redacted.com is a named office inside it. Websites often put different services on different subdomains: the shop on one, the blog on another, the support pages on another.

The blog was built with WordPress. WordPress is a very popular free software for making websites, especially blogs. You install it, pick a theme, write posts, and it handles the rest. Because millions of sites use it, its behaviour is well known, which cuts both ways: it is well tested, but attackers also know exactly how it works.

The researcher notes that WordPress offers relatively few attack vectors. An attack vector is a way in, a feature or path an attacker can use to try to break something. A blog mostly just shows articles and lets people search and comment, so there is not much surface to poke at. The researcher also notes that, because the blog was a third-party hosted service, not every functionality could be tested. In plain terms: the blog was run by someone else, so the researcher could only test what was publicly reachable, not the inner workings behind it.

The feature at the centre of the story is the blog's search bar. It takes whatever a visitor types and shows it back in the results page, for example "Showing results for: your search term". That "showing it back" behaviour is exactly where reflected XSS lives.

Finding the XSS

Reflected XSS is the simplest kind of XSS to picture. You type something into a box, the website sends it back to you inside the page, and if the website did not clean it up, your browser runs it as code. The word "reflected" is used because the input bounces straight back in the response, like a mirror. The other main kind, stored XSS, is when the input is saved on the server and shown to other visitors later.

The researcher found a reflected XSS in the search bar within a couple of minutes, using this payload:

HTML
<img src=”x” onerror=alert(1)>

Let us take that apart piece by piece, because it is the heart of the whole story.

  • <img ...> is an HTML tag for showing a picture. HTML is the language web pages are written in, and tags are the instructions inside it.
  • src=”x” tells the browser where the picture lives. Here it points to x, which is not a real address, so the picture cannot load.
  • onerror=alert(1) is the interesting part. onerror is an event handler: a small instruction that says "when something goes wrong with this picture, run this code". Because the picture address is fake, loading it always fails, so the handler always fires.
  • alert(1) is a built-in browser function that pops up a small dialog box with the number 1 in it.

So the payload says: "try to show a picture from a place that does not exist; when that fails, pop up a dialog". If the dialog appears, the browser ran code that the website did not intend to run. That is the proof of an XSS bug. Researchers call that popup the "popup of happiness", because it is the moment you know the bug is real.

The report does not show the request or the response for this step, only the payload and the fact that it worked in the search bar.

The researcher reported this finding and then moved on to other parts of the application without further luck. Then boredom set in, and the plan changed: test newly published XSS payloads from online resources and PortSwigger Academy to see how they behaved. PortSwigger Academy is a free learning site run by the makers of Burp Suite, a well-known tool for testing websites. It publishes explanations and example payloads for many kinds of bugs, and researchers often use it as a reference.

What happened next, step by step

Step 1: Fuzzing the search bar with a payload list

The researcher ran Burp Intruder with all the collected payloads, using the maximum thread count of 999, and then left the machine for a walk.

Two ideas need explaining here.

Burp Suite is a tool that sits between your browser and a website. It lets you watch every request your browser sends and every response the site sends back, and it lets you change them before they go out. Burp Intruder is the part of Burp that takes one request and repeats it many times, each time swapping in a different value from a list. That list is called a payload list. This process of sending many variations automatically is called fuzzing.

A thread is one line of work happening at the same time. If you send requests one after another, you wait for each reply before sending the next. If you use many threads, you send many requests at once. Setting the thread count to 999 means the tool was firing up to 999 requests in parallel. That is a very aggressive setting; the report's probable explanation for the crash is that a payload broke the MySQL query logic.

The report does not include the Intruder request, the payload file or the individual responses. What matters is the plan: instead of testing one payload by hand, the researcher sent a whole library of them at the search bar, at high speed, and then walked away.

Step 2: Noticing the crash and the leaked connection string

On returning, the researcher navigated to blog.redacted.com to check for XML-RPC and other things. XML-RPC is an older feature of WordPress that lets other programs talk to the blog remotely, for example to publish a post from a desktop app. It is a known thing to look at when testing WordPress, which is why the researcher went back to it.

What they found instead was that the application had crashed, and the error message revealed a database connection string containing login credentials.

A database is an organised store of information. For a blog, it holds the posts, the comments, the user accounts and the settings. A connection string is the short piece of text a program uses to reach that database: it says where the database lives and who to log in as. It typically contains a server address, a username and a password. It is meant to stay inside the server, hidden from visitors, because anyone who has it can talk to the database directly.

An error message is what a website shows when something goes wrong. Good practice is to show a vague message to visitors ("something went wrong, please try again") and keep the technical details in a private log. When a site shows the raw technical error to the public, that is called information disclosure, and it is a bug in its own right.

The report does not reproduce the error page or the connection string. What it tells us is that the crash exposed the database login details to anyone who loaded the page.

Step 3: Trying wp-admin

After some experimentation, the researcher tried to log in through the wp-admin endpoint using the leaked credentials. This did not work. The finding was reported anyway.

wp-admin is the standard address of the WordPress administration area. If you run a WordPress site, you go to something like https://your-site/wp-admin, type your username and password, and get the dashboard where you write posts and change settings. It was the obvious first place to try the leaked database username and password, because it is the login the researcher already knew about.

An endpoint is simply a specific address on a server that does something. Think of a website as a building with many doors, each with its own number: /wp-admin is one door, /search is another. Each door leads to a different function.

The login failed, which is a useful reminder: credentials for one system do not automatically work on another. The database user and the WordPress admin user are different accounts, even though they belong to the same website. The researcher reported the leak anyway, because the leak itself was already a serious problem.

Step 4: Finding phpMyAdmin through directory search

The researcher then performed a recursive directory search and found the directory /server/phpmyadmin accessible publicly. Accessing that endpoint returned a phpMyAdmin login page.

A directory is a folder on a web server. Just as your computer has folders inside folders, a website has paths like /images/, /blog/ and /server/. A directory search (often called directory brute forcing) is when a tool tries a long list of common folder and file names against a website to see which ones exist. It is recursive when, after finding a folder, the tool goes inside it and tries names there too, and keeps going deeper.

phpMyAdmin is a free web application for managing MySQL databases. MySQL is one of the most widely used database systems, and WordPress uses it. Instead of typing database commands on a black screen, you open phpMyAdmin in your browser and click around: browse tables, run queries, edit rows. It is a powerful tool, and it is meant to be reachable only by trusted people, usually on an internal network or behind extra protection. Finding one open to the public internet is a significant exposure on its own.

The path /server/phpmyadmin is the kind of thing a directory search can find: a management tool in a folder that was publicly reachable.

Step 5: Logging in to phpMyAdmin

The credentials revealed in the error message were used on the phpMyAdmin login page. The login succeeded, and the researcher gained access to all databases. The report does not show the login request or the phpMyAdmin interface.

This is the moment the two separate problems combine. The XSS crash leaked a username and password. The directory search found a login page that accepts exactly those credentials. Neither problem alone would have given access to the data: the leak without the open phpMyAdmin would have been embarrassing but harder to use, and the open phpMyAdmin without the leak would still have needed a password. Together, they gave the researcher access to all databases on the server.

Step 6: Updating the report

Comments were added and the initial proof of concept was updated. The report was triaged as P1 the same day and fixed in three days.

A proof of concept, or PoC, is the evidence you attach to a bug report to show the bug is real: the steps, the requests, screenshots, and the result. A first report often contains just enough to prove the bug exists; as the researcher learns more, the PoC is updated with the bigger impact.

Triaged means the company's security team looked at the report, confirmed it was valid, and assigned it a priority. P1 is the highest priority level in most bug bounty programmes: fix this now.

Why it happened

The report gives a probable reason rather than a confirmed one. While searching for and retrieving data from the database, the malicious JavaScript payload likely broke the MySQL query string logic, which produced a temporary error message until the cache expired. That error message disclosed the database connection string with credentials.

Let us unpack that. When you type something into a search bar, the website does not search by hand. It builds a query, which is a structured instruction to the database, something like "find all posts whose title contains the word you typed". The website takes your text and drops it into that instruction. If your text is ordinary, the instruction stays well formed. If your text contains special characters, it can break the instruction apart, and the database refuses to run it and returns an error. That is what "broke the MySQL query string logic" means.

A cache is a temporary copy kept to make things faster. Websites often store a page or a result for a short while so they do not have to rebuild it for every visitor. The report says the error was temporary, until the cache expired: once the bad result aged out, the site went back to normal. That is why the crash was not permanent.

The report explains reflected XSS in general as input reflected without sanitisation or filtration, but does not analyse this search bar's cause. Sanitisation means cleaning input so dangerous parts are removed or neutralised. Filtration means blocking input that matches known bad patterns. Without either, the application treated the malicious code as valid input and sent it back to the browser, which ran it. Output encoding is the practice of converting special characters into harmless text before showing them on a page, so < becomes something the browser displays rather than executes. A content security policy is a set of rules a site sends to the browser saying which scripts are allowed to run, as a second line of defence.

The phpMyAdmin instance under /server/phpmyadmin was reachable publicly, and the leaked credentials worked on it.

Impact

In this instance, sending a large set of payloads to the search functionality coincided with the application crashing and returning an error page containing database credentials. With those credentials, and with the publicly accessible phpMyAdmin instance, the attacker could log in and reach all databases. The report frames the crash as temporary, until the cache expires, and the credential leak as a side effect of that temporary error state.

Fix

The report states only that the issue was fixed in three days. Based on the root cause, the relevant fixes would be to sanitise and encode the search input so the payload is never reflected as executable markup, to stop returning raw database error details to clients, and to remove public access to the phpMyAdmin directory or restrict it to trusted networks.

In everyday terms: clean what visitors type before showing it back, show visitors a polite error instead of the technical one, and keep the database management tool behind a locked door that only trusted people can reach.

Variants to test

These are the same ideas applied elsewhere, for anyone learning from this story. Only test systems you are allowed to test.

  • Search and filter parameters on other WordPress blogs. Submit the same image payload and check whether it executes. A positive result is a JavaScript dialog firing from the reflected input.
  • Stress testing any functionality that talks to the database. If a bug is already found on such a feature, send a larger volume of requests, where testing is allowed. A positive result is a temporary error page that discloses connection strings, stack traces or other configuration details.
  • Recursive directory search for administrative panels. Look for paths such as phpMyAdmin installations. A positive result is a publicly reachable login page for a database management tool.
  • Reusing credentials from error messages against adjacent services. Take any credentials disclosed in an error and try them on the administrative endpoints found. A positive result is a successful login to a service that should not have been reachable with those credentials.

Glossary

  • XSS (Cross-Site Scripting): a bug where a website shows back something a visitor typed without cleaning it, so the visitor's code runs in the browser.
  • Reflected XSS: XSS where the input bounces straight back in the same response, like a mirror, rather than being saved on the server.
  • Stored XSS: XSS where the input is saved on the server and shown to other visitors later.
  • Payload: the piece of input an attacker sends to trigger a bug, here a small snippet of HTML and JavaScript.
  • HTML: the language web pages are written in, made of tags that describe what to show.
  • Tag: an instruction in HTML, such as <img> for a picture.
  • Event handler: a small instruction attached to an element that runs when something happens, such as onerror when a picture fails to load.
  • alert(1): a built-in browser function that pops up a dialog box, commonly used to prove that code ran.
  • Subdomain: a smaller name under a main domain, such as blog.redacted.com under redacted.com.
  • WordPress: a popular free software for building blogs and websites.
  • Attack vector: a way in, a feature or path an attacker can use to try to break something.
  • Search bar: the input box on a site where visitors type a search term; here the place the input was reflected.
  • Burp Suite: a tool that sits between browser and website, letting you watch and change requests and responses.
  • Burp Intruder: the part of Burp that repeats one request many times, swapping in different values from a list.
  • Payload list: the file of values that Intruder sends, one per request.
  • Fuzzing: sending many variations of input automatically to see how a system reacts.
  • Thread: one line of work happening at the same time; more threads means more requests sent in parallel.
  • XML-RPC: an older WordPress feature that lets other programs talk to the blog remotely.
  • Database: an organised store of information, such as posts, comments and user accounts.
  • Connection string: the short text a program uses to reach a database, including where it lives and who to log in as.
  • Error message: what a website shows when something goes wrong; raw technical errors shown to visitors leak information.
  • Information disclosure: a bug where a system reveals data it should have kept private.
  • Endpoint: a specific address on a server that does something, like a numbered door in a building.
  • wp-admin: the standard address of the WordPress administration area.
  • Directory: a folder on a web server.
  • Directory search: trying a long list of common folder and file names to find ones that exist; recursive means going deeper into folders that are found.
  • phpMyAdmin: a free web application for managing MySQL databases through a browser.
  • MySQL: one of the most widely used database systems; WordPress uses it.
  • Query: a structured instruction sent to a database, such as "find posts containing this word".
  • Cache: a temporary copy kept to make things faster, which expires after a while.
  • Sanitisation: cleaning input so dangerous parts are removed or neutralised.
  • Filtration: blocking input that matches known bad patterns.
  • Output encoding: converting special characters into harmless text before showing them on a page.
  • Content security policy: rules a site sends to the browser saying which scripts are allowed to run.
  • Proof of concept (PoC): the evidence attached to a bug report showing the bug is real.
  • Triaged: reviewed and confirmed by the company's security team, with a priority assigned.
  • P1: the highest priority level in most bug bounty programmes, meaning fix this now.

More by Harsh Bothra

View all

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