Skip to content
Info disclosure Write-up Intermediate

Adminer Script Results to Pwning Server?, Private Bug Bounty Program

An exposed Adminer login page allowed an attacker to connect it to a MySQL server they controlled and use a local file read command to access files on the web server. This exposed Nginx configuration and Laravel database credentials, giving access to all databases, though the database user lacked FILE permission to write a shell.

Yashar Shahinzadeh Follow

Published on medium.com

{{media:0}}

Yasho, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Adminer is a single-file database administration tool, a lighter alternative to phpMyAdmin. When a copy of the adminer script is left reachable on a web server, the researcher's starting premise is that the server will most likely be compromised soon. This write-up describes a technique for exploiting an exposed adminer script without any valid credentials for it.

The target was a private bug bounty program. The researcher refers to the in-scope domain as milk.tld throughout.

Setup

No accounts, roles or software versions are given for the target. The tooling used during recon was:

  • sub-domain finders and assorted recon scripts;
  • wfuzz for directory and file name brute forcing;
  • a MySQL server the researcher controlled, reachable on a public IP address, with credentials he had set up himself.

The attack depends on that last item: the attacker needs a MySQL instance that the target's adminer can connect out to.

Finding it

Recon revealed several sub-domains. One of them, support, redirected the user to the main domain. The researcher ran a directory brute force against it with wfuzz using the following syntax:

Text
https://support.milk.tld/FUZZ

This surfaced a /login endpoint. Many vectors were tested on that page without finding a flaw. A subsequent file name brute force with wfuzz, using several word-lists, found a file named connect.php. Opening it revealed the adminer.php script.

The obvious next step, a brute force attack on the adminer login, was attempted and gained nothing.

Exploitation

The technique was inspired by two public articles on abusing MySQL LOCAL INFILE to read files and on SQL injection. The designed scenario had three stages:

  1. Setting up a MySQL server within a public IP address.
  2. Connecting adminer to that MySQL server, so the user is now logged in to adminer.
  3. Reading local files with the read data local infile command and inserting the results into a table.
Image for post
Image for post From the original on medium.com

Step 1: log in to adminer with attacker-controlled credentials

The adminer login form was filled with the address of the researcher's own MySQL server and the credentials he had configured beforehand. The login succeeded.

Image for post
Image for post From the original on medium.com

Step 2: read a local file through LOAD DATA LOCAL INFILE

The MySQL command used to read files from the client side is:

SQL
LOAD DATA LOCAL INFILE '/etc/passwd' INTO TABLE test.testFIELDS TERMINATED BY "\n"

LOAD DATA LOCAL INFILE makes the MySQL client read a file from the machine it runs on, which here is the web server hosting adminer, and send its contents to the server. The server in this case is the attacker's own MySQL instance, so the file contents land in the attacker's table test.testFIELDS, with lines separated by newlines.

The result:

Image for post
Image for post From the original on medium.com

The researcher now had the ability to read files as the mysql user.

Step 3: locate the Nginx site configuration

The next target was the Nginx configuration file. Each site has a configuration under /etc/nginx/sites-enabled/, but the filename was unknown. A list was built from the company name and brute forced. The file was found under a name derived from the domain with a single letter removed, and without the .conf extension:

Text
/etc/nginx/sites-enabled/mil.tld

The result:

Image for post
Image for post From the original on medium.com

Step 4: find the document root and the application's database credentials

The goal at this point was the root path. Reading index.php confirmed the portal was written with Laravel. Opening database.php revealed the connection credentials of the database.

Image for post
Image for post From the original on medium.com

Step 5: use the recovered credentials

With those credentials the researcher obtained all the databases they covered. Connecting to adminer with them gave access to the databases. The database user did not have the FILE permission, however, so uploading a shell script with an into outfile MySQL query was not possible.

Root cause

An adminer script was left reachable on the server, and adminer's login form accepts an arbitrary host, so an unauthenticated attacker can point the tool at a database server they control and authenticate against it. Once adminer is connected to the attacker's server, MySQL features that act on the client side, such as LOAD DATA LOCAL INFILE, run on the web server and return its files to the attacker. The report frames this as a design weakness relative to phpMyAdmin: adminer is less secure because it has a host field, which lets attackers run several pre-authentication attack scenarios, for example revealing the real IP address of servers behind CDNs such as Cloudflare.

Impact

