A scalable and lightweight code 
checker using document 
database 
コンピュータセキュリティシンポジウム2014 
CSS 2014 – Computer Security Symposium 
10月24日14:50 – 16:29 
2D4: 脆弱性・テイント解析 
安藤類央 
情報通信研究機構 
ネットワークセキュリティ研究所
概要: towards lightweight and scalable code checker 
本論文では、key-valueを処理データ構造として持つDocument Dasebaseを用いて、ドメイン固有知 
識と中間表現の分離を行い(lightweight)、大規模なファイル処理に耐えるシステム(scalability)を構 
築する。 
■脆弱性の性質の変化と検査方法のトレンド 
検査手法の性質の二極化。モデル駆動方式によるプロトコル脆弱性の解析と、 
広範なテキストファイルを処理するシステム脆弱性の解析 
■スケーラビリティとFalse Negative: 
Key-Valueによる検査対象コードと脆弱性情報の中間表現の構築 
NoSQLの適用によるアーキテクチャ面でのスケーラビリティの向上 
■脆弱性攻撃の開発スパンの短縮: 
ドメイン固有知識と中間表現の分離 
https://github.com/RuoAndo/Saturator-1 
http://www.slideshare.net/RuoAndo/css2014-ruo-ando2014102301
設計方針(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/
Long term trend (検査方式と対象) 
ITS4 
ACSAC 2000 
MC Meta-Level 
Compilation 
OSDI 2000 
MOPS 
CCS 2002 
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 
モデル検査・実行系 
MOPS: an infrastructure for examining security properties of software CCS2002 
Chucky: exposing missing checks in source code for vulnerability discovery ccs 2013
提案手法1 
Main Loop 
Lexer 
識別子(制御文、メモリ操作命令など) 
の検出と処理 
Token Analyzer 
Block Handler 
ブロック文(繰り返し、 
分岐)のネスト管理 
NFA(有限オートマトン) 
PDA(プッシュダウンオートマトン) 
Document 
Database 
Key-Value 
形式による 
検索要求 
脆弱性に 
関する 
ドメイン 
固有知識 
Saturator-1 
lightweight code checker with document database 
https://github.com/RuoAndo/Saturator-1 
Key-Value(JSON) 
による中間表現の 
構築 
Iteration for each token 
構文主導 
方式 
ルール 
方式
3つの検査方法:データ表現形式とドメイン固有知識 
検査対象 
プログラム 
ルール 
述語論理式定理証明系 
状態遷移式 
正規表現 
データベース 
モデルチェッカー 
実行系 
中間表現 
トランスレータ・実行系 
CFG 
構文主導方式 
ルール方式 
モデル駆動 
方式 
ボトルネック:セキュリティに 
関するドメイン固有知識
提案手法2 
Main Loop 
Lexer 
識別子(制御文、メモリ操作命令など) 
の検出と処理 
Token Analyzer 
Block Handler 
ブロック文(繰り返し、 
分岐)のネスト管理 
NFA(有限オートマトン) 
PDA(プッシュダウンオートマトン) 
Document 
Database 
Key-Value 
形式による 
検索要求 
脆弱性に 
関する 
ドメイン 
固有知識 
Saturator-1 
lightweight code checker with document database 
https://github.com/RuoAndo/Saturator-1 
Key-Value(JSON) 
による中間表現の 
構築 
Iteration for each token 
脆弱 
固有知識 
の排除 
ルール 
方式 
構文主導 
方式
提案手法3 
Main Loop 
Iteration for each token 
Lexer 
識別子(制御文、メモリ操作命令など) 
の検出と処理 
Token Analyzer 
Block Handler 
ブロック文(繰り返し、 
分岐)のネスト管理 
NFA(有限オートマトン) 
PDA(プッシュダウンオートマトン) 
Saturator-1 
lightweight code checker with document database 
https://github.com/RuoAndo/Saturator-1 
Document Database 
処理系の状態情報 
(プログラム中の位置など) 
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) 
問い合わせ 
格納
繰り返し(For文) 
{ “_id” : 
ObjectId(“53d28a5a40c2acf65bbbf9a9”), 
“ start_line" : "209", "end_line" : "250", " 
functionName" : "xc_domain_getinfo", 
“ functionLine" : "197", "filename" : 
"xc_domain.c“} 
{"_id" : 
ObjectId("53d28ab940c2acf65bbbf9b1"), 
"start_line" : "212", "end_line" : "253", " 
functionName" : "xc_domain_getinfo", 
"functionLine" : "200", "filename" : 
"xc_domain.c“} 
1 void DBop realloc(char line, char functionName, char 
functionLine, char filename) 
2 
14 
15 mongoc init (); 
16 
17 client = mongoc client new (uristr); 
18 if (!client) f 
19 fprintf (stderr, "Failed␣to␣parse␣URI.¥n"); 
21 
22 bson init (&query); 
23 
24 bson append utf8 (&query, "located", line); 
25 bson append utf8 (&query, "functionName", -1, 
functionName); 
26 bson append utf8 (&query, "functionLine", -1, 
functionLine); 
27 bson append utf8 (&query, "filename", -1, filename,-1); 
28 
29 collection = mongoc client get collection (client, "cci", 
collection name); 
30 
31 mongoc collection insert (collection, 
32 MONGOC QUERY NONE, 
33 &query, 
34 NULL, 
35 NULL); 
realloc 
{"_id" : ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : 
"145 
"functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", 
"filename" : "xc_domain.c" }
評価実験CVE-2013-4371 
realloc 
{"_id" : ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : "145 
"functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", "filename" : 
"xc_domain.c" } 
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“} 
Xen-4.1.2 
real 2m25.632s 
user 0m9.233s 
sys 0m23.729s 
> db.forloop.count() 
15205 
> db.function.count() 
1742 
> db.realloc.count() 
126 
Xen-4.0.1 
real 4m3.567s 
user 0m9.289s 
sys 0m22.529s 
> db.forloop.count() 
27595 
> db.function.count() 
3099 
> db.realloc.count() 
228 
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.
まとめ: towards lightweight and scalable code checker 
■脆弱性の性質の変化と検査方法のトレンド 
検査手法の性質の二極化。モデル駆動方式によるプロトコル脆弱性の解析と、 
広範なテキストファイルを処理するシステム脆弱性の解析 
■スケーラビリティとFalse Negative: 
Key-Valueによる検査対象コードと脆弱性情報の中間表現の構築 
NoSQLの適用によるアーキテクチャ面でのスケーラビリティの向上 
■脆弱性攻撃の開発スパンの短縮: 
ドメイン固有知識と中間表現の分離 
本論文では、key-valueを処理データ構造として持つDocument Dasebaseを用いて、 
ドメイン固有知識と中間表現の分離を行い(lightweight)、大規模なファイル処理に耐える 
システム(scalability)を構築した。 
https://github.com/RuoAndo/Saturator-1 
http://www.slideshare.net/RuoAndo/css2014-ruo-ando2014102301

Css2014 ruo ando_2014-10-23-01

  • 1.
    A scalable andlightweight code checker using document database コンピュータセキュリティシンポジウム2014 CSS 2014 – Computer Security Symposium 10月24日14:50 – 16:29 2D4: 脆弱性・テイント解析 安藤類央 情報通信研究機構 ネットワークセキュリティ研究所
  • 2.
    概要: towards lightweightand scalable code checker 本論文では、key-valueを処理データ構造として持つDocument Dasebaseを用いて、ドメイン固有知 識と中間表現の分離を行い(lightweight)、大規模なファイル処理に耐えるシステム(scalability)を構 築する。 ■脆弱性の性質の変化と検査方法のトレンド 検査手法の性質の二極化。モデル駆動方式によるプロトコル脆弱性の解析と、 広範なテキストファイルを処理するシステム脆弱性の解析 ■スケーラビリティとFalse Negative: Key-Valueによる検査対象コードと脆弱性情報の中間表現の構築 NoSQLの適用によるアーキテクチャ面でのスケーラビリティの向上 ■脆弱性攻撃の開発スパンの短縮: ドメイン固有知識と中間表現の分離 https://github.com/RuoAndo/Saturator-1 http://www.slideshare.net/RuoAndo/css2014-ruo-ando2014102301
  • 3.
    設計方針(Scalability vs FalseNegatives) 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/
  • 4.
    Long term trend(検査方式と対象) ITS4 ACSAC 2000 MC Meta-Level Compilation OSDI 2000 MOPS CCS 2002 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 プロトコル検証 複合型
  • 5.
    検査方法の分類 ■構文主導型(Syntax DirectedTranslation) - 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 モデル検査・実行系 MOPS: an infrastructure for examining security properties of software CCS2002 Chucky: exposing missing checks in source code for vulnerability discovery ccs 2013
  • 6.
    提案手法1 Main Loop Lexer 識別子(制御文、メモリ操作命令など) の検出と処理 Token Analyzer Block Handler ブロック文(繰り返し、 分岐)のネスト管理 NFA(有限オートマトン) PDA(プッシュダウンオートマトン) Document Database Key-Value 形式による 検索要求 脆弱性に 関する ドメイン 固有知識 Saturator-1 lightweight code checker with document database https://github.com/RuoAndo/Saturator-1 Key-Value(JSON) による中間表現の 構築 Iteration for each token 構文主導 方式 ルール 方式
  • 7.
    3つの検査方法:データ表現形式とドメイン固有知識 検査対象 プログラム ルール 述語論理式定理証明系 状態遷移式 正規表現 データベース モデルチェッカー 実行系 中間表現 トランスレータ・実行系 CFG 構文主導方式 ルール方式 モデル駆動 方式 ボトルネック:セキュリティに 関するドメイン固有知識
  • 8.
    提案手法2 Main Loop Lexer 識別子(制御文、メモリ操作命令など) の検出と処理 Token Analyzer Block Handler ブロック文(繰り返し、 分岐)のネスト管理 NFA(有限オートマトン) PDA(プッシュダウンオートマトン) Document Database Key-Value 形式による 検索要求 脆弱性に 関する ドメイン 固有知識 Saturator-1 lightweight code checker with document database https://github.com/RuoAndo/Saturator-1 Key-Value(JSON) による中間表現の 構築 Iteration for each token 脆弱 固有知識 の排除 ルール 方式 構文主導 方式
  • 9.
    提案手法3 Main Loop Iteration for each token Lexer 識別子(制御文、メモリ操作命令など) の検出と処理 Token Analyzer Block Handler ブロック文(繰り返し、 分岐)のネスト管理 NFA(有限オートマトン) PDA(プッシュダウンオートマトン) Saturator-1 lightweight code checker with document database https://github.com/RuoAndo/Saturator-1 Document Database 処理系の状態情報 (プログラム中の位置など) 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) 問い合わせ 格納
  • 10.
    繰り返し(For文) { “_id”: ObjectId(“53d28a5a40c2acf65bbbf9a9”), “ start_line" : "209", "end_line" : "250", " functionName" : "xc_domain_getinfo", “ functionLine" : "197", "filename" : "xc_domain.c“} {"_id" : ObjectId("53d28ab940c2acf65bbbf9b1"), "start_line" : "212", "end_line" : "253", " functionName" : "xc_domain_getinfo", "functionLine" : "200", "filename" : "xc_domain.c“} 1 void DBop realloc(char line, char functionName, char functionLine, char filename) 2 14 15 mongoc init (); 16 17 client = mongoc client new (uristr); 18 if (!client) f 19 fprintf (stderr, "Failed␣to␣parse␣URI.¥n"); 21 22 bson init (&query); 23 24 bson append utf8 (&query, "located", line); 25 bson append utf8 (&query, "functionName", -1, functionName); 26 bson append utf8 (&query, "functionLine", -1, functionLine); 27 bson append utf8 (&query, "filename", -1, filename,-1); 28 29 collection = mongoc client get collection (client, "cci", collection name); 30 31 mongoc collection insert (collection, 32 MONGOC QUERY NONE, 33 &query, 34 NULL, 35 NULL); realloc {"_id" : ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : "145 "functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", "filename" : "xc_domain.c" }
  • 11.
    評価実験CVE-2013-4371 realloc {"_id": ObjectId("53d291fe40c2acf65bbbf9f7"), "located" : "145 "functionName" : "xc_vcpu_setaffinity", "functionLine" : "116", "filename" : "xc_domain.c" } 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“} Xen-4.1.2 real 2m25.632s user 0m9.233s sys 0m23.729s > db.forloop.count() 15205 > db.function.count() 1742 > db.realloc.count() 126 Xen-4.0.1 real 4m3.567s user 0m9.289s sys 0m22.529s > db.forloop.count() 27595 > db.function.count() 3099 > db.realloc.count() 228 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.
  • 12.
    まとめ: towards lightweightand scalable code checker ■脆弱性の性質の変化と検査方法のトレンド 検査手法の性質の二極化。モデル駆動方式によるプロトコル脆弱性の解析と、 広範なテキストファイルを処理するシステム脆弱性の解析 ■スケーラビリティとFalse Negative: Key-Valueによる検査対象コードと脆弱性情報の中間表現の構築 NoSQLの適用によるアーキテクチャ面でのスケーラビリティの向上 ■脆弱性攻撃の開発スパンの短縮: ドメイン固有知識と中間表現の分離 本論文では、key-valueを処理データ構造として持つDocument Dasebaseを用いて、 ドメイン固有知識と中間表現の分離を行い(lightweight)、大規模なファイル処理に耐える システム(scalability)を構築した。 https://github.com/RuoAndo/Saturator-1 http://www.slideshare.net/RuoAndo/css2014-ruo-ando2014102301