42. ● Mapped Area Based Buffer Overflow
Master Canary Forging
target area
43. ● Mapped Area Based Buffer Overflow
○ まずmmapを使って領域を確保する
○ 確保した領域が目的の領域の上に来るようにする
Master Canary Forging
mapped area
target area
44. ● Mapped Area Based Buffer Overflow
○ まずmmapを使って領域を確保する
○ 確保した領域が目的の領域の上に来るようにする
○ 確保した領域でBOFを起こす
○ 十分なサイズなら、隣接した領域も上書き出る
Master Canary Forging
overwritten
45. ● Mapped Area Based Buffer Overflow
○ これでmaster canaryを書き換えられそう!
○ でも、攻撃者はmmapを呼べるの?
Master Canary Forging
46. ● Mapped Area Based Buffer Overflow
○ これでmaster canaryを書き換えられそう!
○ でも、攻撃者はmmapを呼べるの?
■ はい
Master Canary Forging
47. ● Mapped Area Based Buffer Overflow
○ これでmaster canaryを書き換えられそう!
○ でも、攻撃者はmmapを呼べるの?
■ はい
■ malloc
Master Canary Forging
48. ● Mapped Area Based Buffer Overflow
○ これでmaster canaryを書き換えられそう!
○ でも、攻撃者はmmapを呼べるの?
■ はい
■ malloc
■ “When allocating blocks of memory larger than
MMAP_THRESHOLD bytes, the glibc malloc()
implementation allocates the memory as a private
anonymous mapping using mmap(2).”
Master Canary Forging
49. ● Mapped Area Based Buffer Overflow
○ 使える条件は以下の2つ
■ heapのallocateを自由に行える
■ Heap Based BOFが起こる
Master Canary Forging
50. 1. master canaryの書き換え
a. .bssにある時
i. 任意のアドレス書き換えで書き換える
b. TLSにある時
i. Mapped Area Based BOFを使う
2. Stack Based BOFを起こす
Master Canary Forging