Under the conditions shown here, an attacker who finds an exposed adminer script can read files on the server as the user running the database client, without any valid credentials for the target. In this case that yielded the Nginx site configuration, the document root, confirmation of the Laravel framework, and the application's database credentials, which in turn gave access to all databases those credentials covered. Writing a shell was blocked only because the database user lacked the FILE permission. The researcher's broader point is that a leftover adminer script may result in pwning the server in similar cases.

Fix

The report does not describe a fix or a vendor response.

Variants to test

  • Look for adminer or similar single-file database tools left behind under predictable names such as connect.php, and check whether the login form accepts an arbitrary host.
  • Point the tool at your own MySQL server and try LOAD DATA LOCAL INFILE against paths such as /etc/passwd; a positive result is the file's contents appearing in your table.
  • Brute force /etc/nginx/sites-enabled/ filenames derived from the company or domain name, including names with letters dropped and without the .conf extension; a positive result is a readable site configuration revealing the document root.
  • Read framework entry points and configuration files such as index.php and database.php from the document root; a positive result is framework confirmation and database credentials.
  • Reuse recovered database credentials against adminer and attempt into outfile; a positive result is a writable path, which fails if the user lacks the FILE permission.

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

What happened, in plain words

A security researcher was taking part in a private bug bounty program. A bug bounty program is an arrangement where a company invites selected researchers to look for security problems in its systems and report them, usually for a reward. "Private" means you have to be invited; the systems are not open to everyone.

During his search he found a leftover copy of a small program called adminer sitting on one of the company's web servers. Adminer is a database administration tool: a web page you open in your browser that lets you log in to a database server and run commands against it, look at tables, and so on. It is a lighter alternative to the better-known phpMyAdmin. The important thing about adminer is that it is a single file you drop on a web server, and its login form asks you not only for a username and password but also for the address of the database server you want to connect to.

That last detail is the whole story. The researcher did not have any valid credentials for the company's own database. Instead he set up his own database server on the internet, pointed the company's adminer at it, and logged in with credentials he had created himself. Adminer happily connected. From that moment the company's web server was talking to a database server controlled by the researcher, and certain database commands make the client side (here, the web server) read files from its own disk and send them over. That is how he read files on the company's server without ever having a password for it.

This article walks through the same steps he did, explaining each idea from scratch.

Some background before we start

A few concepts come up again and again, so here they are up front.

Web server. A computer whose job is to answer requests from browsers. When you type an address, your browser asks a web server for a page and the server sends it back.

Domain and sub-domain. A domain is the name of a site, like example.com. A sub-domain is a name placed in front of it, like support.example.com, which usually points at a different machine or a different part of the same site. In this story the researcher calls the in-scope domain milk.tld. The .tld part stands for "top-level domain", the ending of a name such as .com or .org; here it is a placeholder so the real company is not named.

Endpoint. A specific address on a server that does one thing, for example a login page or a search function. Think of a big office building: the domain is the building's address, an endpoint is a particular desk inside it.

Brute forcing. Trying many possibilities automatically, one after another, until something works. It is like trying every key on a big ring on a door, very fast, instead of guessing which one is right. It is used both for guessing passwords and for guessing file and folder names.

Word-list. A plain text file with one candidate per line (common folder names, common passwords, company-related names). Brute forcing tools read a word-list and try each entry.

wfuzz. A free command-line tool that does this kind of automated guessing against web addresses. You give it an address containing a placeholder, and it substitutes each word from a list into the placeholder and sends the request.

Database and MySQL. A database is an organised store of information, like a very large, very strict spreadsheet collection. MySQL is one popular brand of database server. A database server is the program that holds the data and answers questions about it.

Database client. The program that talks to a database server. Adminer is a client: it runs on the web server and connects out to a database server somewhere.

Credentials. The username and password (and sometimes the server address) needed to log in somewhere.

Authentication bypass. The general name for any trick that gets you past a login check without knowing the correct password. Here the bypass is not a flaw in a password check at all: the researcher logs in legitimately, just to his own server rather than the company's.

Nginx. A popular web server program. Its settings, including which folder holds a site's files, live in configuration files on disk.

Document root. The folder on the web server that holds the website's files. If you know it, you know where the site's code lives.

Laravel. A framework for building websites in the PHP programming language. A framework is a ready-made set of building blocks so developers do not write everything from scratch. Laravel sites have a recognisable structure and configuration files.

