Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
カーネル空間からのセキュリティ
Search
Ren Kimura
August 13, 2015
Research
5
6.1k
カーネル空間からのセキュリティ
Introduction to kernel level security talked in seccamp15.
Ren Kimura
August 13, 2015
Tweet
Share
More Decks by Ren Kimura
See All by Ren Kimura
Ideas for defeating Anti-Deep-Fakes
rkx1209
0
40
セキュリティベンチャーのリスク管理
rkx1209
0
83
ファジング+トリアージ技術を用いた脆弱性解析自動化
rkx1209
0
71
Introduction to Fuzzing
rkx1209
6
4.2k
ARM TrustZone エクスプロイト入門
rkx1209
7
8k
The Game is Over. Nintendo switch has been totally compromised
rkx1209
9
5.1k
インサイドNintendo Switch
rkx1209
18
13k
More efficient remote debugging with Thin Hypervisor
rkx1209
3
2.5k
Reverse Debugging with radare2
rkx1209
6
1.9k
Other Decks in Research
See All in Research
ラムダ計算の拡張に基づく 音楽プログラミング言語mimium とそのVMの実装
tomoyanonymous
0
440
地理空間情報と自然言語処理:「地球の歩き方旅行記データセット」の高付加価値化を通じて
hiroki13
1
230
EarthMarker: A Visual Prompting Multimodal Large Language Model for Remote Sensing
satai
3
180
Individual tree crown delineation in high resolution aerial RGB imagery using StarDist-based model
satai
3
190
Weekly AI Agents News! 2月号 アーカイブ
masatoto
1
150
The Economics of Platforms 輪読会 第1章
tomonatu8
0
170
Batch Processing Algorithm for Elliptic Curve Operations and Its AVX-512 Implementation
herumi
0
140
o1 pro mode の調査レポート
smorce
0
150
(NULLCON Goa 2025)Windows Keylogger Detection: Targeting Past and Present Keylogging Techniques
asuna_jp
1
370
Prithvi-EO-2.0: A Versatile Multi-Temporal Foundation Model for Earth Observation Applications
satai
3
330
作業記憶の発達的特性が言語獲得の臨界期を形成する(NLP2025)
chemical_tree
2
450
eAI (Engineerable AI) プロジェクトの全体像 / Overview of eAI Project
ishikawafyu
0
440
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Writing Fast Ruby
sferik
628
61k
Product Roadmaps are Hard
iamctodd
PRO
52
11k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Building an army of robots
kneath
304
45k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
GitHub's CSS Performance
jonrohan
1030
460k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
Building Adaptive Systems
keathley
41
2.5k
Transcript
カーネル空間からの セキュリティ セキュリティキャンプ2015 全国大会 @RKX1209
自己紹介 • るくす(@RKX1209) • 神戸大学 工学部 B3 • seccamp'14 ソフトウェアセキュリティクラス卒業
• seccamp'15 解析トラックチューター
話すこと • Kernel Exploitによる権限昇格と対策 • rootkitによる汚染と対策 • Kernelセキュリティの動向 ring0で繰り広げられる仁義なき戦い
Kernel Exploitによる権限昇格と対策
Kernel exploit • カーネル空間における不正なコード実行やメモリ破 壊などによるexploit • 最高権限を持つカーネル空間への攻撃 => 成功した場合非常に危険 •
ただし制約が厳しい場合が多い => 高度なテクニックを要求される
Kernel exploit • Local (kernel) exploit => ローカルにログインした状態での権限昇格 ex. BadIRET(CVE-2014-9322),
Futex Bug(CVE-2014-3153) • Remote (kernel) exploit => 外部からのpayload参入などによる権限昇格 ex. ROSE(CVE-2011-1493), SCTP(CVE-2009-0065)
BadIRET(CVE-2014-9322) • カーネルのsystemcall処理中のダブルフォルト発 生がトリガー • 不正なSSセグメントを設定した状態でiret • iret前に余分なswapgsが実行されGSセグメントに 任意の値を設定できる脆弱性 =>
現在殆ど資料が無いためもう少し詳しく...
BadIRET(CVE-2014-9322) • ユーザー空間にてSS=(不正な値) GS=(任意の値) に設定する • swapgsによって現在のGSにユーザー空間で設定 したGS(任意の値)が設定される • この状態でgeneral_protectionに飛ぶ
[1] bad_iret: pushq $0 SWAPGS jmp general_protection [2] do_general_protection (GS = arbitrary value) …..
BadIRET(CVE-2014-9322) • general_protection内でcurrent→tsk→threadに0 を設定する処理がある • currentは%gs:0xc780とアクセスされるためGSを 書き換えると任意のアドレスに0を設定する事がで きる • どこを書き換えるか?
=> カーネル内で関数ポインタをもつデータ構造 ここではproc_root->inode_operationsにする
BadIRET(CVE-2014-9322) • 何に書き換える? => カーネル内のROP gadgetのアドレス • Stack pivotを行い シェルコードを実行
• カーネルモードで動作 しているためシェルコード 内でroot昇格可能
kernel exploit対策 • Intel SMEP => カーネルモード時はユーザー空間のコードを実行出 来ないようにする 第3世代(Ivy Bridge)以降のCPUが搭載
• Intel SMAP => カーネルモード時はユーザー空間のデータにアクセス 出来ないようにする BadIRETはSMEPをバイパス可能 しかしユーザー空間のデータFAKE_IOPSなどを利用するため SMAPはバイパスできない
rootkitによる汚染と対策
rootkit • システムに侵入後、使用されるソフトウェアツールの セット • 痕跡消去,backdoor作成など • カーネルレベルの物とユーザーレベルの物がある => 今回は前者について
LKM rootkit • LKM(Loadable Kernel Module)を利用したrootkit • システムコールの書き換えにより自身の隠蔽などを 行う •
Knark, Adore, Rkitなど多くの種類が存在 • カーネルレベルから偽装されるため解析が非常に 困難
Anti rootkit • Kernel Module Signing => 署名されたモジュールしかロードさせない • NICKLE
=> memory shadow-ingを用いてメモリ検証 VMMとして実装されている • RG(Rootkit Guard) => Teh Jia Yew(2013)のペーパーより
RG(Rootkit Guard) • Rootkitの検知を行うRIDS, 防止を行うRIPSにより 構成 • Linux IMAによりあらかじめ正しいファイルやモジュー ルのデータベースを作成(SHA1)
• ユーザーの定義したクリティカルなファイルは暗号化 されたパーティションに格納(TPMを利用) • ファイル保護にはSELinuxを用いる • ブート時の汚染を防ぐためtrusted GRUBを利用する
RG(Rootkit Guard)
Kernelセキュリティの動向
Kernel security • PaXなどのセキュリティパッチ • “Return-less” kernel • LLVM Linux
• Trinity(fuzzing) • Symbolic実行
PaX • grsecurityによる、最小特権保護を実装したLinux カーネル向けセキュリティパッチ • カーネルスタックアドレスのrandomize • SMAPを模したUDEREF • スタックの再利用防止STACKLEAK
=> 多くのセキュリティ機構をカーネルに加える
Return-less kernel • カーネルからret命令を排除する • EuroSys10にて公開 • Kernel exploitやrootkitにおけるカーネル内のROP gadget利用を防止する
• LLVMを用いて実装されている
LLVM Linux • Linux kernelをclang(LLVM)でコンパイルするプロ ジェクト • Linux kernelのコードにはgcc拡張が多いためメイ ンラインへの統合は難しい
• LLVM static analyzerを用いたkernelコードの検証 にも応用可能 => “Applying Clang Static Analyzer to Linux Kernel” LinuxCon(2012)
Trinity(kernel fuzzing) • カーネルのfuzzing用ツール • hardeningというよりはdetection • 様々なパラメータによるシステムコールの呼び出し を行う •
開発者が疲弊してるらしく存続するかは不明....
Symbolic実行 • ソフトウェアテスト手法の一つ • どの入力値でどの実行経路を通るか特定する • 計算量爆発が起こるため多くの場合は動的symbolic実行 を行う • LLVM
bitcodeを用いたKLEEなどがある => カーネルドライバなどの開発においてこれらを用いるの は現実的か? => 現在の開発体制ではテスト方式は決まっていない => 開発サイクルとのトレードオフ
おわりに • カーネルに関わるセキュリティ技術に関して3つの 観点から紹介しました • ユーザー空間とは比較にならないほどの危険が潜 む • 高度なテクニックやシステムに関する深い知識が要 求される
ユーザー空間では物足りないと思ったら カーネル空間にダイブしてみましょう
reference • Rootkit Guard (RG) - An Architecture for Rootkit
Resistant File-System Implementation Based on TPM [http://psasir.upm.edu.my/30621/] • Return-Oriented Rootkits: Bypassing Kernel Code Integrity Protection Mechanisms [https://www.usenix.org/legacy/event/sec09/tech/full_papers/hund.pdf] • ももいろテクノロジー [http://inaz2.hatenablog.com/] • 『A Guide to Kernel Exploitation: Attacking the Core』(Massimiliano Oldani pub. Syngress 2010) • 一生あとで読んでろ [http://ntddk.github.io/] • Writing kernel exploits [http://kmcallister.github.io/talks/security/2012-kernel-exploits/talk.pdf] • Anatomy of a Remote Kernel Exploit [http://vulnfactory.org/research/h2hc-remote.pdf] • Applying Clang Static Analyzer to Linux Kernel(LinuxCon 2012) [https://events.linuxfoundation.org/images/stories/pdf/lcjp2012_matsumotoh.pdf] • Defeating Return-Oriented Rootkits with "Return-less"Kernels [http://eurosys2010.sigops-france.fr/slides/eurosys2010_session6_talk15.pdf]