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
Funny Systems
August 20, 2016
Technology
6
1.4k
開源編譯器,如何實現系統安全最後一哩路
COSCUP Talk
Funny Systems
August 20, 2016
Tweet
Share
More Decks by Funny Systems
See All by Funny Systems
雲端 DHCP 安全問題
funnysystems
1
1.1k
雲端資料掉光光 - GCP 事件調查真實案例
funnysystems
2
1.6k
頑固吧!GCP Cloud SQL (Why Hardening GCP Cloud SQL)
funnysystems
0
480
SMB 捲土重來 (Turning SMB Server Side Bug to Client Side)
funnysystems
0
270
跟壞鄰居想的一樣,供應鏈安全與硬體後門
funnysystems
1
740
以安全工程角度,連結實務與設計
funnysystems
0
360
FunnyPot ‐ 改造 Windows 核心,強固化、蜜罐化
funnysystems
0
720
攻擊者的視角 - 兼談匿名識別度與可追蹤性
funnysystems
1
450
黑客技術,黑科技樹 II
funnysystems
1
840
Other Decks in Technology
See All in Technology
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
16
5.6k
セキュリティの民主化は何故必要なのか_AWS WAF 運用の 10 の苦悩から学ぶ
yoh
1
160
_第3回__AIxIoTビジネス共創ラボ紹介資料_20250617.pdf
iotcomjpadmin
0
150
生成AIで小説を書くためにプロンプトの制約や原則について学ぶ / prompt-engineering-for-ai-fiction
nwiizo
4
1.8k
解析の定理証明実践@Lean 4
dec9ue
0
180
OpenHands🤲にContributeしてみた
kotauchisunsun
1
440
Fabric + Databricks 2025.6 の最新情報ピックアップ
ryomaru0825
1
140
変化する開発、進化する体系時代に適応するソフトウェアエンジニアの知識と考え方(JaSST'25 Kansai)
mizunori
1
220
BrainPadプログラミングコンテスト記念LT会2025_社内イベント&問題解説
brainpadpr
1
160
Uniadex__公開版_20250617-AIxIoTビジネス共創ラボ_ツナガルチカラ_.pdf
iotcomjpadmin
0
160
AIのAIによるAIのための出力評価と改善
chocoyama
2
550
第9回情シス転職ミートアップ_テックタッチ株式会社
forester3003
0
240
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
800
Why You Should Never Use an ORM
jnunemaker
PRO
57
9.4k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
A better future with KSS
kneath
239
17k
Done Done
chrislema
184
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
17
940
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Producing Creativity
orderedlist
PRO
346
40k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Transcript
2016/08/20 COSCUP
起點 0
Hi COSCUP Kuon,喜歡學習,特別是「安全技術」 http://Funny.Systems/ • 編譯器安全計畫
貓捉老鼠 年,貓跑不動了! 1
不能用的劍 一.學術作法 1. 程式語言 • C 語言子集合 (C-Subset) » 沒人用
• 領域專用語言 (DSL) » 更沒人用 2. 程式方法 • 函數式程式設計 (FP) » 有潛力 – 舊有風格程式碼 (Legacy Code) !?
明朝的官 二.古代作法 (~2010) 1. 作業系統 • 記憶體隨機化 (ASLR) • 記憶體不可執行
(DEP/NX) 2. 編譯器 • 堆疊溢位檢測 (StackGuard)
清朝的劍, 砍→明朝的官 二.古代作法 (~2010) 1. 作業系統 • 記憶體隨機化 (ASLR) »
有條件繞過 • 記憶體不可執行 (DEP/NX) » 可成熟繞過 2. 編譯器 • 堆疊溢位檢測 (StackGuard) » 有條件繞過 • 靜態分析 » 堪用~可用 – 掃描完,修不完!
還在發 Paper 階段 三.其他作法 1. 軟體驗證 (Verification) » (軍)工業等級 •
But … 如果你還想加個新功能 (大驚!) 2. 執行檔二次處理 » 有時候需要 3. 虛擬化 » 看怎麼使用
軟體安全 系統安全 • OS – Kernel • TCB (Trust Computing
Base) – Hypervisor • Firmware – TrustZone
安全觀 2
聯網性、持續性
聯網性、持續性
聯網性、持續性
跨界 • 軟體缺陷,到底是不是安全問題? 1. Null Pointer 2. Undefined Behavior
跨界 • 軟體缺陷,到底是不是安全問題? 1. Null Pointer » OS 有關 2.
Undefined Behavior » 已經是了
思路 (Idea) 怎麼進去機場裡面? »
思路 (Idea) « 另一個切入點 »
http://www.appledaily.com.tw/appledaily/article/headline/20110708/3351 3284/
弱點 (Flaw) Uninitialized Memory、Dangling Pointer Use-After-Free、Double Free Use-After-Return、Use-After-Destructor Null Pointer
(Dereference) Type Confusion Race Condition、Data Race、TOCTOU
輔助 (Helper) Non-randomized Memory RWX Memory (ex:JIT) Info Leak、Memory Disclosure
利用 (Exploit) ROP、JOP、IOP、LOP、SOP、SROP、BROP Data Reuse、Non-Control-Data Attack DOP COOP CROP JIT
Spray、Heap Spray Stack Spray Stack Pivot 、Stack Hooking
未知攻、焉知防
未知攻、焉知防
建立好的防守 比攻擊更困難
編譯器 3
C 語言 • Integer 、Float • Pointer 、Array 、Vector 、Structure
、 Function
記憶體空間 • Stack • Heap • Global
編譯器 • Module • Function • Basic Block • Instruction
編譯器 + 安全 4
軟體安全 粒度 效能 相容性
相容性 • Architecture • OS • Kernel-mode vs. User-mode •
Compiler Extension • Toolchain
安全編譯階段 1. 建模 2. 解構 3. 轉換 4. 合成
None
C/C++ 語言 • Pointer – Code Pointer – Data Pointer
– Object Pointer
C/C++ 語言 • Pointer – Code Pointer • Return Address
• Function Pointer • Method Pointer • Virtual Function Pointer – Data Pointer – Object Pointer
C 語言 • Pointer – 完整性(效驗) • Return Address –
隔離性 • Return Address – 不可預測性 • Function Pointer、Method Pointer
C 語言 • Array、Global Data – 方向性 • Overflow •
Underflow – 隔離性 • 邊界防禦
記憶體空間 • Stack、Global – 讀寫模型 (Read-Write Model) – 順序性 •
依變數型態 – 不可預測性 • 變數間距
編譯器階段 • Function – 不可預測性 • 函數間距 – 完整性(效驗) •
函數依賴關係
編譯器階段 • Instruction – 不可預測性 • 指令位址隨機化 • 指令序列混淆 –
抑制 ROP 手法 • 指令序列黑名單
用老虎、抓老鼠 5
None
StackGuard • 1998 年提出,GCC & LLVM • 透過編譯器,在 Stack Frame
的 Return Address 前,插入 Canary/Cookie 。 – 用來抑制 Stack Overflow 問題 – Function Pointer on Stack – fork()
CFI – Control Flow Integrity • 2005 年提出,LLVM • 透過編譯器,針對
Direct/Indirect Control Flow 作完整性驗證 – Call Site & Call Target 互相配對 – 用來抑制 ROP 問題 – Mixing Function Chain & ROP Chain • 3rd Party • Legacy Code • Edge Case
SafeStack • 2005 年左右提出,LLVM • 透過編譯器,依照 Stack 內,變數的各種安 全屬性,重新分配到記憶體其他段落 –
一種 Dual Stack 策略 – Nested Function – Resize Stack at Runtime
VTV – Virtual Table Verification • 2014 年提出,GCC & LLVM
• 透過編譯器,針對 Virtual Table 結構,和 Virtual Function 呼叫,中間插入一層驗證 機制 – 主要用來抑制 Use-After-Free – Instantiated Template – tcmalloc
攻守同源 奇正相長
Q&A