llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · kimai/kimai

GHSA-534C-HCR7-67JG

Kimai has an XXE Leading to Local File Read

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión2.21.0
Exposición794 dDesde la divulgación, 17 sept 2024, 1:36 p. m.
Detección790 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Monitoreo
Detectada
17 sept 24
5 dic 24
17 nov 26
21 nov 26
17 sept 24
4 abr 25
19 oct 25
6 may 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-534C-HCR7-67JG divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

### Summary
Kimai uses PHPSpreadsheet https://github.com/PHPOffice/PhpSpreadsheet for importing and exporting invoices. Recently, a CVE https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-ghg6-32f9-2jp7 was identified in PHPSpreadsheet, which could lead to an XXE vulnerability.

Details

Exploitation requires an Administrator account, allowing the upload of an `XLSX` template containing the payload. The vulnerability is triggered by the following code snippet:

// https://github.com/kimai/kimai/blob/b1903ba18359be16dd32ea9c40377c486498f082/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php#L41
public function render(InvoiceDocument $document, InvoiceModel $model): Response
{
    $spreadsheet = IOFactory::load($document->getFilename());
    $worksheet = $spreadsheet->getActiveSheet();
    $entries = $model->getCalculator()->getEntries();
    $sheetReplacer = $model->toArray();
    $invoiceItemCount = \count($entries);
    if ($invoiceItemCount > 1) {
        $this->addTemplateRows($worksheet, $invoiceItemCount);
    }
}

The `IOFactory::load` function utilizes `simplexml_load_string`, which has previously been demonstrated to be vulnerable to XXE attacks.

While this is not directly an XXE in Kimai, it does however impact the latest stable version.

PoC

By uploading a malicious `XLSX` template, the payload will be triggered every time an invoice is generated.

<?xml version="1.0" encoding='UTF-7' standalone="yes"?>
+ADw-!DOCTYPE foo [ <!ENTITY % xxe SYSTEM "php://filter/......." > %xxe;]>.....

For a better a visibility, I will upload both a:
- Malicious template sample for testing
- An exported invoice, showing the contents of target file during the export.

### Impact
Local File Read / RCE in edge cases where `phar://` can be utilized with gadget chains https://github.com/ambionics/phpggc .

export.xlsx https://github.com/user-attachments/files/16803913/export.xlsx
sample_template.xlsx https://github.com/user-attachments/files/16803916/sample_template.xlsx

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

Versiones

Rangos afectados

Afectada Corregida
kimai/kimai< 2.21.0
2.21.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistkimai/kimai
Corregida 2.21.0 — —
Versiones corregidas2.21.0
Explotación

Arsenal público

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

Referencias
Otrahttps://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-ghg6-32f9-2jp7
Otrahttps://github.com/kimai/kimai/security/advisories/GHSA-534c-hcr7-67jg
Otrahttps://github.com/kimai/kimai/commit/3204dcb03e1003dba90178667a4667ce3edb87b5
Otrahttps://github.com/kimai/kimai

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