GHSA-V58R-XG67-JJ45
SQL Injection in admin/language/write.php via dirlang parameter (column-position concat)
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:L/A:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-V58R-XG67-JJ45 divulgada · CVSS 4.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`admin/language/write.php` concatenates the `dirlang` GET parameter directly into the column list of two `SELECT` statements without validating it. `dirlang` only passes through `Request::get_title()` (`strip_tags()` plus, in this call, no entity encoding) and is never checked against the `^[a-z]{2}$` pattern that every other operation in the language module enforces. Arbitrary SQL expressions can therefore be appended to the selected columns and executed.
Exploitation requires an authenticated God Admin session. See *Attack prerequisites* below — this is the reason the advisory is not rated higher.
Affected code
Both sinks are inside `nv_admin_write_lang()`:
// admin/language/write.php:27
list($module, $admin_file, $langtype, $author_lang) =
$db->query('SELECT module, admin_file, langtype, author_' . $dirlang
. ' FROM ' . NV_LANGUAGE_GLOBALTABLE . '_file WHERE idfile =' . (int) $idfile)->fetch(3);
// admin/language/write.php:97
$result = $db->query('SELECT langtype, lang_key, lang_' . $dirlang
. ' FROM ' . NV_LANGUAGE_GLOBALTABLE . ' WHERE idfile=' . $idfile
. ' ORDER BY langtype ASC, id ASC');The `idfile,checksess` branch that reaches this code performs no validation on `dirlang`, while the sibling `writeallfile` branch in the same file already does:
// admin/language/write.php:167
if ($dirlang != '' and preg_match('/^([a-z]{2})$/', $dirlang)) {The same check is present in `delete.php`, `download.php`, `edit.php`, `interface.php` and `read.php`. `write.php` was the only operation in the module missing it.
The `$page_title = $language_array[$dirlang]['name'];` lookup that precedes the vulnerable branch does not block the request: it raises `E_WARNING`, and the error handler only terminates on `E_USER_ERROR`.
Attack prerequisites
`op=write` is registered only for God Admin accounts, and only when the installation is not a sub-site:
// admin/language/functions.php
if (empty($global_config['idsite'])) {
...
if (defined('NV_IS_GODADMIN')) {
$allow_func[] = 'setting';
$allow_func[] = 'write';
$allow_func[] = 'delete';
}
}This is enforced in `admin/index.php` by `in_array($op, $allow_func, true)`, which returns 404 otherwise. A regular administrator cannot reach the vulnerable code.
The request also requires `checksess = md5($idfile . NV_CHECK_SESSION)`, where `NV_CHECK_SESSION = md5(NV_CACHE_PREFIX . session_id)`. These tokens are rendered on the `op=interface` page, which requires the same God Admin privilege. Because the token is unpredictable to a third party, there is no practical cross-site request forgery chain against this endpoint, despite `GET` requests not being subject to the Referer/Origin check applied to `POST`.
Proof of concept
Against a lab instance with `idfile=37` (one row in `nv_language`), authenticated as God Admin:
# baseline
time curl -s -G -b /tmp/nv_admin.txt --max-time 25 \
--data-urlencode "language=en" --data-urlencode "nv=language" --data-urlencode "op=write" \
--data-urlencode "idfile=37" --data-urlencode "checksess=<token>" \
--data-urlencode "dirlang=en" \
"http://127.0.0.1:8088/admin/index.php"
# => 200, ~0.02s
# payload
time curl -s -G -b /tmp/nv_admin.txt --max-time 25 \
--data-urlencode "language=en" --data-urlencode "nv=language" --data-urlencode "op=write" \
--data-urlencode "idfile=37" --data-urlencode "checksess=<token>" \
--data-urlencode "dirlang=en,(SELECT SLEEP(4))" \
"http://127.0.0.1:8088/admin/index.php"
# => 200, ~8.0s (two SELECTs x SLEEP(4) x one row)Boolean-based and error-based variants are also viable; an invalid expression produces a 500 with the SQL error rendered by XTemplate.
Note that payloads must be quote-less: `Request::security_get()` converts `'` and `"` to HTML entities before the value reaches the query. This does not prevent extraction — subqueries, `SUBSTRING`/`ASCII` comparisons and hex literals all work without quotes — but it does rule out string literals.
Impact
An attacker who already holds a God Admin session can read any table the database user can `SELECT`. Both sinks are `SELECT` only, so no rows can be written or deleted through them.
The practical impact is limited by the privilege required. A God Admin can already read the same data through the administration interface, and can already write arbitrary PHP to disk through the `file_put_contents()` call in this very script. The vulnerability therefore grants no capability that the attacker does not already possess, and does not enable privilege escalation. It is being fixed because the missing validation is inconsistent with the rest of the module and because defence in depth should not rely on the `$allow_func` restriction remaining unchanged.
Path traversal (not exploitable)
`dirlang` is also concatenated into the language file path passed to `file_put_contents()`. This is not exploitable: `Request::security_get()` strips `../` from all GET values, and a payload containing `.` would in any case fail the query at line 27 before the write is reached.
Patch
Validation is applied at two points. At the entry point, before `$page_title` and before either `nv_mkdir()` call, so that every branch of the script is covered:
if (!preg_match('/^([a-z]{2})$/', $dirlang) or !isset($language_array[$dirlang])) {
nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=main');
}And inside `nv_admin_write_lang()` itself, so that future callers cannot reintroduce the issue:
if (!preg_match('/^([a-z]{2})$/', $dirlang) or !isset($language_array[$dirlang])) {
return $lang_module['nv_error_exit_module'];
}`$language_array` is loaded from `includes/ini/langs.ini` in `admin/language/functions.php` and contains every language known to NukeViet, not only the installed ones, so validating against it does not prevent adding a new language.
Affected versions
All 4.x releases. The pattern dates back to commit `dc6b42a` (2015).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Versiones afectadas
4.5.064.5.114.6.004.6.01Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistnukeviet/nukeviet |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/nukeviet/nukeviet/security/advisories/GHSA-v58r-xg67-jj45Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