Shell / shell script. A small program that, once placed on a server and run, gives an attacker a way to send commands to that server. Getting one onto a machine is often the difference between reading files and fully controlling the machine. "Pwning" a server is informal slang for taking full control of it.

CDN (content delivery network). A service that sits in front of a website and serves it from many locations, also hiding the website's real server address. Cloudflare is a well-known example.

Recon: finding the pieces

The researcher started with recon, short for reconnaissance: gathering information about the target before attacking anything. He used sub-domain finders (tools that guess and check possible sub-domain names) and various scripts. This turned up several sub-domains. One of them was support, and visiting it simply redirected the browser to the main domain, so at first it looked uninteresting.

He then ran a brute force against that sub-domain with wfuzz, using this syntax:

Text
https://support.milk.tld/FUZZ

Line by line:

  • https:// is the normal prefix for a secure web address; your browser uses it every day.
  • support.milk.tld is the sub-domain he was looking at.
  • /FUZZ is the placeholder. FUZZ is the special word wfuzz replaces. For every entry in the word-list, wfuzz builds a full address such as https://support.milk.tld/admin or https://support.milk.tld/images and requests it.

Why do this? Because servers often have pages and folders that are not linked from anywhere visible. Guessing common names is a cheap way to discover them. A reply that says "not found" means the name does not exist; a different reply (a page, a redirect, a different error) means something is there.

This found a /login endpoint, a login page. He tested many inputs on that page (the term for the different kinds of input you can try is vectors) and found no flaw.

Next he ran a file name brute force with wfuzz, using several word-lists, this time looking for files rather than folders. That found an interesting file named connect.php. Opening it in the browser showed the adminer.php script. In other words, the file that was supposed to be a small connection helper was serving up the adminer login page.

The obvious next move is to try to guess the adminer login password by brute force. He did that and got nothing.

The idea: use adminer's own login form against it

He took inspiration from two public articles, one about abusing a MySQL feature called LOCAL INFILE to read files, and one about SQL injection (a classic flaw where user input is mixed into database commands). From those he designed a three-stage plan:

  1. Setting up a MySQL server within public IP address
  2. Connecting adminer to the MySQL server (now user has logged to adminer)
  3. Reading local files by read data local infile command, inserting the results in a table
Image for post
Image for post From the original on medium.com

Why does this work? Adminer's job is to connect to a database server. It does not insist that the server be the company's own. If the login form lets you type any address, you can type the address of a server you control. You then log in with credentials that are valid on your server, so the login succeeds. Adminer is now connected, and the web server hosting adminer is the client in that connection.

That matters because some MySQL commands are executed by the client, not the server. The client is told "read this file from your own disk and send me the contents". The client here is the company's web server. So the file comes from the company's disk and is sent to the researcher's database server, where it is stored in a table he can read.

The attack, step by step

Step 1: log in to adminer with your own credentials

He filled the adminer login form with the address of his own MySQL server and the credentials he had set up beforehand. The login succeeded.

Image for post
Image for post From the original on medium.com

Notice what did not happen: no password of the company was guessed, no flaw in a password check was exploited. The login was genuine, just against the wrong server from the company's point of view.

Step 2: read a file from the web server

The MySQL command used to read files from the client side is:

SQL
LOAD DATA LOCAL INFILE '/etc/passwd' INTO TABLE test.testFIELDS TERMINATED BY "\n"

Line by line:

  • LOAD DATA is MySQL's command for loading data into a table, normally from a file.
  • LOCAL is the crucial word. It tells the client, not the server, to read the file. Without it, the server would look for the file on its own disk.
  • INFILE '/etc/passwd' names the file to read. /etc/passwd is a standard file on Linux systems that lists user accounts. It is a common first target because it is almost always present and readable, and it proves whether file reading works at all.
  • INTO TABLE test.testFIELDS says where to put the contents: a table called testFIELDS in a database called test, on the researcher's own server.
  • TERMINATED BY "\n" says each line of the file ends at a newline character, so the file's lines become rows in the table.

The result:

Image for post
Image for post From the original on medium.com

He could now read files as the mysql user. That account's permissions decide which files are readable, which is why the next steps focus on files that account can open.

Step 3: find the web server's configuration file

His next target was the Nginx configuration file. Every site has a configuration under /etc/nginx/sites-enabled/, but he did not know the file's name. So he built a list of candidate names from the company name and brute forced them, the same guessing technique as before, just applied to file names instead of web addresses.

