Skip to content
XSS Write-up Advanced

MyBB <= 1.8.31: Remote Code Execution Chain

A stored XSS in the visual editor allowed a low-privileged user to execute JavaScript when an admin hovered over their signature, and an SQL injection in the admin user search could be escalated to remote code execution when PostgreSQL was used, by overwriting a template that is later evaluated.

Aleksey Solovev Follow

Published on swarm.ptsecurity.com

MyBB is one seriously popular type of open-source forum software. However, even a popular tool can contain bugs or even bug chains that can lead to the compromise of an entire system.

Aleksey Solovev, on swarm.ptsecurity.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. 7 min read.

Context

MyBB is an open-source forum engine. This write-up covers a chain of three issues in MyBB up to and including version 1.8.31: a persistent XSS in the visual editor, an SQL injection in the Admin CP user search, and, when the forum is installed on PostgreSQL, escalation of that SQL injection to remote code execution by overwriting a template that is later passed to eval.

The features involved are ordinary forum features: a user signature rendered in a profile, the user search in the Admin CP, and the template editor in the Admin CP. The template editor normally lets an administrator change the HTML of a page fragment, and templates may contain variable placeholders such as {$lang→users_signature} or {$memprofile['signature']}.

Setup

  • A registered user with low privileges, who edits their own signature.
  • A user in the Moderator or Administrator group, who views that signature.
  • A user in the Administrator group, who uses the Admin CP user search.
  • A proxy such as BurpSuite to intercept the search request.
  • For the RCE stage, MyBB installed with PostgreSQL as the database engine, chosen during installation.

The XSS issue is CVE-2022-43707 (rated high risk) and the SQL injection is CVE-2022-43709 (rated medium risk).

Finding it

The starting point was earlier work by Igor Sak-Sakovskiy on XSS via nested parser conditions, which included a MyBB payload. The MyBB team fixed that payload in version 1.8.25. Rather than stopping there, the researcher fuzzed the fix itself, which is where the persistent XSS came from. The SQL injection was then found in the Admin CP user search, and the template mechanism was analysed to see whether the SQL injection could reach code execution.

Exploitation

Step 1: persistent XSS in a user signature

A low-privileged registered user edits their signature in the settings. In the editor's "View Source" mode the following payload is inserted:

