SlideShare a Scribd company logo
Statically detecting vulnerability
under memory pressure using
exhaustive search
安藤類央
情報通信研究機構
ネットワークセキュリティ研究所
2016年暗号と情報セキュリティシンポジウム
2016年1月22日(金)
4C2 システムセキュリティ
11:00--12:40
CVE-2013-4371 Realloc() vulnerability under high memory
pressure
概要: プログラム全走査による Memory Pressure下での
Use-After-Free (Heap Spray)攻撃の検出と評価
■近年、ミッションクリティカルな情報基盤ソフトウェアに適用される大規模なオープンソー
ス(Linux, Xen, Bind等)にUse-After-Free (Heap Spray)の脆弱性が多々発見されている。
■ Use-After-Free (Heap Spray)は大量の動的メモリ操作によるフラグメンテーションの深刻
化や初期化されないメモリ領域の発生が利用される。どちらもmemory pressureを攻撃者
が任意に発生させることができる状況で発生する。
■本論文では、memory pressureをかけやすい実装をLALR (Look-Ahead Left-Right)パーサ方式で
記述し、ソースコードを全走査することで未知の脆弱性も含めた検出を可能にする手法を提案する。
■ 評価実験では、CVE-2013-4371 / CVE-2014-1950を対象とし、 Use-After-Free攻撃が発生する関
数とループの解析と、コールチェインの全網羅による脆弱性の評価と、Bind上の未知の脆弱性の
調査を行った。
未知の脆弱性の定義
• 攻撃手法が未知で、探索(システム化)対象が未知
量子暗号・新しい理論モデルへの攻撃等
• 攻撃対象が既知で、探索対象が既知
検出・対策済み
• 攻撃対象が未知で、探索対象が既知
ハッキング・新しいデバイス特有の攻撃 Android stagefright
• 攻撃対象が既知で、探索対象が未知
Use-after-free (heap spray) -> CVE-2013-4371 / CVE-2014-1950
攻撃対象 探索対象
未知 未知 理論・PoC
既知 未知 未知の脆弱性
未知 既知 ハッキング・PoC
既知 既知 既知の脆弱性
背景と設計方針 (Scalability vs False Negatives)
In designing vulnerability checker, we face the difficult choice between
precision and scalability. Particularly, security system design is forced
to emphasize either false negatives or false positives. In todayfs large
scale computing era, we conclude that a false negative rate should be
as close to 0 as possible.
As of January 2013, GitHub had grown to 3 million users and
4.9 million repositories (repositories are histories of code
shared on the site). [9] And by December of this year, the
company hit 10 million repositories.
http://slideplayer.us/slide/703331/
長期解析 (静的・形式手法)
ITS4
ACSAC 2000
MOPS
CCS 2002
MC Meta-Level
Compilation
OSDI 2000
MACE
Concolic Execution
USENIX SEC 2011
COTS (ROP)
Usenix 2013
Automation
NDSS 2000
Format String
USENIX SEC 2001
MOPS (2)
CCS 2004
MetaSymsploit
USENIX SEC 2013
CHUCKY
CCS 2013
Computational
Verification (proverif)
CCS 2012
ConfAid
OSDI 2011
Metal Compiler
Extention
SSP 2002
SLAM
POPL 2002
ForNox
Hot SDN 2012
Dowser
USENIX SEC 2013
F7 verification
CCS 2010
StackGuard
USENIX SEC 1998
Branch Tracing (ROP)
Usenix Sec 2013
Proverif
SSP 2006 プロトコル検証の精緻化
複合型
設定整合性
攻撃手法の
迅速化への
対応
自動生成
形式手法
検査方法の分類
■構文主導型 (Syntax Directed Translation)
- This translator consists of a parser (or grammar) with embedded actions that immediately generate output.
正規表現、有限オートマトン
ITS4: a static vulnerability scanner for C and C++ code, Computer Security Applications, ACSAC 2002
Chucky: exposing missing checks in source code for vulnerability discovery ccs 2013
■ルール方式 (Rule Based Translation)
- Rule-based translators use the DSL of a particular rule engine to specify a set of “this goes to that” translation rules.
遷移規則、プッシュダウンオートマトン
Using programmer-written compiler extensions to catch security holes SSP 2002
Checking system rules using system-specific, programmer-written compiler extensions OSDI 2000
■モデル駆動方式 (Model Driven Translation)
- From the input model, a translator can emit output directly, build up strings, build up templates (documents with
“holes” in them where we can stick values), or build up specialized output objects
モデル検査・Concolic execution
MOPS: an infrastructure for examining security properties of software CCS2002
KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs, Usenix Sec 2011
Long term trend
(検査方式・対象の分類) プロトコル検証
メモリ関連脆弱性
オーバーフロー系
ルール・
攻撃ペイロード自動
生成
マッチング
GREP
データベース
中間表現
モデル検査
Symbolic
Execution
メモリ関連脆弱性
DOS攻撃
テンプレート
関数型表現
■脆弱性の性質の変化と検査方法のトレンド
検査手法の性質の二極化。プロトコル(モデル駆動・形式手
法)の精緻化と、大規模なテキストデータ・検索空間(パー
サー・ファジング)の処理の大規模化
ITS4
ACSAC 2000
ForNox
Hot SDN 2012
Computational
Verification (proverif)
CCS 2012
F7 verification
CCS 2010
MOPS (2)
CCS 2004
MC Meta-Level
Compilation
OSDI 2000
COTS (ROP)
Usenix 2013
Proverif
SSP 2006
SLAM
POPL 2002
AEG
NDSS 2012
Chimera
Usenix Sec 2012
CHUCKY
CCS 2013
Use-after-
free, Heap
Spray
Use-after-
free, Heap
Spray
Heap Spray aka user-after-free
http://blog.tempest.com.br/breno-cunha/perspectives-on-
exploit-development-and-cyber-attacks.html
create()
free()
realloc() use()
Jump to payload
on heap
ROP + Shellcode
int *tmp = (int*)realloc(k,(N+1)*sizeof(int));
if( tmp!=NULL ){
k = tmp;
puts("________realloc(k)_________");
for(i=0; i<N+1; i++){
printf("&k[%d]:%p , k[%d]=%d¥n",i,&k[i],i,k[i]);
}
}
realloc関数は第一引数で渡したポインタのアドレス位置から
拡張できない場合は新しい場所にメモリ確保を行う。
結果として、内容は保持されるがアドレスが変わる場合がある。
弊害:フラグメンテーションの深刻化・確保された場所は初期化が保障されない
検査対象 CVE-2013-4371
Xen Hypervisor
402 tmp = realloc(ptr, (i + 1) * sizeof(libxl_cpupoolinfo));
388libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx *ctx, int *nb_pool)
389{
390 libxl_cpupoolinfo *ptr, *tmp;
397 poolid = 0;
398 for (i = 0;; i++) {
399 info = xc_cpupool_getinfo(ctx->xch, poolid);
400 if (info == NULL)
401 break;
402 tmp = realloc(ptr, (i + 1) * sizeof(libxl_cpupoolinfo));
403 if (!tmp) {
404 LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating
cpupool info");
405 free(ptr);
406 xc_cpupool_infofree(ctx->xch, info);
407 return NULL;
408 }
409 ptr = tmp;
410 ptr[i].poolid = info->cpupool_id;
411 ptr[i].sched_id = info->sched_id;
412 ptr[i].n_dom = info->n_dom;
413 if (libxl_cpumap_alloc(ctx, &ptr[i].cpumap)) {
414 xc_cpupool_infofree(ctx->xch, info);
415 break;
416 }
417 memcpy(ptr[i].cpumap.map, info->cpumap, ptr[i].cpumap.size);
418 poolid = info->cpupool_id + 1;
419 xc_cpupool_infofree(ctx->xch, info);
realloc use-after-free vulnerability
Use-after-free vulnerability in the
libxl_list_cpupool function in the libxl toolstack
library in Xen 4.2.x and 4.3.x, when running
"under memory pressure," returns the original
pointer when the realloc function fails, which
allows local users to cause a denial of service
(heap corruption and crash) and possibly
execute arbitrary code via unspecified vectors.
At line 402, Xen uses realloc for
reallocating the memory. Note that the
address of libxl_cpupoolinfo is already
assigned outside of this routine. Under high
pressure, realloc can not extend the
memory from the original pointer which is
already obtained. in this case, realloc newly
yielding the address which remaining the
data to be written.
Boundary(終了条件)が
緩いループ (pressureを
かけやすい)
Reallocの返り値がポインタ
提案手法1(tagging, LALR parsing and binary search)
A-1
対象となるソースツリーのファイルをリストアップする
A-2
ファイルリストから関数をtagging(関数の行数など)する
B-1
対象となるソースツリーのループ群を検出する
B-2
対象となるソースツリーからrealloc()関数を検出する
C-3
検出されたループそれぞれについて、
関数の行数配列と、realloc()の行数の間で
バイナリサーチを行う
D-1
AからCの手順をもとに、
脆弱性についての情報をまとめる。
{ "_id" : ObjectId("5633ed7f42e0e0048307ec14"),
"loop_end_line" : 420, "realloc" : 1, "loop_start_line" : 398,
"loop_type" : 1, "realloc_line" : 402, "file_name" :
"tools_libxl_libxl__c", "func_line_number" : 388 }
関数解析部分
ループ解析部分
出力例:深さ優先探索(幅2) libxl_list_cpupool
main_cpupoollist
libxl_list_cpupool
main_cpupoollist
main*関数
(libvirtのインターフェース)
が連続している。
提案手法2 Loop representation and semantic action
66 line
67: for_statement_1
68| for_statement_2
69| for_loop_start
70| condition_1
71| condition_2
72| realloc
73| block
74;
258 block
259: BRACE_LEFT {
263}
264|
265 BRACE_RIGHT {
266 counter = yylval.ival;
269
274 func_for_statement_end();
275 func_for_statement_insert();
276
281 }
"for" {
return FOR;
}
"realloc" {
return REALLOC;
}
[0-9*] {
return NUMBER;
}
"(" {
return PAREN_LEFT;
}
Lexer Parser
Yacc or Bison Compiler
C Compiler
Parser Binary
(a.out)
LR
specification
y.tab.c
Input stream
y.tab.c
a.out
output stream
{ "_id" :
ObjectId("5633ed7f42e0e004
8307ec14"), "loop_end_line" :
420, "realloc" : 1,
"loop_start_line" : 398,
"loop_type" : 1,
"realloc_line" : 402,
"file_name" :
"tools_libxl_libxl__c",
"func_line_number" : 388 }
Semantic action
Bottom up
【参考】 比較した手法(SCIS2015) : プッシュダウンオートマトンによるブロック解析
Main Loop
Lexer
NFA(有限オートマトン)
PDA(プッシュダウンオートマトン)
Token Analyzer
Block Handler
識別子(制御文、メモリ操作命令など)
の検出と処理
ブロック文(繰り返し、
分岐)のネスト管理
Saturator-1
lightweight code checker with document database
https://github.com/RuoAndo/Saturator-1
Iteration for each token
switch (charatyp[ch]) f
case Letter:
for ( ; charatyp[ch]==Letter ||
charatyp[ch]==Digit;
ch=nextCh())
if (p < p 16) p++ = ch;
p = '0'
if(strcmp(tkn.text, “for")==0)
Document Database
処理系の状態情報
(プログラム中の位置など)
問い合わせ
格納
【参考】 評価実験 CVE-2013-4371 並列化したプッシュダウンオートマトン
12
{"_id" : ObjectId("53f9ec4764e21cef244d69fb"), "
located" : "402", "functionName" : "
libxl_list_cpupool", "functionLine" : "388", "
filename" : "libxl.c“}
34
{"_id" : ObjectId("53f9ec9464e21cef244d6a0e"), "
start_line" : "398", "end_line" : "420", "
functionName" : "libxl_list_cpupool", "
functionLine" : "388", "filename" : "libxl.c“}
realloc
{"_id" : ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : "145
"functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", "filename" :
"xc_domain.c" }
Use-after-free vulnerability in the libxl_list_cpupool function in the libxl toolstack library in Xen 4.2.x and 4.3.x, when
running "under memory pressure," returns the original pointer when the realloc function fails, which allows local users
to cause a denial of service (heap corruption and crash) and possibly execute arbitrary code via unspecified vectors.
http://www.cvedetails.com/cve/CVE-2013-4371/
We compiled our system on ubuntu12 LTS with Linux kernel
3.2.0. proposed system is hosted on Intel Xeon E5645 with 2.4
GHZ clock.
version forloop realloc functions real user sys real user sys
4.0.4 5438 76 13143m41.925s 0m9.213s 0m22.837 0m17.817s 0m2.880s 0m0.328s
4.1.0 5579 80 13735m35.133s 0m9.381s 0m25.002s 0m18.597 0m2.980 0m0.448
4.1.2 5547 76 13682m2.915s 0m9.301s 0m23.545s 0m18.432s 0m3.012 0m0.396
青:並列化なし 赤:提案手法(タスク並列化)
評価実験(2) LALR(Look-Ahead Left-Right Parsing)
{ "_id" : ObjectId("5633ed7f42e0e0048307ec14"),
"loop_end_line" : 420, "realloc" : 1, "loop_start_line" : 398,
"loop_type" : 1, "realloc_line" : 402, "file_name" :
"tools_libxl_libxl__c", "func_line_number" : 388 }
computing time
detected
realloc() loop
detected loop
4.2.1 10m40.012s 21 3734
4.2.5 11.m17.259s 20 3737
4.2.5 11.m17.259s 20 3737
4.3.1 11m54.117s 18 3907
4.3.4 12m3.511s 18 3911
for_statement_1
: for_loop_start condition_1_1 condition_1_2 condition_1_3 {
printf("for_statement type:1 starts at :");
print_line_number();
func_for_statement_1_start();
for_loop_flag = 1;
}
;
for_statement_2
: for_loop_start condition_1_1 condition_2_2 {
printf("for_statement type:2 started at :");
print_line_number();
func_for_statement_2_start();
for_loop_flag = 1;
}
;
終了条件 (boundary) が不十分なループ実装
提案したLALR型は変数遷移やループ系特定可能だがreentrant(pure)
ではないので現状では並列化できない。
Memory Pressureとコールチェイン解析 libxl_list_cpupool
main_cpupoollist
libxl_list_cpupool
main_cpupoollist
version functions callchain (one edge) time
4.1.0 804717 706252 9721m45.469s
4.2.0 1190430 1032808 20923m4.443s
4.3.0 1237690 1069749 22223m5643s
depth # callchains
1 8
2 84
3 1755
4 5290
5 7524
6 8808
7 11064
8 12483
9 14424
0
2000
4000
6000
8000
10000
12000
14000
16000
1 2 3 4 5 6 7 8 9
# callchains
main*関数
(libvirtのインターフェース)
が連続している。
未知の脆弱性: DNS Bind seriesの調査
> db.bind_9_4_0_forloop.find()
{ "_id" : ObjectId("5656562e208e132ac45177e1"), "filename" : "./bin/check/named-checkzone.c",
"start_line" : 105, "end_line" : 136, "loop_type" : 2, "realloc" : 0, "realloc_line" : 0 }
{ "_id" : ObjectId("5656562e208e132b4143cd11"), "filename" : "./bin/check/named-checkconf.c",
"start_line" : 96, "end_line" : 101, "loop_type" : 1, "realloc" : 0, "realloc_line" : 0 }
> db.bind_9_3_0_forloop.find({"realloc":1, "loop_type":2}).count()
39
> db.bind_9_3_0_forloop.find({"realloc":1, "loop_type":1}).count()
0
> db.bind_9_4_0_forloop.find({"realloc":1, "loop_type":1}).count()
0
> db.bind_9_4_0_forloop.find({"realloc":1, "loop_type":1}).count()
0
> db.bind_9_9_8_forloop.find({"realloc":1, "loop_type":1}).count()
0
> db.bind_9_7_0_forloop.find({"realloc":1, "loop_type":1}).count()
0
> db.bind_9_9_8_forloop.find({"realloc":1, "loop_type":2}).count()
64
> db.bind_9_7_0_forloop.find({"realloc":1, "loop_type":2}).count()
48
Hypervisor Xen
CVE-2013-4371 / CVE-2014-
1950 に該当するrealloc()の実
装形態は発見されなかった。
まとめ: プログラム全走査による Memory Pressure下での
Use-After-Free (Heap Spray)攻撃の検出と評価
■近年、ミッションクリティカルな情報基盤ソフトウェアに適用される大規模なオープンソー
ス(Linux, Xen, Bind等)にUse-After-Free (Heap Spray)の脆弱性が多々発見されている。
■ Use-After-Free (Heap Spray)は大量の動的メモリ操作によるフラグメンテーションの深刻
化や初期化されないメモリ領域の発生が利用される。どちらもmemory pressureを攻撃者
が任意に発生させることができる状況で発生する。
■本論文では、memory pressureをかけやすい実装をLALR (Look-Ahead Left-Right)パーサ方式で
記述し、ソースコードを全走査することで未知の脆弱性も含めた検出を可能にする手法を提案する。
■ 評価実験では、CVE-2013-4371 / CVE-2014-1950を対象とし、 Use-After-Free攻撃が発生する関
数とループの解析と、コールチェインの全網羅による脆弱性の評価と、Bind上の未知の脆弱性の
調査を行った。

More Related Content

PPTX
An extension of cryptographic protocol in distributed in-memory caching syst...
PPTX
SCIS 2016: An efficient slab encryption using extended SASL protocol
PPTX
An annotated context-free grammar based vulnerability detection using LALR pa...
PPTX
An Empirical Study of Android APK Distribution Sites Using Headless Browser w...
PPTX
Css2014 ruo ando_2014-10-23-01
PPTX
Scis2015 ruo ando_2015-01-20-01
PDF
RHEL7/CentOS7 NetworkManager徹底入門
PDF
入門!Software Defined Network
An extension of cryptographic protocol in distributed in-memory caching syst...
SCIS 2016: An efficient slab encryption using extended SASL protocol
An annotated context-free grammar based vulnerability detection using LALR pa...
An Empirical Study of Android APK Distribution Sites Using Headless Browser w...
Css2014 ruo ando_2014-10-23-01
Scis2015 ruo ando_2015-01-20-01
RHEL7/CentOS7 NetworkManager徹底入門
入門!Software Defined Network

What's hot (20)

PDF
Elasticsearch勉強会#44 20210624
PPTX
押さえておきたい、PostgreSQL 13 の新機能!!(Open Source Conference 2021 Online/Hokkaido 発表資料)
PPTX
Wiresharkの解析プラグインを作る ssmjp 201409
PDF
PostgreSQL運用管理入門
PDF
Stormの注目の新機能TridentAPI
PDF
分散ストリーム処理フレームワーク Apache S4
PDF
いまさら聞けないPostgreSQL運用管理
PDF
IIJlab seminar - Linux Kernel Library: Reusable monolithic kernel (in Japanese)
PDF
C16 45分でわかるPostgreSQLの仕組み by 山田努
PDF
Elasticsearch勉強会#39 LT 20201217
PDF
PostgreSQL Query Cache - "pqc"
PDF
OSS-DB Goldへの第一歩~実践!運用管理~
PDF
MBSD_Cybersecurity_Challenges_2017_最終審査会_発表スライド
PDF
OpenStackクラウド基盤構築ハンズオンセミナー 第1日:ハンズオンNo2
PDF
PostgreSQLアーキテクチャ入門(PostgreSQL Conference 2012)
PDF
Try andstudy cloud_20120509_nagoya
PDF
PG-REXで学ぶPacemaker運用の実例
PDF
5ステップで始めるPostgreSQLレプリケーション@hbstudy#13
PPTX
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PDF
Try andstudy cloud_20111108_tokyo
Elasticsearch勉強会#44 20210624
押さえておきたい、PostgreSQL 13 の新機能!!(Open Source Conference 2021 Online/Hokkaido 発表資料)
Wiresharkの解析プラグインを作る ssmjp 201409
PostgreSQL運用管理入門
Stormの注目の新機能TridentAPI
分散ストリーム処理フレームワーク Apache S4
いまさら聞けないPostgreSQL運用管理
IIJlab seminar - Linux Kernel Library: Reusable monolithic kernel (in Japanese)
C16 45分でわかるPostgreSQLの仕組み by 山田努
Elasticsearch勉強会#39 LT 20201217
PostgreSQL Query Cache - "pqc"
OSS-DB Goldへの第一歩~実践!運用管理~
MBSD_Cybersecurity_Challenges_2017_最終審査会_発表スライド
OpenStackクラウド基盤構築ハンズオンセミナー 第1日:ハンズオンNo2
PostgreSQLアーキテクチャ入門(PostgreSQL Conference 2012)
Try andstudy cloud_20120509_nagoya
PG-REXで学ぶPacemaker運用の実例
5ステップで始めるPostgreSQLレプリケーション@hbstudy#13
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
Try andstudy cloud_20111108_tokyo
Ad

Viewers also liked (15)

PDF
Taller negociación y manejo conflictos en el entorno de las Relaciones Insti...
DOC
Assignment 1 - Enhancement Green Technology via Air Conditioning
PDF
労働市場のパラダイムシフトWork Model 2030_中村天江(リクルートワークス研究所 労働政策センター長)
PDF
NIOMR Industrial Attachment Report 2006
PDF
科学技術イノベーション政策における「政策のための科学」推進に関する政策課題についての調査分析 報告書/政府研究開発投資目標の設定・投資効果の分析
PDF
気づきとサービスデザインワークショップ
DOCX
Sample of SIWES REPORT
PPTX
NASM Personal Fitness Training
PDF
Oral manifestations of systemic diseases
PDF
Buildings with Base Isolation Techniques
PDF
マイキープラットフォームに期待すること
PPT
industrialised building systems_achah
PPTX
fouling and boring
PPTX
PRE & PROBIOTICS
PDF
Affordable AI Connects To A Better Life
Taller negociación y manejo conflictos en el entorno de las Relaciones Insti...
Assignment 1 - Enhancement Green Technology via Air Conditioning
労働市場のパラダイムシフトWork Model 2030_中村天江(リクルートワークス研究所 労働政策センター長)
NIOMR Industrial Attachment Report 2006
科学技術イノベーション政策における「政策のための科学」推進に関する政策課題についての調査分析 報告書/政府研究開発投資目標の設定・投資効果の分析
気づきとサービスデザインワークショップ
Sample of SIWES REPORT
NASM Personal Fitness Training
Oral manifestations of systemic diseases
Buildings with Base Isolation Techniques
マイキープラットフォームに期待すること
industrialised building systems_achah
fouling and boring
PRE & PROBIOTICS
Affordable AI Connects To A Better Life
Ad

Similar to Statically detecting vulnerability under memory pressure using exhaustive search (20)

PDF
【技術解説4】assertion failureとuse after-free
PDF
SpectreBustersあるいはLinuxにおけるSpectre対策
PDF
IDAの脆弱性とBug Bounty by 千田 雅明
PDF
リナックスに置ける様々なリモートエキスプロイト手法 by スクハー・リー
PDF
[JPCERT/CC POC Meeting] 研究紹介 + DLLハイジャックの脆弱性
PPTX
Survey and Analysis of ICS Vulnerabilities (Japanese)
PDF
[CB17] Trueseeing: Effective Dataflow Analysis over Dalvik Opcodes
PDF
Di shen pacsec_jp-final
ODP
0x300
PPTX
No.2 超初心者向け セキュリティ入門
PDF
2012-04-25 ASPLOS2012出張報告(公開版)
PDF
Abusing Interrupts for Reliable Windows Kernel Exploitation (ja)
PDF
clu2cの動態保存とはなんでしょう?(東海道らぐ 初オフ会 in オープンソースカンファレンス 2012 Kansai@Kyoto 資料)
PDF
ROP Illmatic: Exploring Universal ROP on glibc x86-64 (ja)
PDF
Boost Tour 1.53.0 merge
PDF
GC in C++0x
PDF
C/C++プログラマのための開発ツール
PDF
[CB19] Semzhu-Project – 手で作る組込み向けハイパーバイザと攻撃検知手法の新しい世界 by 朱義文
PDF
脆弱性スキャナVuls(応用編)
PPTX
Scis2017 2007-01-27-02
【技術解説4】assertion failureとuse after-free
SpectreBustersあるいはLinuxにおけるSpectre対策
IDAの脆弱性とBug Bounty by 千田 雅明
リナックスに置ける様々なリモートエキスプロイト手法 by スクハー・リー
[JPCERT/CC POC Meeting] 研究紹介 + DLLハイジャックの脆弱性
Survey and Analysis of ICS Vulnerabilities (Japanese)
[CB17] Trueseeing: Effective Dataflow Analysis over Dalvik Opcodes
Di shen pacsec_jp-final
0x300
No.2 超初心者向け セキュリティ入門
2012-04-25 ASPLOS2012出張報告(公開版)
Abusing Interrupts for Reliable Windows Kernel Exploitation (ja)
clu2cの動態保存とはなんでしょう?(東海道らぐ 初オフ会 in オープンソースカンファレンス 2012 Kansai@Kyoto 資料)
ROP Illmatic: Exploring Universal ROP on glibc x86-64 (ja)
Boost Tour 1.53.0 merge
GC in C++0x
C/C++プログラマのための開発ツール
[CB19] Semzhu-Project – 手で作る組込み向けハイパーバイザと攻撃検知手法の新しい世界 by 朱義文
脆弱性スキャナVuls(応用編)
Scis2017 2007-01-27-02

More from Ruo Ando (20)

PDF
KISTI-NII Joint Security Workshop 2023.pdf
PDF
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
PDF
解説#86 決定木 - ss.pdf
PDF
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~
PDF
解説#83 情報エントロピー
PDF
解説#82 記号論理学
PDF
解説#81 ロジスティック回帰
PDF
解説#74 連結リスト
PDF
解説#76 福岡正信
PDF
解説#77 非加算無限
PDF
解説#1 C言語ポインタとアドレス
PDF
解説#78 誤差逆伝播
PDF
解説#73 ハフマン符号
PDF
【技術解説20】 ミニバッチ確率的勾配降下法
PDF
ITmedia Security Week 2021 講演資料
PPTX
ファジングの解説
PDF
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
PDF
【AI実装4】TensorFlowのプログラムを読む2 非線形回帰
PDF
Intel Trusted Computing Group 1st Workshop
PDF
情報セキュリティと標準化I 第15回
KISTI-NII Joint Security Workshop 2023.pdf
Gartner 「セキュリティ&リスクマネジメントサミット 2019」- 安藤
解説#86 決定木 - ss.pdf
SaaSアカデミー for バックオフィス アイドルと学ぶDX講座 ~アイドル戦略に見るDXを専門家が徹底解説~
解説#83 情報エントロピー
解説#82 記号論理学
解説#81 ロジスティック回帰
解説#74 連結リスト
解説#76 福岡正信
解説#77 非加算無限
解説#1 C言語ポインタとアドレス
解説#78 誤差逆伝播
解説#73 ハフマン符号
【技術解説20】 ミニバッチ確率的勾配降下法
ITmedia Security Week 2021 講演資料
ファジングの解説
AI(機械学習・深層学習)との協働スキルとOperational AIの事例紹介 @ ビジネス+ITセミナー 2020年11月
【AI実装4】TensorFlowのプログラムを読む2 非線形回帰
Intel Trusted Computing Group 1st Workshop
情報セキュリティと標準化I 第15回

Statically detecting vulnerability under memory pressure using exhaustive search

  • 1. Statically detecting vulnerability under memory pressure using exhaustive search 安藤類央 情報通信研究機構 ネットワークセキュリティ研究所 2016年暗号と情報セキュリティシンポジウム 2016年1月22日(金) 4C2 システムセキュリティ 11:00--12:40 CVE-2013-4371 Realloc() vulnerability under high memory pressure
  • 2. 概要: プログラム全走査による Memory Pressure下での Use-After-Free (Heap Spray)攻撃の検出と評価 ■近年、ミッションクリティカルな情報基盤ソフトウェアに適用される大規模なオープンソー ス(Linux, Xen, Bind等)にUse-After-Free (Heap Spray)の脆弱性が多々発見されている。 ■ Use-After-Free (Heap Spray)は大量の動的メモリ操作によるフラグメンテーションの深刻 化や初期化されないメモリ領域の発生が利用される。どちらもmemory pressureを攻撃者 が任意に発生させることができる状況で発生する。 ■本論文では、memory pressureをかけやすい実装をLALR (Look-Ahead Left-Right)パーサ方式で 記述し、ソースコードを全走査することで未知の脆弱性も含めた検出を可能にする手法を提案する。 ■ 評価実験では、CVE-2013-4371 / CVE-2014-1950を対象とし、 Use-After-Free攻撃が発生する関 数とループの解析と、コールチェインの全網羅による脆弱性の評価と、Bind上の未知の脆弱性の 調査を行った。
  • 3. 未知の脆弱性の定義 • 攻撃手法が未知で、探索(システム化)対象が未知 量子暗号・新しい理論モデルへの攻撃等 • 攻撃対象が既知で、探索対象が既知 検出・対策済み • 攻撃対象が未知で、探索対象が既知 ハッキング・新しいデバイス特有の攻撃 Android stagefright • 攻撃対象が既知で、探索対象が未知 Use-after-free (heap spray) -> CVE-2013-4371 / CVE-2014-1950 攻撃対象 探索対象 未知 未知 理論・PoC 既知 未知 未知の脆弱性 未知 既知 ハッキング・PoC 既知 既知 既知の脆弱性
  • 4. 背景と設計方針 (Scalability vs False Negatives) In designing vulnerability checker, we face the difficult choice between precision and scalability. Particularly, security system design is forced to emphasize either false negatives or false positives. In todayfs large scale computing era, we conclude that a false negative rate should be as close to 0 as possible. As of January 2013, GitHub had grown to 3 million users and 4.9 million repositories (repositories are histories of code shared on the site). [9] And by December of this year, the company hit 10 million repositories. http://slideplayer.us/slide/703331/
  • 5. 長期解析 (静的・形式手法) ITS4 ACSAC 2000 MOPS CCS 2002 MC Meta-Level Compilation OSDI 2000 MACE Concolic Execution USENIX SEC 2011 COTS (ROP) Usenix 2013 Automation NDSS 2000 Format String USENIX SEC 2001 MOPS (2) CCS 2004 MetaSymsploit USENIX SEC 2013 CHUCKY CCS 2013 Computational Verification (proverif) CCS 2012 ConfAid OSDI 2011 Metal Compiler Extention SSP 2002 SLAM POPL 2002 ForNox Hot SDN 2012 Dowser USENIX SEC 2013 F7 verification CCS 2010 StackGuard USENIX SEC 1998 Branch Tracing (ROP) Usenix Sec 2013 Proverif SSP 2006 プロトコル検証の精緻化 複合型 設定整合性 攻撃手法の 迅速化への 対応 自動生成 形式手法
  • 6. 検査方法の分類 ■構文主導型 (Syntax Directed Translation) - This translator consists of a parser (or grammar) with embedded actions that immediately generate output. 正規表現、有限オートマトン ITS4: a static vulnerability scanner for C and C++ code, Computer Security Applications, ACSAC 2002 Chucky: exposing missing checks in source code for vulnerability discovery ccs 2013 ■ルール方式 (Rule Based Translation) - Rule-based translators use the DSL of a particular rule engine to specify a set of “this goes to that” translation rules. 遷移規則、プッシュダウンオートマトン Using programmer-written compiler extensions to catch security holes SSP 2002 Checking system rules using system-specific, programmer-written compiler extensions OSDI 2000 ■モデル駆動方式 (Model Driven Translation) - From the input model, a translator can emit output directly, build up strings, build up templates (documents with “holes” in them where we can stick values), or build up specialized output objects モデル検査・Concolic execution MOPS: an infrastructure for examining security properties of software CCS2002 KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs, Usenix Sec 2011
  • 7. Long term trend (検査方式・対象の分類) プロトコル検証 メモリ関連脆弱性 オーバーフロー系 ルール・ 攻撃ペイロード自動 生成 マッチング GREP データベース 中間表現 モデル検査 Symbolic Execution メモリ関連脆弱性 DOS攻撃 テンプレート 関数型表現 ■脆弱性の性質の変化と検査方法のトレンド 検査手法の性質の二極化。プロトコル(モデル駆動・形式手 法)の精緻化と、大規模なテキストデータ・検索空間(パー サー・ファジング)の処理の大規模化 ITS4 ACSAC 2000 ForNox Hot SDN 2012 Computational Verification (proverif) CCS 2012 F7 verification CCS 2010 MOPS (2) CCS 2004 MC Meta-Level Compilation OSDI 2000 COTS (ROP) Usenix 2013 Proverif SSP 2006 SLAM POPL 2002 AEG NDSS 2012 Chimera Usenix Sec 2012 CHUCKY CCS 2013 Use-after- free, Heap Spray Use-after- free, Heap Spray
  • 8. Heap Spray aka user-after-free http://blog.tempest.com.br/breno-cunha/perspectives-on- exploit-development-and-cyber-attacks.html create() free() realloc() use() Jump to payload on heap ROP + Shellcode int *tmp = (int*)realloc(k,(N+1)*sizeof(int)); if( tmp!=NULL ){ k = tmp; puts("________realloc(k)_________"); for(i=0; i<N+1; i++){ printf("&k[%d]:%p , k[%d]=%d¥n",i,&k[i],i,k[i]); } } realloc関数は第一引数で渡したポインタのアドレス位置から 拡張できない場合は新しい場所にメモリ確保を行う。 結果として、内容は保持されるがアドレスが変わる場合がある。 弊害:フラグメンテーションの深刻化・確保された場所は初期化が保障されない
  • 9. 検査対象 CVE-2013-4371 Xen Hypervisor 402 tmp = realloc(ptr, (i + 1) * sizeof(libxl_cpupoolinfo)); 388libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx *ctx, int *nb_pool) 389{ 390 libxl_cpupoolinfo *ptr, *tmp; 397 poolid = 0; 398 for (i = 0;; i++) { 399 info = xc_cpupool_getinfo(ctx->xch, poolid); 400 if (info == NULL) 401 break; 402 tmp = realloc(ptr, (i + 1) * sizeof(libxl_cpupoolinfo)); 403 if (!tmp) { 404 LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating cpupool info"); 405 free(ptr); 406 xc_cpupool_infofree(ctx->xch, info); 407 return NULL; 408 } 409 ptr = tmp; 410 ptr[i].poolid = info->cpupool_id; 411 ptr[i].sched_id = info->sched_id; 412 ptr[i].n_dom = info->n_dom; 413 if (libxl_cpumap_alloc(ctx, &ptr[i].cpumap)) { 414 xc_cpupool_infofree(ctx->xch, info); 415 break; 416 } 417 memcpy(ptr[i].cpumap.map, info->cpumap, ptr[i].cpumap.size); 418 poolid = info->cpupool_id + 1; 419 xc_cpupool_infofree(ctx->xch, info); realloc use-after-free vulnerability Use-after-free vulnerability in the libxl_list_cpupool function in the libxl toolstack library in Xen 4.2.x and 4.3.x, when running "under memory pressure," returns the original pointer when the realloc function fails, which allows local users to cause a denial of service (heap corruption and crash) and possibly execute arbitrary code via unspecified vectors. At line 402, Xen uses realloc for reallocating the memory. Note that the address of libxl_cpupoolinfo is already assigned outside of this routine. Under high pressure, realloc can not extend the memory from the original pointer which is already obtained. in this case, realloc newly yielding the address which remaining the data to be written. Boundary(終了条件)が 緩いループ (pressureを かけやすい) Reallocの返り値がポインタ
  • 10. 提案手法1(tagging, LALR parsing and binary search) A-1 対象となるソースツリーのファイルをリストアップする A-2 ファイルリストから関数をtagging(関数の行数など)する B-1 対象となるソースツリーのループ群を検出する B-2 対象となるソースツリーからrealloc()関数を検出する C-3 検出されたループそれぞれについて、 関数の行数配列と、realloc()の行数の間で バイナリサーチを行う D-1 AからCの手順をもとに、 脆弱性についての情報をまとめる。 { "_id" : ObjectId("5633ed7f42e0e0048307ec14"), "loop_end_line" : 420, "realloc" : 1, "loop_start_line" : 398, "loop_type" : 1, "realloc_line" : 402, "file_name" : "tools_libxl_libxl__c", "func_line_number" : 388 } 関数解析部分 ループ解析部分
  • 12. 提案手法2 Loop representation and semantic action 66 line 67: for_statement_1 68| for_statement_2 69| for_loop_start 70| condition_1 71| condition_2 72| realloc 73| block 74; 258 block 259: BRACE_LEFT { 263} 264| 265 BRACE_RIGHT { 266 counter = yylval.ival; 269 274 func_for_statement_end(); 275 func_for_statement_insert(); 276 281 } "for" { return FOR; } "realloc" { return REALLOC; } [0-9*] { return NUMBER; } "(" { return PAREN_LEFT; } Lexer Parser Yacc or Bison Compiler C Compiler Parser Binary (a.out) LR specification y.tab.c Input stream y.tab.c a.out output stream { "_id" : ObjectId("5633ed7f42e0e004 8307ec14"), "loop_end_line" : 420, "realloc" : 1, "loop_start_line" : 398, "loop_type" : 1, "realloc_line" : 402, "file_name" : "tools_libxl_libxl__c", "func_line_number" : 388 } Semantic action Bottom up
  • 13. 【参考】 比較した手法(SCIS2015) : プッシュダウンオートマトンによるブロック解析 Main Loop Lexer NFA(有限オートマトン) PDA(プッシュダウンオートマトン) Token Analyzer Block Handler 識別子(制御文、メモリ操作命令など) の検出と処理 ブロック文(繰り返し、 分岐)のネスト管理 Saturator-1 lightweight code checker with document database https://github.com/RuoAndo/Saturator-1 Iteration for each token switch (charatyp[ch]) f case Letter: for ( ; charatyp[ch]==Letter || charatyp[ch]==Digit; ch=nextCh()) if (p < p 16) p++ = ch; p = '0' if(strcmp(tkn.text, “for")==0) Document Database 処理系の状態情報 (プログラム中の位置など) 問い合わせ 格納
  • 14. 【参考】 評価実験 CVE-2013-4371 並列化したプッシュダウンオートマトン 12 {"_id" : ObjectId("53f9ec4764e21cef244d69fb"), " located" : "402", "functionName" : " libxl_list_cpupool", "functionLine" : "388", " filename" : "libxl.c“} 34 {"_id" : ObjectId("53f9ec9464e21cef244d6a0e"), " start_line" : "398", "end_line" : "420", " functionName" : "libxl_list_cpupool", " functionLine" : "388", "filename" : "libxl.c“} realloc {"_id" : ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : "145 "functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", "filename" : "xc_domain.c" } Use-after-free vulnerability in the libxl_list_cpupool function in the libxl toolstack library in Xen 4.2.x and 4.3.x, when running "under memory pressure," returns the original pointer when the realloc function fails, which allows local users to cause a denial of service (heap corruption and crash) and possibly execute arbitrary code via unspecified vectors. http://www.cvedetails.com/cve/CVE-2013-4371/ We compiled our system on ubuntu12 LTS with Linux kernel 3.2.0. proposed system is hosted on Intel Xeon E5645 with 2.4 GHZ clock. version forloop realloc functions real user sys real user sys 4.0.4 5438 76 13143m41.925s 0m9.213s 0m22.837 0m17.817s 0m2.880s 0m0.328s 4.1.0 5579 80 13735m35.133s 0m9.381s 0m25.002s 0m18.597 0m2.980 0m0.448 4.1.2 5547 76 13682m2.915s 0m9.301s 0m23.545s 0m18.432s 0m3.012 0m0.396 青:並列化なし 赤:提案手法(タスク並列化)
  • 15. 評価実験(2) LALR(Look-Ahead Left-Right Parsing) { "_id" : ObjectId("5633ed7f42e0e0048307ec14"), "loop_end_line" : 420, "realloc" : 1, "loop_start_line" : 398, "loop_type" : 1, "realloc_line" : 402, "file_name" : "tools_libxl_libxl__c", "func_line_number" : 388 } computing time detected realloc() loop detected loop 4.2.1 10m40.012s 21 3734 4.2.5 11.m17.259s 20 3737 4.2.5 11.m17.259s 20 3737 4.3.1 11m54.117s 18 3907 4.3.4 12m3.511s 18 3911 for_statement_1 : for_loop_start condition_1_1 condition_1_2 condition_1_3 { printf("for_statement type:1 starts at :"); print_line_number(); func_for_statement_1_start(); for_loop_flag = 1; } ; for_statement_2 : for_loop_start condition_1_1 condition_2_2 { printf("for_statement type:2 started at :"); print_line_number(); func_for_statement_2_start(); for_loop_flag = 1; } ; 終了条件 (boundary) が不十分なループ実装 提案したLALR型は変数遷移やループ系特定可能だがreentrant(pure) ではないので現状では並列化できない。
  • 16. Memory Pressureとコールチェイン解析 libxl_list_cpupool main_cpupoollist libxl_list_cpupool main_cpupoollist version functions callchain (one edge) time 4.1.0 804717 706252 9721m45.469s 4.2.0 1190430 1032808 20923m4.443s 4.3.0 1237690 1069749 22223m5643s depth # callchains 1 8 2 84 3 1755 4 5290 5 7524 6 8808 7 11064 8 12483 9 14424 0 2000 4000 6000 8000 10000 12000 14000 16000 1 2 3 4 5 6 7 8 9 # callchains main*関数 (libvirtのインターフェース) が連続している。
  • 17. 未知の脆弱性: DNS Bind seriesの調査 > db.bind_9_4_0_forloop.find() { "_id" : ObjectId("5656562e208e132ac45177e1"), "filename" : "./bin/check/named-checkzone.c", "start_line" : 105, "end_line" : 136, "loop_type" : 2, "realloc" : 0, "realloc_line" : 0 } { "_id" : ObjectId("5656562e208e132b4143cd11"), "filename" : "./bin/check/named-checkconf.c", "start_line" : 96, "end_line" : 101, "loop_type" : 1, "realloc" : 0, "realloc_line" : 0 } > db.bind_9_3_0_forloop.find({"realloc":1, "loop_type":2}).count() 39 > db.bind_9_3_0_forloop.find({"realloc":1, "loop_type":1}).count() 0 > db.bind_9_4_0_forloop.find({"realloc":1, "loop_type":1}).count() 0 > db.bind_9_4_0_forloop.find({"realloc":1, "loop_type":1}).count() 0 > db.bind_9_9_8_forloop.find({"realloc":1, "loop_type":1}).count() 0 > db.bind_9_7_0_forloop.find({"realloc":1, "loop_type":1}).count() 0 > db.bind_9_9_8_forloop.find({"realloc":1, "loop_type":2}).count() 64 > db.bind_9_7_0_forloop.find({"realloc":1, "loop_type":2}).count() 48 Hypervisor Xen CVE-2013-4371 / CVE-2014- 1950 に該当するrealloc()の実 装形態は発見されなかった。
  • 18. まとめ: プログラム全走査による Memory Pressure下での Use-After-Free (Heap Spray)攻撃の検出と評価 ■近年、ミッションクリティカルな情報基盤ソフトウェアに適用される大規模なオープンソー ス(Linux, Xen, Bind等)にUse-After-Free (Heap Spray)の脆弱性が多々発見されている。 ■ Use-After-Free (Heap Spray)は大量の動的メモリ操作によるフラグメンテーションの深刻 化や初期化されないメモリ領域の発生が利用される。どちらもmemory pressureを攻撃者 が任意に発生させることができる状況で発生する。 ■本論文では、memory pressureをかけやすい実装をLALR (Look-Ahead Left-Right)パーサ方式で 記述し、ソースコードを全走査することで未知の脆弱性も含めた検出を可能にする手法を提案する。 ■ 評価実験では、CVE-2013-4371 / CVE-2014-1950を対象とし、 Use-After-Free攻撃が発生する関 数とループの解析と、コールチェインの全網羅による脆弱性の評価と、Bind上の未知の脆弱性の 調査を行った。