He found it. The name was mil.tld: the domain with a single letter removed, and with no .conf extension:

Text
/etc/nginx/sites-enabled/mil.tld

Why bother? Because a site configuration tells you where the website's files live (the document root) and how the site is wired up. It is a map for the next step.

The result:

Image for post
Image for post From the original on medium.com

Step 4: find the document root and the database password

What he wanted was the root path, the document root. Reading index.php, the usual entry file of a PHP site, confirmed the portal was written with Laravel. Opening database.php, a Laravel configuration file, revealed the connection credentials of the database.

Image for post
Image for post From the original on medium.com

Why does this matter so much? Because application configuration files often contain the username and password the website itself uses to talk to its database. Those are real credentials for the company's own systems, obtained without ever attacking a login form.

Step 5: use the recovered credentials

With those credentials he could reach all the databases they covered. He connected to adminer with them and had the databases. One thing did not work: the database user did not have the FILE permission, a MySQL privilege that allows reading and writing files on the database server's disk. Without it, uploading a shell script with an into outfile query (a MySQL command that writes query results to a file) was not possible.

So the chain stopped one step short of full control in this case. The researcher's main point is broader: an adminer script left on a server may well result in pwning that server in similar situations.

Why adminer is riskier than phpMyAdmin

He compares adminer with phpMyAdmin and argues adminer is less secure because its login form has a host field, the box where you type the database server's address. That single field lets an attacker run several attack scenarios before authenticating to anything of the target's: you authenticate to your own server, and the target's server does the work for you. One example he gives is revealing the real IP address of servers hidden behind CDNs such as Cloudflare. A CDN hides the origin server; if a tool on the origin can be made to connect out to an address you control, the connection comes from the origin's real address, which can give it away.

What to take away

  • A leftover adminer file is not a small thing. It is a login page that will connect to any database server you name.
  • Guessing names (folders, files, configuration files) is cheap and often enough to find what was meant to stay hidden.
  • Configuration files are valuable because they contain paths and passwords.
  • The database user lacked the FILE permission, so uploading a shell script with an into outfile query was not possible here.

Glossary

  • Adminer: a single-file web tool for administering a MySQL database from a browser; a lighter alternative to phpMyAdmin.
  • Authentication bypass: getting past a login check without the correct password.
  • Brute force: automatically trying many possibilities until one works.
  • Bug bounty program: an arrangement where a company invites researchers to find and report security problems, often for a reward; a private one is invitation-only.
  • CDN (content delivery network): a service in front of a website that serves it from many locations and can hide the real server's address.
  • Cloudflare: a well-known CDN provider.
  • Credentials: the username and password (and sometimes server address) used to log in.
  • Database: an organised store of data, managed by a database server.
  • Database client: the program that connects to and talks with a database server.
  • Document root: the folder on a web server that holds a website's files.
  • Domain: the name of a site, such as example.com.
  • Endpoint: a specific address on a server that performs one function, such as a login page.
  • FILE permission: a MySQL privilege that allows a database user to read and write files on the database server's disk.
  • Framework: a ready-made set of building blocks for developing software, such as Laravel for PHP.
  • Host field: the input on a login form where you type the address of the database server to connect to.
  • into outfile: a MySQL command that writes query results to a file on the database server's disk.
  • Laravel: a popular framework for building websites in PHP.
  • LOAD DATA LOCAL INFILE: a MySQL command that makes the client read a file from its own machine and load the contents into a table on the server.
  • MySQL: a popular database server program.
  • Nginx: a popular web server program whose settings live in configuration files on disk.
  • PHP: a programming language widely used for websites.
  • phpMyAdmin: a well-known web tool for administering MySQL databases.
  • Private bug bounty program: a bounty program open only to invited researchers.
  • Pwning: informal slang for taking full control of a machine.
  • Recon (reconnaissance): gathering information about a target before attacking it.
  • Shell / shell script: a small program that, once on a server, lets an attacker run commands on it.
  • SQL injection: a flaw where user input is mixed into database commands, letting an attacker change those commands.
  • Sub-domain: a name placed in front of a domain, such as support.example.com.
  • TLD (top-level domain): the ending of a domain name, such as .com or .org.
  • Vector: a particular kind of input or technique tried against a target.
  • wfuzz: a command-line tool for automated guessing against web addresses, using a placeholder and a word-list.
  • Word-list: a text file with one candidate per line, used by brute forcing tools.

More by Yashar Shahinzadeh

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.