
Html2xhtml v1.3 には、procesador.c の関数 static void elm_close(tree_node_t *nodo) に境界外読み取り(Out-of-Bounds Read)が存在することが判明しました。この脆弱性により、攻撃者は巧妙に細工された HTML ファイルを介して、機密ファイルへのアクセスやサービス拒否(DoS)を引き起こす可能性があります。
CWE-125 境界外読み取り(Out-of-Bounds Read) は、メモリからデータを読み取る際に発生する可能性のあるソフトウェアエラーの一種です。これは、例えばプログラムが配列の末尾を超えて読み取ろうとした場合に発生します。境界外読み取りは、クラッシュやその他の予期しない脆弱性を引き起こす可能性があり、攻撃者が本来アクセスできない機密情報を読み取ることを可能にする場合があります。
html2xhtml/src/procesador.c における境界外読み取り (GHSA-28fm-qh2h-3mch)Html2xhtml は、HTML ファイルを XHTML ファイルに変換するコマンドラインツールです。Html2xhtml は、次のいずれかの文書型に準拠した XHTML 出力を生成できます: XHTML 1.0(Transitional、Strict、Frameset)、XHTML 1.1、XHTML Basic、XHTML Mobile Profile。
この脆弱性は、-t frameset オプションを使用した際に発生したセグメンテーションフォールト(segfault)エラーによって発見されました。セグメンテーションフォールト(segfault) は、自分に属さないメモリにアクセスすることで発生する特定の種類のエラーです。これは、メモリを破壊してデバッグが困難なメモリバグを引き起こすのを防ぐためのヘルパーメカニズムです。
C および C++ プログラムのヒープメモリ(new や malloc で動的に割り当てられるメモリ)へのメモリアクセスエラーを検出するツールである Valgrind を使用してセグフォルトエラーをデバッグしたところ、テストケースで invalid read of size 4(サイズ 4 の無効な読み取り)が報告されました:
==1040381== Memcheck, a memory error detector
==1040381== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1040381== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1040381== Command: ./src/html2xhtml -t frameset report/vuln/id:000000,sig:11,src:001386+001369,time:12081510,execs:2336913,op:splice,rep:16
==1040381==
==1040381== Invalid read of size 4
==1040381== at 0x40E911: elm_close (procesador.c:944)
==1040381== by 0x410617: err_html_struct (procesador.c:1889)
==1040381== by 0x40F20A: err_content_invalid (procesador.c:0)
==1040381== by 0x40F20A: elm_close (procesador.c:959)
==1040381== by 0x40E7C4: saxEndDocument (procesador.c:233)
==1040381== by 0x40DF7A: main (html2xhtml.c:117)
==1040381== Address 0x6f20d4 is not stack'd, malloc'd or (recently) free'd
==1040381==
==1040381==
==1040381== Process terminating with default action of signal 11 (SIGSEGV)
==1040381== Access not within mapped region at address 0x6F20D4
==1040381== at 0x40E911: elm_close (procesador.c:944)
==1040381== by 0x410617: err_html_struct (procesador.c:1889)
==1040381== by 0x40F20A: err_content_invalid (procesador.c:0)
==1040381== by 0x40F20A: elm_close (procesador.c:959)
==1040381== by 0x40E7C4: saxEndDocument (procesador.c:233)
==1040381== by 0x40DF7A: main (html2xhtml.c:117)
==1040381== If you believe this happened as a result of a stack
==1040381== overflow in your program's main thread (unlikely but
==1040381== possible), you can try to increase the size of the
==1040381== main thread stack using the --main-stacksize= flag.
==1040381== The main thread stack size used in this run was 8388608.
==1040381==
==1040381== HEAP SUMMARY:
==1040381== in use at exit: 88,190 bytes in 13 blocks
==1040381== total heap usage: 22 allocs, 9 frees, 2,218,413 bytes allocated
==1040381==
==1040381== LEAK SUMMARY:
==1040381== definitely lost: 0 bytes in 0 blocks
==1040381== indirectly lost: 0 bytes in 0 blocks
==1040381== possibly lost: 0 bytes in 0 blocks
==1040381== still reachable: 88,190 bytes in 13 blocks
==1040381== suppressed: 0 bytes in 0 blocks
==1040381== Rerun with --leak-check=full to see details of leaked memory
==1040381==
==1040381== For lists of detected and suppressed errors, rerun with: -s
==1040381== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==1040419== Memcheck, a memory error detector
Valgrind からのエラーログにより、セグフォルトが発生した以下の関数が特定されました:

この関数には型チェックが欠如していることが判明しました。ユーザーが element ではなく comment 型のノードをこの関数に渡すと、境界外読み取りエラーが発生します。ユーザーが無効な ELM_PTR(nodo).contenttype[doctype] を含む不正な文書を提供すると、アセンブリ内で次の比較が行われます:
cmp dword ptr [rbp + rax*4 + 0xc], 4
この脆弱性は、攻撃者が細工されたファイルを使用して、機密ファイル、メモリ、またはメモリ位置を読み取るために悪用される可能性があります。
| 深刻度 | 高 8.1 / 10 |
|---|
| 攻撃の複雑さ | 低 |
| 必要な権限レベル | なし |
| ユーザー操作 | 要 |
| スコープ | 変更なし |
| 機密性 | 高 |
| 完全性 | なし |
| 可用性 | 高 |