{"answers":{"affected":"2 open source packages ship an affected version, including kimai/kimai.","exploited":"There is no known exploitation of GHSA-534c-hcr7-67jg in the wild and no public exploit code.","fix":"Upgrade kimai/kimai to 2.21.0 or later.","what":"GHSA-534c-hcr7-67jg is a vulnerability in kimai/kimai, published on 17 Sep 2024. An attacker needs administrator access to exploit it, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for GHSA-534c-hcr7-67jg and fix it if it is affected.\n\nWhat it is: GHSA-534c-hcr7-67jg is a vulnerability in kimai/kimai, published on 17 Sep 2024. An attacker needs administrator access to exploit it, and only if a user opens a file or follows a link.\nExploitation: There is no known exploitation of GHSA-534c-hcr7-67jg in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- kimai/kimai (Packagist): affected all versions; fixed in 2.21.0\n- kimai/kimai (Packagist): affected all versions; fixed in 2.21.0\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-534c-hcr7-67jg/ (Markdown: https://insights.sbomify.com/GHSA-534c-hcr7-67jg/index.md)","id":"GHSA-534c-hcr7-67jg","markdown":"https://insights.sbomify.com/GHSA-534c-hcr7-67jg/index.md","name":"GHSA-534c-hcr7-67jg","record":{"aliases":[],"analysis":{"component_type":"web_application","fix_type":"upgrade","impacts":["data_read","code_execution"],"network_reachable":"yes","non_default_config":false,"product_category":"Kimai time tracking","requires_auth":"high_privilege","summary":"An administrator can upload a malicious XLSX template to trigger XXE, allowing local file read or potential remote code execution.","user_interaction":"required","vuln_class":"xxe"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"### 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### 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-\u003egetFilename());\n    $worksheet = $spreadsheet-\u003egetActiveSheet();\n    $entries = $model-\u003egetCalculator()-\u003egetEntries();\n    $sheetReplacer = $model-\u003etoArray();\n    $invoiceItemCount = \\count($entries);\n    if ($invoiceItemCount \u003e 1) {\n        $this-\u003eaddTemplateRows($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\u003c?xml version=\"1.0\" encoding='UTF-7' standalone=\"yes\"?\u003e\n+ADw-!DOCTYPE foo [ \u003c!ENTITY % xxe SYSTEM \"php://filter/.......\" \u003e %xxe;]\u003e.....\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[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)","ecosystems":["Packagist"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Kimai has an XXE Leading to Local File Read","id":"GHSA-534c-hcr7-67jg","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"Packagist","product":null,"products":[],"type":"xxe","year":"2024"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"Packagist","fixed":["2.21.0"],"introduced":["0"],"last_affected":[],"package":"kimai/kimai","purl":null,"source":"GHSA-534c-hcr7-67jg"},{"ecosystem":"Packagist","fixed":["2.21.0"],"introduced":["0"],"last_affected":[],"package":"kimai/kimai","purl":"pkg:composer/kimai/kimai","source":"GHSA-534c-hcr7-67jg"}],"products":null,"published":"2024-09-17","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"An administrator can upload a malicious XLSX template to trigger XXE, allowing local file read or potential remote code execution.","url":"https://insights.sbomify.com/GHSA-534c-hcr7-67jg/"}