Unpacking CVE-2017–8917: A Hands-On Guide to Reproducing and Fixing the Joomla com_fields SQL Injection.
Joomla 3.7.0's com_fields component built an ORDER BY clause directly from the list[fullordering] request parameter without input filtering, allowing error-based SQL injection. An unauthenticated attacker could read arbitrary database contents, including the administrator username and password hash, through reflected MySQL error messages.
Published on medium.com
Sql Injection
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
CVE-2017-8917 is a critical error-based SQL injection in Joomla! 3.7.0, in the com_fields component. That component builds the ORDER BY clause of an internal database query directly from the list[fullordering] request parameter, without passing it through Joomla's standard input-filtering whitelist. The flaw scores 9.8 (Critical) on the CVSS 3.0 scale, with No Privileges Required and No User Interaction Required. The com_fields list view is reachable before login, so any unauthenticated attacker on the public internet can use this single endpoint to read arbitrary data from the database.
Because the unsanitised input lands inside an ORDER BY clause rather than a WHERE clause, UNION SELECT techniques do not apply. The working approach is error-based injection: functions such as extractvalue() or updatexml() are placed in the sort expression, MySQL evaluates the payload, fails to parse it as a valid XPath expression, and reflects the extracted database content inside its own error message. Default Joomla configurations surface PHP and MySQL errors directly to the client, so that error message becomes an exfiltration channel.
Setup
The lab was built for isolation first. The environment was an Oracle VirtualBox VM running a 64-bit Kali Linux guest, with the network adapter locked to NAT so the guest had no reachable IP address on the real LAN. A clean snapshot was taken before any software was deployed, so the VM could be rolled back quickly if a configuration went wrong.
Docker and Docker Compose were installed inside the Kali VM. The target was a container pinned to joomla:3.7.0, paired with a mysql:5.7 database backend.
Two preconditions matter before any request is sent:
- The
/installation/directory must be removed andconfiguration.phpmust be present. Otherwise Joomla redirects all traffic to the setup wizard. curltreats square brackets as glob ranges by default, which mangles the request. Use the-gflag and URL-encode the brackets as%5Band%5Dso the payload reaches the server intact.
Finding it
Before exploiting anything, the researcher verified that the service was healthy, so that later anomalies could be attributed to the exploit rather than a broken installation. A preliminary curl request returned HTTP/1.1 200 OK with standard Apache and PHP headers. Reading the version file inside the container returned:
RELEASE = '3.7'
DEV_LEVEL = '0'
That confirmed the unpatched target was active and responsive. The vulnerable surface is the com_fields list view, whose list[fullordering] parameter is concatenated into an ORDER BY clause without whitelist validation.
Exploitation
Step 1: define the base URL
A base URL targeting the com_fields endpoint was defined so that testing could be done systematically. Requests use curl -g and the encoded bracket forms %5B and %5D for the list[fullordering] parameter.
Step 2: prove arbitrary SQL execution with the database version
An extractvalue() call wrapping a version query was injected into the ordering parameter. The database version, 5.7.44, leaked directly inside the HTML title element of the error response, wrapped in tilde (0x7e) delimiters.
Step 3: read the database user and schema
Querying the database user and schema name returned [redacted] and joomladb.
Step 4: pull the administrator password hash in fragments
extractvalue() truncates its output at 32 characters, and the administrator bcrypt hash is 60 characters long. The hash was therefore pulled in 32-character fragments using SUBSTRING(). Stitching the fragments together yielded the full administrator username and bcrypt hash (admin:$2y$10$...), which an attacker could take offline and crack with commodity hardware.
Root cause
The com_fields component constructs the ORDER BY clause of an internal query from the list[fullordering] request parameter without routing it through Joomla's standard input-filtering whitelist. The parameter is therefore attacker-controlled SQL syntax inside the query. The parameter was not routed through Joomla's standard input-filtering whitelist, so it reached the query unfiltered.
Two design factors turn the injection into a reliable exfiltration channel. First, the injection point is in ORDER BY, so UNION SELECT is not usable and error-based functions are the practical route. Second, default Joomla configurations display PHP and MySQL errors to the client, so the XPath parse error carries the extracted data back to the attacker.
Impact
The com_fields list view is reachable pre-login, and the CVSS metrics record No Privileges Required and No User Interaction Required. Any unauthenticated attacker on the public internet can use this single endpoint to read arbitrary data from the underlying database. In the lab this covered the database version, the database user and schema, and the administrator username and bcrypt hash. A stolen hash can be attacked offline with commodity hardware.
Fix
CVE-2017-8917 was officially patched in the Joomla 3.7.1 source release through rigorous input validation on the ordering parameter. Because Docker Hub publishes joomla:3.7.3 as the earliest accessible patched image tag containing the fix, the service definition in docker-compose.yml was updated from 3.7.0 to 3.7.3. After pulling the patched container and resetting the database volume, re-running the exact same exfiltration request produced no output: the XPath error was gone, no database version was leaked, and the injection vector was fully sealed.
For defenders, Apache access logs can reveal exploitation attempts: look for requests to index.php?option=com_fields where list[fullordering] contains SQL functions such as extractvalue, updatexml, concat or substring. A spike in HTTP 500 responses on this endpoint is an early indicator of automated probing. Web Application Firewalls configured to reject non-integer or unexpected structural values in sorting parameters can neutralise the vulnerability during the window between public disclosure and patch deployment.

