SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
今回説明する脆弱性
[1] Assertion failure CVE-2015-5722 (DNS BIND series)
[2] User-after-free CVE-2013-4371 Xen hypervisor
[1] Assertion failure CVE-2015-5722 (DNS BIND series)
表明(assertion):そのプログラムの前提条件を示すのに使われる。表明は、プログラムのその箇所で必ず真で
あるべき式の形式をとる。表明が偽となった場合、プログラムにバグが潜在していることを示している。これを
assertion failureと呼ぶ。
■エラー処理ルーチン:通常発生しうるエラーを処理する
■表明(アサーション):論理的にありえない状況をチェックするのに使う
int *ptr = malloc(sizeof(int) * 10);
assert(ptr != NULL);
mallocの失敗はプログラム内では、論理的にはまず起こりえないことになっているが、オペレーティングシステ
ムは malloc が常に成功することは保証していない。システム上ではmallocが失敗して、ptrにnullが入ることが
ある。
int *ptr;
assert(ptr = malloc(sizeof(int) * 10)); // malloc() が失敗するとNULLを返す。
この文は特定のオプションでコンパイルすると実行されなくなり、結果としてptrが初期化されずに参照されるこ
とになる。
検出対象①
CVE-2015-5722 Parsing malformed keys may
cause BIND to exit due to a failed assertion in buffer.c
isc_result_t
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t
**dynbuffer, unsigned int length)
{
isc_buffer_t *dbuf;
REQUIRE(dynbuffer != NULL);
REQUIRE(*dynbuffer == NULL);
dbuf = isc_mem_get(mctx, length +
sizeof(isc_buffer_t));
if (dbuf == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_init(dbuf, ((unsigned char *)dbuf) +
sizeof(isc_buffer_t), length);
dbuf->mctx = mctx;
ENSURE(ISC_BUFFER_VALID(dbuf));
*dynbuffer = dbuf;
return (ISC_R_SUCCESS);
}
bind-9.9.9-P3/lib/isc/include/isc/assertions.h:101:#define
ISC_ENSURE(cond) ((void) 0)
94#if ISC_CHECK_ENSURE != 0
95#define ISC_ENSURE(cond) ¥
96 ((void) ((cond) || ¥
97 ((isc_assertion_failed)(__FILE__, __LINE__, ¥
98 isc_assertiontype_ensure, ¥
99 #cond), 0)))
100#else
101#define ISC_ENSURE(cond) ((void) 0)
102#endif /* ISC_CHECK_ENSURE */
diff -ur bind-9.9.8/lib/isc/buffer.c bind-9.9.9-P3/lib/isc/buffer.c
--- bind-9.9.8/lib/isc/buffer.c 2015-09-09 11:23:50.000000000 +0900
+++ bind-9.9.9-P3/lib/isc/buffer.c 2016-09-09 11:47:21.000000000
+0900
@@ -1,5 +1,5 @@
@@ -462,6 +462,8 @@
+ ENSURE(ISC_BUFFER_VALID(dbuf));
+
*dynbuffer = dbuf;
return (ISC_R_SUCCESS);
上記パッチより、 bind-9.9.8に脆弱性があることが確認できる。
Attack surfaceの削減: 削除可能パスの検出
/bind-9.9.9-P2# global -rx setup_system
setup_system 1897 bin/dig/dig.c setup_system();
setup_system 898 bin/dig/host.c setup_system();
setup_system 333 bin/dig/include/dig/dig.h setup_system(void);
setup_system 913 bin/dig/nslookup.c setup_system();
setup_system 3147 bin/nsupdate/nsupdate.c setup_system();
削除可能パス
CVE-2015-5722 Parsing
malformed keys may cause
BIND to exit due to a failed
assertion in buffer.c
[2] User-after-free (aka heap spray) : CVE-2013-4371 Xen hypervisor
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
Use-after-free 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);
420 }
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の返り値がポインタ
Attack surfaceの削減: 削除可能パスの検出 # global -t cmdtable_lookup
cmdtable_lookup tools/libxl/xl_cmdtable.c 390
20struct cmd_spec cmd_table[] = {
34 { "list",
35 &main_list,
36 "List information about all/some domains",
37 "[options] [Domain]¥n",
38 "-l, --long Output all VM details¥n"
39 "-v, --verbose Prints out UUIDs",
40 },
134 { "migrate-receive",
135 &main_migrate_receive,
136 "Restore a domain from a saved state",
137 "- for internal use only",
138},
341 { "cpupool-create",
342 &main_cpupoolcreate,
343 "Create a CPU pool based an ConfigFile",
344 "[options] <ConfigFile> [vars]",
345 "-h, --help Print this help.¥n"
346 "-f=FILE, --defconfig=FILE Use the given
configuration file.¥n"
347 "-n, --dryrun Dry run - prints the
resulting configuration."
348 },
削除可能パス

Mais conteúdo relacionado

Mais de Ruo Ando

Mais de Ruo Ando (20)

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

Último

TokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentationTokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentation
YukiTerazawa
 
The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024
koheioishi1
 

Último (7)

TokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentationTokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentation
 
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
 
次世代機の製品コンセプトを描く ~未来の機械を創造してみよう~
次世代機の製品コンセプトを描く ~未来の機械を創造してみよう~次世代機の製品コンセプトを描く ~未来の機械を創造してみよう~
次世代機の製品コンセプトを描く ~未来の機械を創造してみよう~
 
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
 
2024年度 東京工業大学 工学院 機械系 大学院 修士課程 入試 説明会 資料
2024年度 東京工業大学 工学院 機械系 大学院 修士課程 入試 説明会 資料2024年度 東京工業大学 工学院 機械系 大学院 修士課程 入試 説明会 資料
2024年度 東京工業大学 工学院 機械系 大学院 修士課程 入試 説明会 資料
 
The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024
 
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
 

【技術解説4】assertion failureとuse after-free

  • 1. 今回説明する脆弱性 [1] Assertion failure CVE-2015-5722 (DNS BIND series) [2] User-after-free CVE-2013-4371 Xen hypervisor
  • 2. [1] Assertion failure CVE-2015-5722 (DNS BIND series) 表明(assertion):そのプログラムの前提条件を示すのに使われる。表明は、プログラムのその箇所で必ず真で あるべき式の形式をとる。表明が偽となった場合、プログラムにバグが潜在していることを示している。これを assertion failureと呼ぶ。 ■エラー処理ルーチン:通常発生しうるエラーを処理する ■表明(アサーション):論理的にありえない状況をチェックするのに使う int *ptr = malloc(sizeof(int) * 10); assert(ptr != NULL); mallocの失敗はプログラム内では、論理的にはまず起こりえないことになっているが、オペレーティングシステ ムは malloc が常に成功することは保証していない。システム上ではmallocが失敗して、ptrにnullが入ることが ある。 int *ptr; assert(ptr = malloc(sizeof(int) * 10)); // malloc() が失敗するとNULLを返す。 この文は特定のオプションでコンパイルすると実行されなくなり、結果としてptrが初期化されずに参照されるこ とになる。
  • 3. 検出対象① CVE-2015-5722 Parsing malformed keys may cause BIND to exit due to a failed assertion in buffer.c isc_result_t isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer, unsigned int length) { isc_buffer_t *dbuf; REQUIRE(dynbuffer != NULL); REQUIRE(*dynbuffer == NULL); dbuf = isc_mem_get(mctx, length + sizeof(isc_buffer_t)); if (dbuf == NULL) return (ISC_R_NOMEMORY); isc_buffer_init(dbuf, ((unsigned char *)dbuf) + sizeof(isc_buffer_t), length); dbuf->mctx = mctx; ENSURE(ISC_BUFFER_VALID(dbuf)); *dynbuffer = dbuf; return (ISC_R_SUCCESS); } bind-9.9.9-P3/lib/isc/include/isc/assertions.h:101:#define ISC_ENSURE(cond) ((void) 0) 94#if ISC_CHECK_ENSURE != 0 95#define ISC_ENSURE(cond) ¥ 96 ((void) ((cond) || ¥ 97 ((isc_assertion_failed)(__FILE__, __LINE__, ¥ 98 isc_assertiontype_ensure, ¥ 99 #cond), 0))) 100#else 101#define ISC_ENSURE(cond) ((void) 0) 102#endif /* ISC_CHECK_ENSURE */ diff -ur bind-9.9.8/lib/isc/buffer.c bind-9.9.9-P3/lib/isc/buffer.c --- bind-9.9.8/lib/isc/buffer.c 2015-09-09 11:23:50.000000000 +0900 +++ bind-9.9.9-P3/lib/isc/buffer.c 2016-09-09 11:47:21.000000000 +0900 @@ -1,5 +1,5 @@ @@ -462,6 +462,8 @@ + ENSURE(ISC_BUFFER_VALID(dbuf)); + *dynbuffer = dbuf; return (ISC_R_SUCCESS); 上記パッチより、 bind-9.9.8に脆弱性があることが確認できる。
  • 4. Attack surfaceの削減: 削除可能パスの検出 /bind-9.9.9-P2# global -rx setup_system setup_system 1897 bin/dig/dig.c setup_system(); setup_system 898 bin/dig/host.c setup_system(); setup_system 333 bin/dig/include/dig/dig.h setup_system(void); setup_system 913 bin/dig/nslookup.c setup_system(); setup_system 3147 bin/nsupdate/nsupdate.c setup_system(); 削除可能パス CVE-2015-5722 Parsing malformed keys may cause BIND to exit due to a failed assertion in buffer.c
  • 5. [2] User-after-free (aka heap spray) : CVE-2013-4371 Xen hypervisor 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関数は第一引数で渡したポインタのアドレス位置 から拡張できない場合は新しい場所にメモリ確保を行う。 結果として、内容は保持されるがアドレスが変わる場合がある。 弊害:フラグメンテーションの深刻化・確保された場所は初期化が保障されない。
  • 6. 検査対象② CVE-2013-4371 Use-after-free 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); 420 } 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の返り値がポインタ
  • 7. Attack surfaceの削減: 削除可能パスの検出 # global -t cmdtable_lookup cmdtable_lookup tools/libxl/xl_cmdtable.c 390 20struct cmd_spec cmd_table[] = { 34 { "list", 35 &main_list, 36 "List information about all/some domains", 37 "[options] [Domain]¥n", 38 "-l, --long Output all VM details¥n" 39 "-v, --verbose Prints out UUIDs", 40 }, 134 { "migrate-receive", 135 &main_migrate_receive, 136 "Restore a domain from a saved state", 137 "- for internal use only", 138}, 341 { "cpupool-create", 342 &main_cpupoolcreate, 343 "Create a CPU pool based an ConfigFile", 344 "[options] <ConfigFile> [vars]", 345 "-h, --help Print this help.¥n" 346 "-f=FILE, --defconfig=FILE Use the given configuration file.¥n" 347 "-n, --dryrun Dry run - prints the resulting configuration." 348 }, 削除可能パス