GHSA-3582-Q6XQ-5VF7
ZDI-CAN-28201: multi_query Incorrect Check of Function Return Value RCE
CVSS:3.1/AV:N/AC:L/PR:H/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-3582-Q6XQ-5VF7 divulgada · CVSS 7.2 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Please find POC file here: https://trendmicro-my.sharepoint.com/:u:/p/kholoud_altookhy/IQBt0UYzTjHZSY2R8IXw4E9AARuTRVuLsHDDRfq53VcE_jQ?e=c8hZ6W
ZDI-CAN-28201: Adminer multi_query Incorrect Check of Function Return Value Remote Code Execution Vulnerability
-- CVSS -----------------------------------------
7.2: AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
-- ABSTRACT -------------------------------------
Trend Micro's Zero Day Initiative has identified a vulnerability affecting the following products:
Adminer - Adminer
-- VULNERABILITY DETAILS ------------------------
* Version tested: 5.4.2
* Installer file: adminer-5.4.2.php
* Platform tested: Debian
---
Analysis
This vulnerability is a patch bypass that exploits catastrophic backtracking in a regular expression used to filter ATTACH statements in Adminer's SQLite functionality. The original vulnerability (CVE-2021-43008) allowed authenticated users to create PHP files through SQLite ATTACH statements, achieving remote code execution. The patch introduced a regex filter to block ATTACH queries, but this filter is vulnerable to catastrophic backtracking.
[Source] sql.inc.php :: SQL import handler:39
$query = get_file("sql_file", true, ";");> User uploads a malicious SQL file through the import form. The file content is read into the $query variable without any initial sanitization.
[Transform] sql.inc.php :: SQL import handler:67
// Query parsing loop that extracts individual SQL statements> The uploaded SQL content is processed in a loop that splits it into individual queries. Each query $q is extracted for processing.
[Context] sql.inc.php :: SQL import handler:105
$space = "(?:\\s|/\\*[\\s\\S]*?\\*/|(?:#|$line_comment)[^\\n]*\\n?|--\\r?\\n)";> Definition of the $space regex pattern used in the ATTACH filter. The possessive quantifier *+ combined with SQLite comment patterns (--) creates the catastrophic backtracking vulnerability when many comment lines are processed.
[Transform] sql.inc.php :: SQL import handler:108
if (JUSH == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {> The ATTACH query filter check. When the regex encounters 350,000 SQLite comment lines (--), it triggers catastrophic backtracking. The possessive quantifier *+ causes exponential backtracking, eventually hitting PHP's backtracking limit and causing preg_match() to return false instead of 0 or 1, bypassing the security filter.
[Sink] sql.inc.php :: SQL import handler:125
connection()->multi_query($q)> When the ATTACH filter is bypassed due to the preg_match() returning false, the malicious SQL query containing the ATTACH statement is executed. This allows the attacker to create a .php file with embedded PHP code, achieving remote code execution when the file is accessed via HTTP.
The root cause is that PHP's `preg_match()` function returns `false` when the backtracking limit is exceeded, but the code only checks for truthy values (1 for match), treating `false` the same as 0 (no match). This allows the ATTACH statement to bypass the security filter.
Proof of Concept
The ZDI-CAN-28201.zip archive contains a complete proof-of-concept environment including:
- `adminer/` folder: Complete Adminer setup with necessary plugins and configuration
- `adminer/adminer.php`: The vulnerable Adminer application (version 5.4.2)
- `adminer/php.ini`: PHP configuration file enabling SQLite extension
- `adminer/adminer-plugins/`: Directory containing the login-password-less.php plugin
- `adminer/adminer-plugins.php`: Plugin configuration file with password hash for 'password123'
- `ZDI-CAN-28201_poc.php`: Exploit generator script
Setup Instructions:
1. Place the provided `adminer` folder on a Debian machine
2. Configure SQLite password setup as included in the adminer-plugins.php (password: 'password123')
3. From inside the adminer folder, run: `php -c php.ini -S localhost:8000`
4. Use ZDI-CAN-28201_poc.php to generate exploit.sql: `php ZDI-CAN-28201_poc.php > exploit.sql`
Exploitation Steps:
1. Navigate to `http://localhost:8000/adminer.php`
2. Select SQLite as the database system
3. Enter password 'password123' (configured in adminer-plugins.php)
4. Go to the "import" section in the left sidebar
5. Upload the generated exploit.sql file
6. Click "Execute"
7. On success, the system displays "3 queries executed OK"
8. A file named `lol.php` is created in the adminer directory containing PHP code
9. Visiting `http://localhost:8000/lol.php` executes the embedded PHP code
The exploit works by generating approximately 350,000 SQLite comment lines (`--`) followed by the malicious ATTACH statement. The excessive number of comment lines causes the regex engine to hit PHP's backtracking limit, making `preg_match()` return `false` instead of 0 or 1, thus bypassing the ATTACH filter and allowing the malicious SQL to execute.
-- CREDIT ---------------------------------------
This vulnerability was discovered by:
0daystolive (Sorcery Ltd) working with TrendAI Zero Day Initiative
-- FURTHER DETAILS ------------------------------
Supporting files:
If supporting files were contained with this report they are provided within a password protected ZIP file. The password is the ZDI candidate number in the form: ZDI-CAN-XXXX where XXXX is the ID number.
Please confirm receipt of this report. We expect all vendors to remediate ZDI vulnerabilities within 120 days of the reported date. If you are ready to release a patch at any point leading up to the deadline, please coordinate with us so that we may release our advisory detailing the issue. If the 120-day deadline is reached and no patch has been made available we will release a limited public advisory with our own mitigations, so that the public can protect themselves in the absence of a patch. Please keep us updated regarding the status of this issue and feel free to contact us at any time:
Zero Day Initiative
zdi-disclosures@trendmicro.com
The PGP key used for all ZDI vendor communications is available from:
http://www.zerodayinitiative.com/documents/disclosures-pgp-key.asc
-- INFORMATION ABOUT THE ZDI --------------------
Established by TippingPoint and acquired by Trend Micro, the Zero Day Initiative (ZDI) neither re-sells vulnerability details nor exploit code. Instead, upon notifying the affected product vendor, the ZDI provides its Trend Micro TippingPoint customers with zero day protection through its intrusion prevention technology. Explicit details regarding the specifics of the vulnerability are not exposed to any parties until an official vendor patch is publicly available.
Please contact us for further details or refer to:
http://www.zerodayinitiative.com
-- DISCLOSURE POLICY ----------------------------
Our vulnerability disclosure policy is available online at:
http://www.zerodayinitiative.com/advisories/disclosure_policy/
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Versiones afectadas
5.4.2Estado 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-3582-q6xq-5vf7Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