Variants to test
A positive result is a database error message containing the extracted value, or a visible change in the response title or body. A positive result is an XPath parse error that reflects the injected query result. A positive result is a complete value reconstructed from several error responses. A positive result is a cluster of such requests or errors from one source. A positive result is a blocked request rather than a database error.
What happened, in plain words
A piece of software called Joomla, which people use to build websites, had a serious bug in one of its versions. The bug let anyone on the internet, without any account or password, ask the website's database questions it was never meant to answer. A database is the organised store of information behind a website: user accounts, articles, settings, and in this case the administrator's login details.
The bug is catalogued under the name CVE-2017-8917. A CVE is a public reference number given to a known security flaw so that people can talk about it unambiguously, a bit like a case number for a police report. The flaw lived in a part of Joomla called com_fields, which is a feature for adding extra custom fields to content. The researcher, Asasira Morris, rebuilt the vulnerable version in a safe, isolated computer, attacked it, read data out of it, then moved to a patched image and showed the attack stopped working.
This article walks through that same journey for someone who has never done security work before. You only need to be comfortable using a browser and a computer. Every technical term is explained the first time it appears.
The vulnerability, explained from zero
What SQL and databases are
Websites like Joomla store their content in a database, and the language used to talk to most such databases is called SQL (Structured Query Language). You can think of a database as a very large, very strict filing cabinet, and SQL as the set of instructions you hand to the clerk: "give me every row in the users drawer", "sort these rows by date", and so on. The clerk follows instructions exactly and does not question them.
What SQL injection is
SQL injection is what happens when a website takes something a visitor typed and pastes it straight into one of those instructions, instead of checking it first. Imagine a form that asks for your name and then tells the clerk "find the person called [your name]". If you type a normal name, all is well. If you type something clever that includes extra SQL instructions, the clerk reads your text as part of the command and obeys it. That is the whole idea: the attacker's words become part of the database's instructions.
What this particular bug is
CVE-2017-8917 is a critical flaw in Joomla 3.7.0, in the com_fields component. A component is a self-contained module inside Joomla that provides one feature. This one builds part of an internal database query, specifically the ORDER BY clause, directly from a request parameter called list[fullordering], without passing it through Joomla's standard input-filtering whitelist.
Two of those terms need unpacking:
- A request parameter is a named value sent along with a web request, usually visible in the address bar after a question mark. When you search a shop for "shoes", the word shoes travels as a parameter.
- An
ORDER BYclause is the part of a SQL instruction that says how to sort results, for example "sort by price". - A whitelist is a list of values that are known to be acceptable. Input filtering against a whitelist means: if what arrived is not on the approved list, reject it. Joomla has such a mechanism, but on this code path it was not applied.
So the sort order the visitor asks for is pasted into the database instruction unchecked. That is the injection.
Why the usual attack does not work here
A common SQL injection trick is called UNION SELECT. It means: append a second query to the first one and have the database return the results of both together. It does not apply when the injection point sits in an ORDER BY clause, the sorting part of a query. Here the injection point is in ORDER BY, the sorting part, so UNION SELECT does not apply. The researcher needed a different route.
The error-based route
The route used is called error-based SQL injection. The idea is to make the database produce an error message that contains the very data you want to read. The attacker places functions such as extractvalue() or updatexml() into the sort expression. These are MySQL functions that expect a piece of text formatted as an XPath expression, which is a way of pointing at a location inside a structured document. MySQL evaluates the payload, fails to parse it as valid XPath, and puts the extracted database content inside its own error message.
That only helps if the error message is shown to the visitor. Default Joomla configurations surface PHP and MySQL errors directly to the client, so the error message becomes an unintended exfiltration channel. Exfiltration simply means getting data out of a system.
How serious is it
The flaw scores 9.8 out of 10, rated Critical on the CVSS 3.0 scale. CVSS is a standard scoring system for the severity of security flaws. The metrics behind the score include No Privileges Required and No User Interaction Required: no account is needed, and nobody has to click anything. The com_fields list view is reachable before login, so any unauthenticated attacker on the public internet can use this single endpoint to read arbitrary data from the database. An endpoint is a specific address on a server that accepts requests, and unauthenticated means "without proving who you are".
Building a safe lab
Why isolation comes first
Practising attacks on a real machine connected to your home or office network is a bad idea: a mistake could expose your own computer or other devices. Safety and isolation are prerequisites for any offensive security exercise. The researcher built the lab inside an isolated virtual machine.
A virtual machine (VM) is a computer simulated inside your real computer by software. It has its own operating system and disk, and you can delete it without touching your real machine. Oracle VirtualBox is the software used to run it here. The guest operating system was 64-bit Kali Linux, a Linux distribution that ships with security tools.
The VM's network adapter was locked to NAT. NAT is a networking mode where the virtual machine can reach out to the internet but has no reachable address of its own on the real Local Area Network, so nothing on your real network can connect in to it. A clean snapshot was captured before any software was deployed. A snapshot is a saved copy of the entire machine at a moment in time, so you can roll back to it if a configuration goes wrong.
Docker and the target
Docker is a tool for running software in containers. A container is a packaged, self-contained copy of an application with everything it needs to run, so it behaves the same everywhere. Docker Compose is a companion tool that describes several containers in one file and starts them together. Inside the Kali VM, Docker and Docker Compose were installed to spin up the target container pinned precisely to joomla:3.7.0, paired with a mysql:5.7 database backend. Pinning to an exact version matters: the bug exists in 3.7.0 and was fixed in 3.7.1, so the version number is the whole point.
Two preconditions before any request
- The
/installation/directory must be removed andconfiguration.phpmust be present. Otherwise Joomla redirects all traffic to the setup wizard. In plain terms, a freshly unpacked Joomla still thinks it is being installed, and until you delete the installer folder and leave its configuration file in place, every visit lands on the installation screens instead of the site. curltreats square brackets as glob ranges by default, which mangles the request. curl is a command-line tool for sending web requests, useful because it shows you exactly what is sent and received. A glob range is a pattern like[1-5]that curl expands into several values, so a parameter writtenlist[fullordering]would be altered before it leaves your machine. The fix is to use the-gflag, which turns that expansion off, and to URL-encode the brackets as%5Band%5D. URL encoding is a way of writing characters that are not allowed literally in a web address;%5Bis the encoded form of[and%5Dof]. With both measures the payload reaches the server intact.
Checking the target is healthy
Before attempting any exploitation, it is vital to verify that the service is running normally, so that subsequent anomalies can be definitively attributed to the exploit rather than a broken installation. This is the same discipline as testing a microphone before a recording: if something is wrong later, you know it was not the equipment.
A preliminary curl request to the server confirmed a healthy HTTP/1.1 200 OK status alongside standard Apache and PHP headers. HTTP status codes are short numbers a server returns to describe the outcome; 200 means "here is your page, all fine". Apache is a common web server program and PHP is the programming language Joomla is written in, so seeing their headers is a sign the expected stack is answering.
Inspecting the version file inside the container returned:
RELEASE = '3.7'
DEV_LEVEL = '0'
This is a small configuration file inside the Joomla installation that records which release is running. RELEASE = '3.7' and DEV_LEVEL = '0' together mean version 3.7.0, validating that the unpatched target was active and responsive. The vulnerable surface is the com_fields list view, whose list[fullordering] parameter is concatenated into an ORDER BY clause without whitelist validation. Concatenated means simply glued onto the end of the query text.
Exploitation, step by step
Step 1: define the base URL
A base URL targeting the com_fields endpoint was defined so that testing could be done systematically. A base URL is the fixed front part of an address, the part that stays the same, so each test only changes the interesting bit at the end. Requests use curl -g and the encoded bracket forms %5B and %5D for the list[fullordering] parameter, for the reasons explained above.
Step 2: prove arbitrary SQL execution with the database version
To prove arbitrary SQL execution, an extractvalue() function wrapping a version query was injected into the ordering parameter. The goal of this first test is modest on purpose: read the database's own version number. If that comes back, you have proof that your text is being executed as SQL, before you ask for anything sensitive.
The database version, 5.7.44, leaked directly inside the HTML title element of the error response, wrapped in tilde (0x7e) delimiters. The HTML title element is the text a browser shows in the tab of the page. Tildes are used as markers so the leaked value is easy to spot inside a longer error message; 0x7e is how the tilde character is written in hexadecimal, the numbering system SQL uses for such markers.
Step 3: read the database user and schema
Querying the database user and schema name returned [redacted] and joomladb. The database user is the account the website uses to talk to the database, and the schema is the named collection of tables it works in. Knowing both tells an attacker what identity the queries run under and where the data lives. The address shown is an internal container address.
Step 4: pull the administrator password hash in fragments
extractvalue() truncates its output at 32 characters, and the administrator bcrypt hash is 60 characters long. Truncates means cuts off; anything past the limit is lost. A bcrypt hash is the result of running a password through a one-way scrambling function. The site stores the hash, not the password, so a database thief does not get the password directly. It is 60 characters long here.
Because of the 32-character limit, the hash was pulled in 32-character fragments using SUBSTRING(), a SQL function that returns a piece of a longer piece of text starting at a position you choose. Stitching the fragments together yielded the full administrator username and bcrypt hash (admin:$2y$10$...), which an attacker could take offline and crack with commodity hardware. Taking it offline means copying the hash to the attacker's own machines and guessing passwords against it there, with no rate limits or alarms from the website. Commodity hardware means ordinary, affordable computers rather than specialised equipment.
Why the bug exists
The com_fields component constructs the ORDER BY clause of an internal query from the list[fullordering] request parameter without routing it through Joomla's standard input-filtering whitelist. The parameter is therefore attacker-controlled SQL syntax inside the query. The parameter was not routed through Joomla's standard input-filtering whitelist, so it reached the query unfiltered.
Two design factors turn the injection into a reliable exfiltration channel. First, the injection point is in ORDER BY, so UNION SELECT is not usable and error-based functions are the practical route. Second, default Joomla configurations display PHP and MySQL errors to the client, so the XPath parse error carries the extracted data back to the attacker. In everyday terms: the clerk was never given the approved list to check against, and the clerk's complaints are read aloud to whoever is standing at the counter.
What an attacker could do with it
The com_fields list view is reachable pre-login, and the CVSS metrics record No Privileges Required and No User Interaction Required. Any unauthenticated attacker on the public internet can use this single endpoint to read arbitrary data from the underlying database. In the lab this covered the database version, the database user and schema, and the administrator username and bcrypt hash. A stolen hash can be attacked offline with commodity hardware.
The fix, and proving it works
CVE-2017-8917 was officially patched in the Joomla 3.7.1 source release through rigorous input validation on the ordering parameter. Input validation means checking incoming values against what is expected and rejecting anything else, which is exactly the whitelist step that was missing.
Because Docker Hub publishes joomla:3.7.3 as the earliest accessible patched image tag containing the fix, the service definition in docker-compose.yml was updated from 3.7.0 to 3.7.3. Docker Hub is the public library of ready-made container images, and an image tag is the label that picks one exact version. The compose file is the text file that tells Docker which image to run, so changing the tag there is how you upgrade the target.
After pulling the patched container and resetting the database volume, re-running the exact same exfiltration request produced no output. Pulling means downloading the new image, and resetting the database volume means starting the database from a clean state so old data cannot confuse the result. The XPath error was gone, no database version was leaked, and the injection vector was fully sealed. Re-running the identical request is the important part: the only thing that changed was the software version, so the change in behaviour is attributable to the fix.
What defenders should watch for
Analysing real-world vulnerabilities highlights critical lessons for blue teams and security engineers. A blue team is the group responsible for defending systems, as opposed to the red team that attacks them. A single unvalidated parameter in a minor component can bypass authentication entirely and expose core database assets.
Defenders monitoring Apache access logs can spot exploitation attempts by searching for requests targeting index.php?option=com_fields where the list[fullordering] parameter contains SQL functions like extractvalue, updatexml, concat, or substring. An access log is the running record a web server keeps of every request it received. An unexpected spike in HTTP 500 error responses on this endpoint serves as an early indicator of automated probing; status code 500 means the server hit an internal error, which is what a failed injection attempt tends to produce.
Finally, Web Application Firewalls (WAFs) configured to reject non-integer or unexpected structural values within sorting parameters can neutralise vulnerabilities during the critical window between public disclosure and patch deployment. A WAF is a filter that sits in front of a website and inspects incoming requests, blocking ones that look malicious. The critical window is the period after a flaw becomes public knowledge but before the site owner has installed the official fix.

