GHSA-H9G9-73C3-23C9
Admin plugin "Save As" writes .md files outside the pages tree via unvalidated language code
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-H9G9-73C3-23C9 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
1. Summary
The Grav admin "Save As" action (taskSaveas) builds the destination page-file path from the attacker-controlled
POST field data[lang] without validation. determineFilenameIncludingLanguage() embeds the raw lang into
<name>.<lang>.md, concatenated onto the page directory and written via RocketTheme Toolbox File::save() /
Page::save(). A lang value containing ../ traverses out of the pages tree, and the page content is fully
attacker-controlled via preparePage() (frontmatter+content) → an authenticated arbitrary-location write
of a .md file with attacker-controlled bytes.
2. Affected Version & Scope
Repositories: https://github.com/getgrav/grav (core @ fa1c20a) + https://github.com/getgrav/grav-plugin-admin.
Preconditions: an authenticated admin user with admin.pages.create (not necessarily super-admin) and a
valid admin-nonce. No non-default config required.
3. Recon → Discovery (Methodology)
3a. Recon. NEXT-TARGETS2 CMS seam (Grav = flat-file PHP; admin file-write/upload/YAML/SSTI paths are the
classic bug source). Enumerated the admin task* handlers and their file-writing sinks.
3b. Discovery. A sink-sweep found that taskFilesUpload/taskAddmedia/taskDelmedia/taskBackup all run
their filename through Utils::checkFilename (which rejects ../slashes/dangerous extensions), but
taskSaveas does not. Tracing data[lang] → determineFilenameIncludingLanguage showed the raw lang is
embedded into the filename with only an in_array($lang, languages_enabled) check that merely decides
suffix-stripping — it does not reject a traversal value. preparePage confirmed the written content is fully
attacker-controlled.
4. Environment Setup (Reproduce From Zero)
git clone --depth=1 https://github.com/getgrav/grav src && (cd src && git checkout fa1c20a)
git clone --depth=1 https://github.com/getgrav/grav-plugin-admin src/user/plugins/admin
# serve Grav locally (php -S), create an admin user, log in to /admin, obtain a valid admin-nonce, then send §6.
5. Technical Details & Root Cause
// admin/classes/plugin/AdminController.php — taskSaveas()
1728: if (!$this->authorizeTask('save as', ['admin.pages','admin.pages.create','admin.super'])) return false;
1736: $lang = $data['lang'] ?? null; // ATTACKER POST, UNVALIDATED
1746: $this->preparePage($obj, false, $lang); // applies POST frontmatter/content to $obj
1748: $filename = $this->determineFilenameIncludingLanguage($obj->name(), $lang);
1750: $path = $obj->path() . DS . $filename; // pageDir + "/" + <name>.<lang>.md
1751: $aFile = File::instance($path); $aFile->save(); // writes to LITERAL path (no ../ normalization)
1765: $aPage->init(new SplFileInfo($path), $lang.'.md'); ... $aPage->save(); // writes attacker content
// determineFilenameIncludingLanguage($current_filename, $language) ~ :2975
$ext='.md'; $filename = substr($current_filename,0,-3); // "default.md" -> "default"
$parts=explode('.',trim($filename,'.')); $lang=array_pop($parts);
if ($lang === $language) return $filename.$ext;
if (in_array($lang,$languages_enabled,true)) $filename=implode('.',$parts); // only strips a real-lang suffix
return $filename . '.' . $language . $ext; // raw $language -> "default./../../../../tmp/pwn.md"
// preparePage() ~ :41 — attacker controls the ENTIRE page content
if (isset($input['frontmatter'],$input['content']))
$page->raw("---\n".(string)$input['frontmatter']."\n---\n".(string)$input['content']);
Root cause: lang is used as a filesystem path component with no Utils::checkFilename/allowlist rejection;
the only in_array check governs suffix-stripping, not validity. The File/Page save writes to the literal
(traversed) path
6. Proof of Concept (Embedded Replication Code)
6a. Reproduction — numbered steps
Authenticate to /admin as a user with admin.pages.create; obtain a valid admin-nonce.
Send the request in §6c against an existing page route.
Observed: <pages>/<page>/default./../../../../../../tmp/pwn.md resolves to /tmp/pwn.md, written with
the attacker frontmatter+content.
if possible plesae provide the CVE accordingly.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav-plugin-admin |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getgrav/grav/security/advisories/GHSA-h9g9-73c3-23c9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
