🇰🇷 한글 설명
ag-psd는 Photoshop 문서(PSD) 파일을 읽고 쓰는 JavaScript 라이브러리입니다. 31.0.0 이전 버전의 readPsd()는 실제 데이터를 검증하기 전에 공격자가 선언한 PSD 크기 정보로 이미지 및 레이어 버퍼를 할당하여, 매우 작은 파일로도 수 GB의 메모리를 소모시킬 수 있습니다. 31.0.0에서 합성 이미지 할당 제한이 추가되었으나 레이어 사각형 할당 경로에 대한 완전한 보호는 확인되지 않았습니다.
💡 쉬운 설명
아주 작은 그림 파일이라도 '거대한 크기'라고 거짓으로 적혀 있으면, 이 라이브러리는 그만큼의 메모리를 미리 잡아버립니다. 이로 인해 서버 메모리가 바닥나 서비스가 멈출 수 있습니다.
🇺🇸 원문 (English)
ag-psd is a JavaScript library for reading and writing Photoshop Document files. Before the allocation-limit remediation attempt in version 31.0.0, `readPsd()` commits image and layer buffers from attacker-declared PSD geometry before validating the declarations against the actual available data or sane allocation limits. The `psdReader.js` implementation sizes off-heap typed arrays using `width`, `height`, `channels`, `depth` and `per-layer rectangles`, so a tiny PSD declaring enormous geometry can force multi-gigabyte memory allocation before a later bounds error. The reported 52-byte input on Node 24 produced approximately 3.17 GB peak RSS before a RangeError; under memory pressure the process can be terminated before the error can be caught, and concurrent inputs can exhaust memory. Services reading untrusted PSDs are exposed to denial of service. This differs from genuinely large PSD files whose memory demand is proportional to real input content. Version 31.0.0 adds a composite-image allocation limit, but complete coverage of the separately described layer-rectangle allocation path is not established and requires curator residual/scope review.
📍 영향받는 시스템
ag-psd 31.0.0 이전 버전을 사용하여 신뢰할 수 없는 PSD 파일을 읽는 Node.js 서비스
⚔️ 공격 벡터
공격자가 크기 정보를 과장한 소형 PSD 파일을 업로드하거나 전송하여 서버의 메모리를 고갈시킴 (서비스 거부)
🛡️ 대응 방법
ag-psd를 31.0.0 이상으로 업그레이드하고, 레이어 할당 경로에 대한 추가 제한(파일 크기 상한, 메모리 제한, 프로세스 격리)을 적용
🔧 검증 코드
출력된 ag-psd 버전이 31.0.0 이상이면 합성 이미지 제한이 적용된 것이며, 31.0.0 미만이거나 결과가 없으면 취약 가능성이 있으므로 업그레이드 및 설치 여부를 확인해야 합니다.
npm ls ag-psd 2>/dev/null | grep ag-psd