GHSA-534c-hcr7-67jg: Kimai/kimai Kimai Has An XXE Leading Vulnerability

HIGH
CVSS 6.5
CWE-1395 CWE-611
Published
Advisory Summary

GHSA-534c-hcr7-67jg is a HIGH (CVSS 6.5) kimai has an xxe leading vulnerability (CWE-1395: Dependency on Vulnerable Third-Party Component) affecting Kimai/kimai libraries in the Packagist ecosystem. The issue involves kimai has an xxe leading to local file read. Remediation is available by upgrading affected packages to version 2.21.0.

GHSA-534c-hcr7-67jg at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-534c-hcr7-67jg
Severity HIGH
CVSS v3.1 Base Score 6.5
CWE Classification CWE-1395: Dependency on Vulnerable Third-Party Component
Affected Product Kimai/kimai
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix GHSA-534c-hcr7-67jg

To remediate this vulnerability, upgrade all affected Kimai/kimai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

kimai/kimai fixed: 2.21.0
Upgrade kimai/kimai to 2.21.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for kimai/kimai

How to Check if You Are Affected

To determine whether your application is affected by GHSA-534c-hcr7-67jg, inspect your project dependencies for Kimai/kimai:

inspect dependencies for kimai/kimai

Analyze the terminal output to locate any version of Kimai/kimai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.21.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1395: Dependency on Vulnerable Third-Party Component, where the product has a dependency on a third-party component that contains one or more known vulnerabilities. In Kimai/kimai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```php // 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 <?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)

GHSA-534c-hcr7-67jg Affected Kimai/kimai Versions

1 component(s)
Fixed Versions:
2.21.0
Product / Package Ecosystem Affected Versions Fixed Version
kimai/kimai
Packagist
< 2.21.0
2.21.0

References

Frequently Asked Questions

What is GHSA-534c-hcr7-67jg?
GHSA-534c-hcr7-67jg is a security vulnerability in Kimai/kimai involving Kimai has an XXE Leading to Local File Read under CWE-1395: Dependency on Vulnerable Third-Party Component.
Which Kimai/kimai versions are affected?
Affected versions include releases prior to 2.21.0 across affected packages: kimai/kimai.
What version fixes GHSA-534c-hcr7-67jg?
Upgrading to 2.21.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is kimai/kimai affected?
Yes, kimai/kimai is affected in releases prior to 2.21.0. Upgrade your dependency to 2.21.0 or later.
What is the CVSS score of GHSA-534c-hcr7-67jg?
GHSA-534c-hcr7-67jg has a CVSS v3.1 base score of 6.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with GHSA-534c-hcr7-67jg?
GHSA-534c-hcr7-67jg is classified under CWE-1395: Dependency on Vulnerable Third-Party Component (The product has a dependency on a third-party component that contains one or more known vulnerabilities.).
How can I check Packagist dependencies for GHSA-534c-hcr7-67jg?
Run the dependency tree command: 'inspect dependencies for kimai/kimai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-534c-hcr7-67jg",
  "modified" : "2024-11-14T17:45:16Z",
  "published" : "2024-09-17T18:36:50Z",
  "aliases" : [ ],
  "summary" : "Kimai has an XXE Leading to Local File Read",
  "details" : "### Summary\nKimai 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.\n\n\n### Details\n\nExploitation requires an Administrator account, allowing the upload of an `XLSX` template containing the payload. The vulnerability is triggered by the following code snippet:\n\n```php\n// https://github.com/kimai/kimai/blob/b1903ba18359be16dd32ea9c40377c486498f082/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php#L41\npublic function render(InvoiceDocument $document, InvoiceModel $model): Response\n{\n    $spreadsheet = IOFactory::load($document->getFilename());\n    $worksheet = $spreadsheet->getActiveSheet();\n    $entries = $model->getCalculator()->getEntries();\n    $sheetReplacer = $model->toArray();\n    $invoiceItemCount = \\count($entries);\n    if ($invoiceItemCount > 1) {\n        $this->addTemplateRows($worksheet, $invoiceItemCount);\n    }\n}\n```\n\nThe `IOFactory::load` function utilizes `simplexml_load_string`, which has previously been demonstrated to be vulnerable to XXE attacks.\n\nWhile this is not directly an XXE in Kimai, it does however impact the latest stable version.\n\n \n### PoC\n\nBy uploading a malicious `XLSX` template, the payload will be triggered every time an invoice is generated.\n\n```xml\n<?xml version=\"1.0\" encoding='UTF-7' standalone=\"yes\"?>\n+ADw-!DOCTYPE foo [ <!ENTITY % xxe SYSTEM \"php://filter/.......\" > %xxe;]>.....\n```\n\nFor a better a visibility, I will upload both a:\n- Malicious template sample for testing \n- An exported invoice, showing the contents of target file during the export. \n\n### Impact\nLocal File Read / RCE in edge cases where `phar://` can be utilized with [gadget chains](https://github.com/ambionics/phpggc) . \n\n\n[export.xlsx](https://github.com/user-attachments/files/16803913/export.xlsx)\n[sample_template.xlsx](https://github.com/user-attachments/files/16803916/sample_template.xlsx)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "kimai/kimai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.21.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.20.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-ghg6-32f9-2jp7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kimai/kimai/security/advisories/GHSA-534c-hcr7-67jg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kimai/kimai/commit/3204dcb03e1003dba90178667a4667ce3edb87b5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/kimai/kimai"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1395", "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-17T18:36:50Z",
    "nvd_published_at" : null
  }
}