The image illustrates that point about WAFs: a firewall configured to reject non-integer or unexpected structural values in sorting parameters can neutralise the vulnerability during the window between public disclosure and patch deployment.
Variants to test
A positive result is a database error message containing the extracted value, or a visible change in the response title or body. A positive result is an XPath parse error that reflects the injected query result. A positive result is a complete value reconstructed from several error responses. A positive result is a cluster of such requests or errors from one source. A positive result is a blocked request rather than a database error.
Glossary
- Access log: the running record a web server keeps of every request it receives.
- Apache: a widely used web server program.
- Base URL: the fixed front part of a web address, shared by all requests in a test series.
- Bcrypt hash: the result of scrambling a password with the bcrypt one-way function; the site stores this instead of the password.
- Blue team: the people responsible for defending systems, as opposed to attacking them.
- Component: a self-contained module inside Joomla that provides one feature.
- Concatenate: to glue text onto the end of other text.
- Container: a packaged, self-contained copy of an application with everything it needs to run.
- CVE: a public reference number given to a known security flaw.
- CVSS: a standard scoring system for the severity of security flaws.
- curl: a command-line tool for sending web requests and showing exactly what is sent and received.
- Database: the organised store of information behind a website.
- Docker: a tool for running software in containers.
- Docker Compose: a tool that describes several containers in one file and starts them together.
- Docker Hub: the public library of ready-made container images.
- Endpoint: a specific address on a server that accepts requests.
- Error-based SQL injection: an attack that makes the database put the data you want inside an error message.
- Exfiltration: getting data out of a system.
- Glob range: a pattern such as
[1-5]that curl expands into several values unless told not to. - Hash: see bcrypt hash; a one-way scramble of a value.
- HTTP status code: a short number a server returns to describe the outcome of a request, such as 200 for success or 500 for an internal error.
- Image tag: the label that picks one exact version of a container image.
- Input validation: checking incoming values against what is expected and rejecting anything else.
- Kali Linux: a Linux distribution that ships with security tools.
- NAT: a networking mode where a virtual machine can reach out but has no reachable address on the real network.
- ORDER BY clause: the part of a SQL instruction that says how to sort results.
- Parameter: a named value sent along with a web request, usually visible in the address bar.
- PHP: the programming language Joomla is written in.
- Request: a message a browser or tool sends to a server asking for something.
- Schema: the named collection of tables a database user works in.
- Snapshot: a saved copy of an entire virtual machine at a moment in time.
- SQL: the language used to talk to most databases.
- SQL injection: pasting unchecked visitor input into a SQL instruction so that it becomes part of the command.
- SUBSTRING(): a SQL function that returns a piece of a longer piece of text.
- Truncate: to cut off anything past a limit.
- UNION SELECT: a SQL technique that appends a second query to the first and returns both results together.
- URL encoding: writing characters that are not allowed literally in a web address, such as
%5Bfor[. - Virtual machine (VM): a computer simulated inside your real computer by software.
- WAF (Web Application Firewall): a filter in front of a website that inspects incoming requests and blocks ones that look malicious.
- Whitelist: a list of values known to be acceptable; anything not on it is rejected.
- XPath: a way of pointing at a location inside a structured document, which MySQL functions such as
extractvalue()expect.