GHSA-75XM-QWFQ-9WP5
Arbitrary .sql file write via unvalidated ns in sql-log plugin
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-75XM-QWFQ-9WP5 divulgada · CVSS 5.4 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The bundled `sql-log` plugin builds its log file path from the request parameter `$_GET["ns"]` without sanitization (`plugins/sql-log.php:29`), then opens that path for appending (`plugins/sql-log.php:31`) and writes each executed query verbatim (`plugins/sql-log.php:33`). The `ns` parameter is the PostgreSQL schema selector and is normally validated by `set_schema()`, but that validation is gated on a database being selected. When the user is logged in with no database selected, `database()` returns an empty string, `ns` is never checked, and the concatenation `"" . ".$_GET[ns]" . ".sql"` places the entire path under attacker control.
An authenticated user submits any SQL query with a traversal sequence in `ns`. The plugin writes an attacker-named `.sql` file, containing attacker-controlled content, to any directory writable by the Adminer process. Adminer connects to any host on ports 1024 and above, so the attacker supplies their own database server and their own credentials to obtain the session; access to the operator's database is not required.
Result: any user who can log in to an Adminer instance running the `sql-log` plugin writes arbitrary `.sql` files with controlled content to arbitrary writable paths on the Adminer host.
Affected
vrana/adminer, `sql-log` plugin, v5.3.0 through v5.4.2 (current latest as of 2026-07-04). The vulnerable line is byte-identical on `master` HEAD. The `$_GET[ns]` concatenation was introduced on 2025-04-15 (commit 45799f460, "AdminerSqlLog: Store schema"), first shipped in v5.3.0.
Condition: the `sql-log` plugin is enabled (official Docker image: environment variable `ADMINER_PLUGINS=sql-log`, which generates `return new AdminerSqlLog();` with the default empty filename).
Not affected: default installs without the `sql-log` plugin; versions before v5.3.0.
Root cause
`plugins/sql-log.php:29` sets the log filename to `Adminer\adminer()->database() . ($_GET["ns"] != "" ? ".$_GET[ns]" : "") . ".sql"`, taking `$_GET["ns"]` directly into a filesystem path. The only validation of `ns`, `set_schema()`, is reached only through the block guarded by `DB != "" && $_GET["ns"] !== ""` at `include/connect.inc.php:120`, so with no database selected that block is skipped and `ns` reaches the sink unvalidated. `database()` then returns an empty string, collapsing the prefix to a single `.`, so a value such as `ns=/../../../tmp/x` resolves to an absolute path outside the web root. The file is opened in append mode (`plugins/sql-log.php:31`) and each executed query is written to it verbatim (`plugins/sql-log.php:33`), giving the attacker control over both the path and the file content.
Reproduction
Official `adminer:5.4.2` Docker image, PHP 8.4.23, started with `ADMINER_PLUGINS=sql-log`. The attacker uses a MySQL server they control.
- Log in with the driver's credentials and leave the database field empty.
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
auth[driver]=server&auth[server]=<attacker-db-host>&auth[username]=<user>&auth[password]=<pw>&auth[db]=HTTP/1.1 302 Found
Location: ?server=<attacker-db-host>&username=<user>- Submit any query with a path-traversal sequence in the `ns` query-string parameter.
POST /?server=<attacker-db-host>&username=<user>&sql=&ns=/../../../tmp/adminer_pwn HTTP/1.1
Content-Type: application/x-www-form-urlencoded
query=SELECT 'LFI_F1_PROOF -- attacker controls this content'&token=<csrf>HTTP/1.1 200 OK- Read the written file inside the container.
$ cat /tmp/adminer_pwn.sql
SELECT 'LFI_F1_PROOF -- attacker controls this content'Live-verified: the `.sql` file is created outside the web root with byte-exact attacker content. A null byte (`ns=.../x.php%00`) does not escape the `.sql` suffix; PHP 8.4 rejects it and no file is written.
Impact
- Arbitrary `.sql` file creation and append at any path writable by the Adminer process (uid 100), with attacker-controlled content.
- Disk-exhaustion denial of service through unbounded appends.
- Second-order SQL execution when an operator imports a poisoned `.sql` file via the "from server" import.
- Triggered by any authenticated user with a self-supplied database; no operator-database access and no administrative role required.
Credit
Jan Kahmen, turingpoint https://www.turingpoint.de (jan@turingpoint.de)
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-75xm-qwfq-9wp5Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