Text
[email][email= onpointerover=alert()//]text[/email]
Inserting the payload with xss into a user signature From the original on swarm.ptsecurity.com

After the signature is updated, the rendered link carries a new onpointerover event handler with the value alert();//. Hovering the mouse cursor over the rendered text executes the embedded JavaScript.

Execution of the embedded javascript code in the user signature when hover over the mouse cursor From the original on swarm.ptsecurity.com

If a user in the Moderator or Administrator group opens the profile of the user who set this signature, the code also runs when that privileged user hovers over the rendered text.

Execution of the embedded javascript code when editing the user signature by the administrator when hover over the mouse cursor From the original on swarm.ptsecurity.com

Step 2: SQL injection in the Admin CP user search

A user in the Administrator group can perform an SQL injection when searching for users through the Admin CP at:

Text
/admin/index.php?module=user-users&action=search

By default the custom fields Location, Bio and Gender are vulnerable.

Custom fields when searching for users From the original on swarm.ptsecurity.com

To demonstrate it, the search is run against the custom Bio field. The user first needs some text in that field so the search returns at least one record. Here the value My biography is added to the custom Bio field of the user in the Administrator group.

Filling in the custom Bio field From the original on swarm.ptsecurity.com

A search for users by the custom field Bio with the value My biography is then made and intercepted with a proxy.

Search for users by the custom bio field From the original on swarm.ptsecurity.com

The user search query is intercepted on the custom Bio field.

The user search request intercepted via proxy From the original on swarm.ptsecurity.com

The vulnerable place is the key of the profile_fields array:

Text
profile_fields[fid2]=My biography

Adding a single quotation mark after fid2 makes the server return the error HTTP/1.1 503 Service Temporarily Unavailable.

Adding the single quotation mark to the key of the custom Bio field in the user search request intercepted through a proxy From the original on swarm.ptsecurity.com

The data sent by the user is not fully controlled or escaped. The root of the problem is in admin/modules/user/users.php, in how the value of the $column variable is handled. That value should either be framed with double quotes or checked against a list of valid values.

Insufficient escaping of user data leading to a SQL Injection From the original on swarm.ptsecurity.com

Because there is no check on which values of $column are allowed, the injection is possible as long as no special characters are used, since those are escaped by $db->escape_string:

PHP
' AND '.$db->escape_string($column)."

A payload that delays query execution by 5 seconds:

Text
profile_fields[(select pg_sleep(5))::text = $quote$$quote$ and fid2]=My biography
The SQL Injection, which causes the execute SQL query to fall asleep for an additional 5 seconds From the original on swarm.ptsecurity.com

Step 3: from SQL injection to RCE through a template

The SQL injection can be escalated if a database engine that supports multiple queries was selected when MyBB was installed. During installation, PostgreSQL is one such choice.

When installing the forum engine, the PostgreSQL is selected in the database configuration From the original on swarm.ptsecurity.com

With PostgreSQL, the injected SQL runs through the native pg_send_query function in inc/db_pgsql.php.

Calling the native function pg_send_query when using the Postgresql From the original on swarm.ptsecurity.com

According to the official PHP documentation, pg_send_query can execute multiple queries at a time.

The official documentation for the native pg_send_query function From the original on swarm.ptsecurity.com

Templates are created and edited in the Admin CP.

The functionality of template editing From the original on swarm.ptsecurity.com

The image above shows the editing form of the template member_profile_signature. Templates can contain variable values such as {$lang→users_signature} and {$memprofile['signature']}. The template is stored in the database in the mybb_templates table; the edited member_profile_signature template has tid = 240.

The user signature template stored in the database From the original on swarm.ptsecurity.com

In member.php, the member_profile_signature template is read from the database on line 2158 and passed to the eval function.

Executing code on the server using a user signature template From the original on swarm.ptsecurity.com

One might think that the construction ";${system('id')} could simply be injected into a template and would become a separate instruction executed by that eval. That does not work. Before a template is saved to the database, the check_template function is called in admin/modules/style/templates.php on line 536.

When saving a template, the check_template function is called From the original on swarm.ptsecurity.com

The purpose of check_template is to check the user-supplied template for structures that would allow arbitrary code to be executed through eval.

The check_template function is a sandbox that protects against the introduction of dangerous constructions in the template From the original on swarm.ptsecurity.com

If check_template finds a dangerous construction, it returns true and a saving error occurs.

The result of the check_template function is a security error From the original on swarm.ptsecurity.com

So the only way to reach eval with the construction ";${system('id')} is to embed it into the template while bypassing check_template. That is where the SQL injection comes back in. Using single or double quotes during the injection would lead to them being escaped:

PHP
' AND '.$db->escape_string($column)."

The following SQL query rewrites the required construction into the member_profile_signature template without using single quotes:

Text
update mybb_templates set template = (select concat((select template from mybb_templates mt  where mt.tid = 240),(select CHR(34)||CHR(59)||CHR(36)||CHR(123)||CHR(115)||CHR(121)||CHR(115)||CHR(116)||CHR(101)||CHR(109)||CHR(40)||CHR(39)||CHR(105)||CHR(100)||CHR(39)||CHR(41)||CHR(125)))) where tid = 240;

The query rewrites the template without using single quotes. The final SQL injection then has the form that leads to execution of arbitrary code on the system.

Executing the SQL Injection in multi query mode, where the second query overwrites the user signature template and injects malicious code From the original on swarm.ptsecurity.com

The result is execution of the system('id') command.

The RCE on the server via SQL Injection bypassing the template sandbox function From the original on swarm.ptsecurity.com

Root cause

The XSS payload was inserted through the editor's View Source mode and produced an onpointerover attribute on the rendered link.

The SQL injection comes from admin/modules/user/users.php using the key of the profile_fields array as the $column value without validating it against allowed values. $db->escape_string escapes special characters in the value, but the column name is not a value and is not protected by that escaping, so a crafted key changes the structure of the query.

The escalation depends on two design facts: PostgreSQL is driven through pg_send_query, which can run multiple statements in one call, and templates are stored in the database and later passed to eval in member.php. The check_template function in admin/modules/style/templates.php checks templates before they are saved, so the construction has to be embedded while bypassing it. Building the payload from CHR() avoids the quote escaping that would otherwise stop the injected statement.

Impact

The XSS is persistent: a low-privileged user stores it in a signature, and it executes in the browser of any Moderator or Administrator who views that profile and hovers over the rendered text. The SQL injection requires an account in the Administrator group, so it is a privilege escalation from an already highly privileged position rather than an unauthenticated attack. The RCE additionally requires MyBB to be installed with a database engine that supports multiple queries, such as PostgreSQL; the RCE additionally requires MyBB to be installed with a database engine that supports multiple queries, such as PostgreSQL. When those conditions hold, the attacker can execute arbitrary commands on the server, as shown by system('id').

Fix

Vulnerability fixes can be found on the official MyBB site for version 1.8.32. The report recommends that users update their software as soon as possible.

Variants to test

  1. Fuzz the fix rather than the original payload. Take a parser fix for a nested tag such as [email] and try other attribute positions and event handler names; a positive result is a rendered element carrying an event handler that fires on hover or another interaction.
  2. Try array keys as SQL identifiers wherever the application builds a column list from request parameters, for example profile_fields[fid2]. A single quotation mark in the key that produces a database error, such as a 503, is a positive signal.
  3. Test whether the database driver allows stacked queries. A payload that calls a time-delay function such as pg_sleep and measurably delays the response confirms it.
  4. Look for data that is validated on one path but stored and later executed on another, such as templates checked in the editor but read straight from the database into eval. A positive result is a stored value that reaches the execution sink without passing the check.
  5. When quote characters are escaped, build them with database functions such as CHR() and concatenate them onto an existing stored value. A positive result is the stored value containing the intended construction after the injected statement runs.

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

What happened, in plain words

MyBB is a piece of software that lets anyone run an online discussion forum: a website where people register, post messages, and have a profile page. It is open source, which means its programming code is public and anyone can read it, including people looking for mistakes in it.

This article describes three mistakes found in MyBB, up to and including version 1.8.31, and how they can be joined together into one attack. The three mistakes are:

  1. A persistent XSS in the visual editor used to write a forum signature. In everyday terms: a normal user can save a small piece of JavaScript (a tiny program that runs inside a web browser) into their signature, and that program then runs in the browser of a moderator or administrator who looks at the signature. "Persistent" means the malicious content is stored on the server and keeps working every time someone views it, like a note pinned to a noticeboard that everyone reads.
  2. An SQL injection in the user search of the Admin CP (the administrator control panel). In everyday terms: the search box builds a database question out of whatever the administrator types, and a crafted input can change the question itself, so the database does something the developer never intended.
  3. When the forum is installed on a particular database engine called PostgreSQL, that SQL injection can be escalated into remote code execution (RCE): the attacker can make the server run commands of their choosing. This is done by overwriting a template, a reusable piece of page layout stored in the database, which the forum later hands to a PHP function called eval that executes it as code.

The features involved are all ordinary forum features: a user signature shown on a profile, the user search in the Admin CP, and the template editor in the Admin CP. The template editor normally lets an administrator change the HTML (the markup that describes a web page) of a page fragment, and templates may contain variable placeholders such as {$lang→users_signature} or {$memprofile['signature']}. A placeholder is a slot that the forum fills in with a real value when the page is built, like a blank in a form letter.

Setup

To follow the whole chain, the researcher used the following pieces:

  • A registered user with low privileges, who edits their own signature. "Low privileges" means an ordinary account with no special powers.
  • A user in the Moderator or Administrator group, who views that signature. Moderators and administrators are the people who run the forum, so their browsers are valuable targets.
  • A user in the Administrator group, who uses the Admin CP user search.
  • A proxy such as BurpSuite to intercept the search request. A proxy is a program that sits between your browser and the website, so you can look at and change the messages going back and forth, like a postal worker who opens letters, reads them, and can rewrite them before delivery.
  • For the RCE stage, MyBB installed with PostgreSQL as the database engine, chosen during installation. A database engine is the software that stores and retrieves the forum's data (users, posts, settings); PostgreSQL is one popular choice.

The XSS issue is CVE-2022-43707 (rated high risk) and the SQL injection is CVE-2022-43709 (rated medium risk). A CVE is a public catalogue number given to a known security flaw so people can refer to it unambiguously, a bit like a case number for a reported crime.

Finding it

The starting point was earlier work by Igor Sak-Sakovskiy on XSS via nested parser conditions, which included a MyBB payload. A parser is the part of the software that reads text written by users (for example the special [email] tags used in forum posts) and turns it into formatted output. "Nested" means one tag sits inside another, like boxes inside boxes, and that is where parsers often get confused. The MyBB team fixed that payload in version 1.8.25.

Rather than stopping there, the researcher fuzzed the fix itself. Fuzzing means feeding a program lots of slightly varied inputs to see which ones make it behave unexpectedly, like trying many keys on a lock to find one that turns. That is where the persistent XSS came from. The SQL injection was then found in the Admin CP user search, and the template mechanism was analysed to see whether the SQL injection could reach code execution.

Exploitation

Step 1: persistent XSS in a user signature

A low-privileged registered user edits their signature in the settings. A signature is the short block of text that appears under every post a user makes, and on their profile page. In the editor's "View Source" mode, which shows the raw text instead of the formatted result, the following payload is inserted:

Text
[email][email= onpointerover=alert()//]text[/email]
Inserting the payload with xss into a user signature From the original on swarm.ptsecurity.com

Line by line, in plain words:

  • [email] opens a forum tag that normally turns text into a clickable email link.
  • [email= onpointerover=alert()//] opens a second email tag, but with an attribute. An attribute is an extra setting attached to an HTML element, such as the address a link points to. Here the attribute is named onpointerover, which is an event handler: a piece of JavaScript the browser runs when the mouse pointer moves over the element. The value is alert(), a JavaScript command that pops up a small dialog box, followed by //, which in JavaScript starts a comment so anything after it is ignored.
  • text is the visible text of the link.
  • [/email] closes the tag.

The idea is that the parser, when it rebuilds the formatted output, copies the onpointerover attribute into the final HTML. The browser then treats it as a real event handler and runs the JavaScript when the mouse hovers over the link.

After the signature is updated, the rendered link carries a new onpointerover event handler with the value alert();//. Hovering the mouse cursor over the rendered text executes the embedded JavaScript.

Execution of the embedded javascript code in the user signature when hover over the mouse cursor From the original on swarm.ptsecurity.com

If a user in the Moderator or Administrator group opens the profile of the user who set this signature, the code also runs when that privileged user hovers over the rendered text.

Execution of the embedded javascript code when editing the user signature by the administrator when hover over the mouse cursor From the original on swarm.ptsecurity.com

Why this matters: the attacker does not need to trick the administrator into clicking a suspicious link. The code is stored on the forum itself and runs when the administrator hovers over the rendered text in the profile.

Step 2: SQL injection in the Admin CP user search

A user in the Administrator group can perform an SQL injection when searching for users through the Admin CP at:

Text
/admin/index.php?module=user-users&action=search

This is a URL: the address of a page on the forum. The part after the question mark is the query string, a list of name=value pairs that tells the server which page to show and what to do. Here module=user-users says "open the user management module" and action=search says "run the search action".

By default the custom fields Location, Bio and Gender are vulnerable. A custom field is an extra profile question the forum administrator has added, such as "Where do you live?" or "Tell us about yourself".

Custom fields when searching for users From the original on swarm.ptsecurity.com

To demonstrate it, the search is run against the custom Bio field. The user first needs some text in that field so the search returns at least one record. Here the value My biography is added to the custom Bio field of the user in the Administrator group.

Filling in the custom Bio field From the original on swarm.ptsecurity.com

A search for users by the custom field Bio with the value My biography is then made and intercepted with a proxy.

Search for users by the custom bio field From the original on swarm.ptsecurity.com

The user search query is intercepted on the custom Bio field.

The user search request intercepted via proxy From the original on swarm.ptsecurity.com

The vulnerable place is the key of the profile_fields array:

Text
profile_fields[fid2]=My biography

Line by line, in plain words:

  • profile_fields is the name of a group of values sent to the server. In programming, an array is an ordered collection of values, and here it is sent as a set of named slots.
  • [fid2] is the key, the name of one slot inside that group. fid2 is the internal identifier of the Bio custom field.
  • =My biography is the value placed in that slot.

Adding a single quotation mark after fid2 makes the server return the error HTTP/1.1 503 Service Temporarily Unavailable. A single quotation mark is special in SQL, the language used to talk to databases: it marks where a piece of text begins and ends. If it appears where the developer did not expect it, the database question becomes malformed, and the server reports an error. That error is the first sign that user input is reaching the database question directly.

Adding the single quotation mark to the key of the custom Bio field in the user search request intercepted through a proxy From the original on swarm.ptsecurity.com

The data sent by the user is not fully controlled or escaped. Escaping means adding a backslash or similar marker before special characters so they are treated as plain text rather than as instructions. The root of the problem is in admin/modules/user/users.php, in how the value of the $column variable is handled. A variable is a named box in a program that holds a value; $column here holds the name of the database column to search in. That value should either be framed with double quotes or checked against a list of valid values.

Insufficient escaping of user data leading to a SQL Injection From the original on swarm.ptsecurity.com

Because there is no check on which values of $column are allowed, the injection is possible as long as no special characters are used, since those are escaped by $db->escape_string:

PHP
' AND '.$db->escape_string($column)."

Line by line, in plain words:

  • ' AND ' is a literal piece of SQL text: the word AND surrounded by single quotes, which in SQL marks it as a string of text.
  • . is the PHP operator that glues strings together, like tape joining two pieces of paper.
  • $db->escape_string($column) takes the value of $column and runs it through the escaping function, which neutralises special characters.
  • " closes the string being built.

The important point: escaping protects the value, but the column name is not a value. It is part of the structure of the question, so escaping does not help there.

A payload that delays query execution by 5 seconds:

Text
profile_fields[(select pg_sleep(5))::text = $quote$$quote$ and fid2]=My biography

Line by line, in plain words:

  • profile_fields[ starts the array key.
  • (select pg_sleep(5))::text is a small SQL expression that calls pg_sleep(5), a PostgreSQL function that makes the database wait for 5 seconds, and then converts the result to text. ::text is PostgreSQL's way of saying "treat this as text".
  • = $quote$$quote$ compares that text to an empty string written using PostgreSQL's dollar-quoting syntax, which avoids using ordinary single quotes.
  • and fid2] closes the expression and returns to the normal key name.
  • =My biography is the ordinary value.

This payload delays query execution by 5 seconds.

The SQL Injection, which causes the execute SQL query to fall asleep for an additional 5 seconds From the original on swarm.ptsecurity.com

Step 3: from SQL injection to RCE through a template

The SQL injection can be escalated if a database engine that supports multiple queries was selected when MyBB was installed. "Multiple queries" means the database will accept several SQL statements in one go, one after another, like a form that lets you write several instructions in the same box. During installation, PostgreSQL is one such choice.

When installing the forum engine, the PostgreSQL is selected in the database configuration From the original on swarm.ptsecurity.com

With PostgreSQL, the injected SQL runs through the native pg_send_query function in inc/db_pgsql.php. A function is a named block of code that does a job when called. pg_send_query is PostgreSQL's own function for sending a query to the database.

Calling the native function pg_send_query when using the Postgresql From the original on swarm.ptsecurity.com

According to the official PHP documentation, pg_send_query can execute multiple queries at a time.

The official documentation for the native pg_send_query function From the original on swarm.ptsecurity.com

Templates are created and edited in the Admin CP.

The functionality of template editing From the original on swarm.ptsecurity.com

The image above shows the editing form of the template member_profile_signature. Templates can contain variable values such as {$lang→users_signature} and {$memprofile['signature']}. A template is a reusable piece of page layout: instead of writing the same HTML everywhere, the forum keeps one copy and fills in the blanks. The template is stored in the database in the mybb_templates table; the edited member_profile_signature template has tid = 240. A table is a grid of rows and columns inside a database, like a spreadsheet; tid is the template's identifier number.

The user signature template stored in the database From the original on swarm.ptsecurity.com

In member.php, the member_profile_signature template is read from the database on line 2158 and passed to the eval function. eval is a PHP function that takes a string and runs it as code. That is dangerous: if an attacker can control the string, they control what the server executes.

Executing code on the server using a user signature template From the original on swarm.ptsecurity.com

One might think that the construction ";${system('id')} could simply be injected into a template and would become a separate instruction executed by that eval. In plain words: the " ends the surrounding string, the ; ends the current instruction, and ${system('id')} calls the system command id, which prints information about the current user on the server. That does not work. Before a template is saved to the database, the check_template function is called in admin/modules/style/templates.php on line 536.

When saving a template, the check_template function is called From the original on swarm.ptsecurity.com

The purpose of check_template is to check the user-supplied template for structures that would allow arbitrary code to be executed through eval. Think of it as a security guard at the door who reads every package before it goes into the warehouse.

The check_template function is a sandbox that protects against the introduction of dangerous constructions in the template From the original on swarm.ptsecurity.com

If check_template finds a dangerous construction, it returns true and a saving error occurs.

The result of the check_template function is a security error From the original on swarm.ptsecurity.com

So the only way to reach eval with the construction ";${system('id')} is to embed it into the template while bypassing check_template. That is where the SQL injection comes back in. Using single or double quotes during the injection would lead to them being escaped:

PHP
' AND '.$db->escape_string($column)."

Line by line, in plain words: this is the same fragment as before. It shows that any quote character the attacker types into the injected value gets escaped, so the attacker cannot simply write a quote to break out of the string. The trick is to build the quote characters inside the database instead, using a function that produces them from their numeric character codes.

The following SQL query rewrites the required construction into the member_profile_signature template without using single quotes:

Text
update mybb_templates set template = (select concat((select template from mybb_templates mt  where mt.tid = 240),(select CHR(34)||CHR(59)||CHR(36)||CHR(123)||CHR(115)||CHR(121)||CHR(115)||CHR(116)||CHR(101)||CHR(109)||CHR(40)||CHR(39)||CHR(105)||CHR(100)||CHR(39)||CHR(41)||CHR(125)))) where tid = 240;

Line by line, in plain words:

  • update mybb_templates set template = ... means "change the template column in the mybb_templates table".
  • (select concat(...)) builds a new value by joining pieces together with concat, which is SQL's glue for strings.
  • (select template from mybb_templates mt where mt.tid = 240) fetches the current text of the template with id 240, so the new value starts with what is already there.
  • CHR(34)||CHR(59)||CHR(36)||CHR(123)||CHR(115)||CHR(121)||CHR(115)||CHR(116)||CHR(101)||CHR(109)||CHR(40)||CHR(39)||CHR(105)||CHR(100)||CHR(39)||CHR(41)||CHR(125) builds the payload one character at a time from its numeric code. CHR(34) is a double quote, CHR(59) is a semicolon, CHR(36) is a dollar sign, CHR(123) is an opening brace, and so on. The || operator joins the characters together. The result is the text ";${system('id')} without ever typing a quote character literally.
  • where tid = 240; limits the change to that one template.

The query rewrites the template without using single quotes. The final SQL injection then has the form that leads to execution of arbitrary code on the system.

Executing the SQL Injection in multi query mode, where the second query overwrites the user signature template and injects malicious code From the original on swarm.ptsecurity.com

The result is execution of the system('id') command.

The RCE on the server via SQL Injection bypassing the template sandbox function From the original on swarm.ptsecurity.com

Root cause

The XSS payload was inserted through the editor's View Source mode and produced an onpointerover attribute on the rendered link. In plain words: the guard was updated to block one specific bad package, but the door was still open for a slightly different one.

The SQL injection comes from admin/modules/user/users.php using the key of the profile_fields array as the $column value without validating it against allowed values. $db->escape_string escapes special characters in the value, but the column name is not a value and is not protected by that escaping, so a crafted key changes the structure of the query. In plain words: the escaping only protects the contents of the envelope, not the address written on it.

The escalation depends on two design facts: PostgreSQL is driven through pg_send_query, which can run multiple statements in one call, and templates are stored in the database and later passed to eval in member.php. The check_template function in admin/modules/style/templates.php checks templates before they are saved, so the construction has to be embedded while bypassing it. A sandbox is a restricted area where code can run without affecting the rest of the system, like a playpen. Building the payload from CHR() avoids the quote escaping that would otherwise stop the injected statement.

Impact

The XSS is persistent: a low-privileged user stores it in a signature, and it executes in the browser of any Moderator or Administrator who views that profile and hovers over the rendered text. The SQL injection requires an account in the Administrator group, so it is a privilege escalation from an already highly privileged position rather than an unauthenticated attack. The RCE additionally requires MyBB to be installed with a database engine that supports multiple queries, such as PostgreSQL; the RCE additionally requires MyBB to be installed with a database engine that supports multiple queries, such as PostgreSQL. When those conditions hold, the attacker can execute arbitrary commands on the server, as shown by system('id').

Fix

Vulnerability fixes can be found on the official MyBB site for version 1.8.32. The report recommends that users update their software as soon as possible.

Variants to test

  1. Fuzz the fix rather than the original payload. Take a parser fix for a nested tag such as [email] and try other attribute positions and event handler names; a positive result is a rendered element carrying an event handler that fires on hover or another interaction.
  2. Try array keys as SQL identifiers wherever the application builds a column list from request parameters, for example profile_fields[fid2]. A single quotation mark in the key that produces a database error, such as a 503, is a positive signal.
  3. Test whether the database driver allows stacked queries. A payload that calls a time-delay function such as pg_sleep and measurably delays the response confirms it.
  4. Look for data that is validated on one path but stored and later executed on another, such as templates checked in the editor but read straight from the database into eval. A positive result is a stored value that reaches the execution sink without passing the check. An execution sink is the place in the code where data finally gets run, such as eval.
  5. When quote characters are escaped, build them with database functions such as CHR() and concatenate them onto an existing stored value. A positive result is the stored value containing the intended construction after the injected statement runs.

Glossary

  • XSS (cross-site scripting): a flaw where an attacker gets their own JavaScript to run inside someone else's browser on a website they trust.
  • Persistent XSS: XSS where the malicious content is stored on the server and runs every time a victim views the page.
  • JavaScript: the programming language that web browsers run to make pages interactive.
  • Event handler: an attribute on an HTML element that names code to run when something happens, such as a mouse hover.
  • HTML: the markup language that describes the structure of a web page.
  • Attribute: an extra setting on an HTML element, such as a link's destination or an event handler.
  • Parser: the part of the software that reads user-written text and turns it into formatted output.
  • Nested tag: a tag placed inside another tag, like a box inside a box.
  • Fuzzing: feeding a program many slightly varied inputs to find ones that make it misbehave.
  • SQL: the language used to ask questions of and give instructions to a database.
  • SQL injection: a flaw where user input changes the structure of an SQL query, so the database does something unintended.
  • Escaping: marking special characters so they are treated as plain text instead of instructions.
  • Time-based blind SQL injection: an injection where the attacker cannot see data but confirms it works by measuring a deliberate delay.
  • Database engine: the software that stores and retrieves a site's data, such as PostgreSQL.
  • PostgreSQL: a popular open-source database engine.
  • Multiple queries / stacked queries: sending several SQL statements in one call so they run one after another.
  • RCE (remote code execution): a flaw that lets an attacker run their own commands on a server over the network.
  • Template: a reusable piece of page layout stored by the forum and filled in with values when a page is built.
  • Placeholder: a slot in a template that gets replaced with a real value.
  • Variable: a named box in a program that holds a value.
  • Function: a named block of code that performs a job when called.
  • Array: an ordered collection of values, often addressed by keys.
  • Key: the name of a slot inside an array.
  • Table: a grid of rows and columns in a database, like a spreadsheet.
  • Column: one field of a table, such as the name of a user or the text of a template.
  • Proxy: a program that sits between a browser and a website so messages can be inspected and changed.
  • BurpSuite: a popular proxy tool used by security testers.
  • CVE: a public catalogue number for a known security flaw.
  • Admin CP: the administrator control panel of the forum.
  • Custom field: an extra profile question added by the forum administrator.
  • Signature: the short block of text shown under a user's posts and on their profile.
  • Sandbox: a restricted area where code can run without affecting the rest of the system.
  • Execution sink: the place in code where data is finally executed, such as eval.
  • eval: a PHP function that runs a string as code.
  • pg_send_query: a PostgreSQL function that sends a query to the database and can run several statements at once.
  • CHR(): a database function that returns the character matching a numeric code.
  • concat: a database function that joins strings together.
  • pg_sleep: a PostgreSQL function that makes the database wait for a given number of seconds.
  • system(): a PHP function that runs an operating system command.
  • Privilege escalation: gaining more access than your account was meant to have.
  • Unauthenticated attack: an attack that needs no account or login at all.

More by Aleksey Solovev

View all

1 more disclosed report, best first.

More from MyBB

View all

The newest disclosed reports for this program.

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.