Mucfi CERN-2
Mucfi CERN-2
Microarchitectural
Control-flow Integrity
Katharina Ceesay-Seitz, Flavien Solt,
Kaveh Razavi
1
Published at ACM Computer and Communications Security (CCS) 2024
CPU Verification
Testing, e.g., fuzzing
2
CPU Verification
Testing, e.g., fuzzing,
is incomplete
3
CPU Verification
Formal verification:
• Provides formal guarantees for
all inputs
4
CPU Verification
Formal verification:
• Provides formal guarantees for
all inputs
5
Formal Property Verification
CPU
Formal properties,
HDL e.g.,
(Hardware SystemVerilog
Description Assertions
Language)
Design describe desired
behavior
6
Formal Property Verification
Formal model
CPU
checker
CPU
Formal
properties,
e.g.,
SystemVerilog SAT(isfiability)
Assertions solver
7
Formal Property Verification
8
SIMPLER
SOLUTION?
9
CPU Verification
Formal verification:
• Provides formal guarantees for
all inputs
10
Definition Microarchitectural Control Flow (µCF)
Software program (assembly instructions)
Architectural
(software) PC
Program
Counter
(PC)
CPU
If condition
Software 'if'
PC = Branch target = A
=
Else
Branch instruction
PC = Branch target = B
11
Definition Microarchitectural Control Flow (µCF)
Software program (assembly instructions)
Architectural
(software) PC
Program
Counter
(PC)
CPU
update time
reads
secret
data
13
Microarchitectural Control Flow Violations
Constant Time (CT) program
reads
secret
data
operand:
14
Microarchitectural Control Flow Violations
Constant Time (CT) program
operand:
PROBLEM?
operand:
15
Microarchitectural Control Flow Violations
Constant Time (CT) program
operand:
operand:
Secret influences µCF
Delayed PC update PC
16
Microarchitectural Control Flow Violations
Constant Time (CT) program Control-flow integrity secure program
reads
operand:
input
data Exception
operand:
17
Microarchitectural Control Flow Violations
Constant Time (CT) program Control-flow integrity secure program
operand:
operand:
PC
operand:
18
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
Operand PC
19
ISA = Instruction Set Architecture, PC = Program Counter
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
Two threat
models
captured
20
ISA = Instruction Set Architecture, PC = Program Counter
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
21
ISA = Instruction Set Architecture, PC = Program Counter
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
22
ISA = Instruction Set Architecture, PC = Program Counter
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
Source Sink
23
ISA = Instruction Set Architecture
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
24
ISA = Instruction Set Architecture
µCFI - Microarchitectural Control-flow Integrity
• Prove that only ISA specified control and data flows exist
• Detect non-ISA specified flows
25
ISA = Instruction Set Architecture, PC = Program Counter
Formal Verification of Information Flow
[1] F. Solt, B. Gras, K. Razavi, "CELLIFT: Leveraging Cells for Scalable and Precise Dynamic Information Flow Tracking in RTL", USENIX Security 2022
26
https://github.com/comsec-group/cellift-yosys
CellIFT
CPU
Taint
logic
[1] F. Solt, B. Gras, K. Razavi, "CELLIFT: Leveraging Cells for Scalable and Precise Dynamic Information Flow Tracking in RTL", 27
USENIX Security 2022
Formal Verification of Information Flow
CPU
Formal SVA
properties
Taint
logic
28
Formal Verification of Information Flow
CPU
29
Formal Verification of Information Flow
CPU
30
Formally Verifying µCFI
Operand
PC
31
PC = Program Counter
Formally Verifying µCFI
Operand
PC
32
PC = Program Counter
Formally Verifying µCFI
Operand
PC µCFI violated??
33
PC = Program Counter
Instruction Classification
Control-influencing:
direct branches,
beq t1, t2, 20 PC
instructions with
exceptions, … control
branch
control
target
are expected
to influence
the program counter
If reg[t1] == reg[t2]
Branch target = A
Else
Branch target = B
34
Instruction Classification
µCFI
Control-influencing:
branches,
instructions with
beq t1, t2, 20 PC Operand PC
exceptions, … control
branch
control data
target
are expected
to influence
the program counter CellDFT
via control paths only If reg[t1] == reg[t2]
Branch target = A
Else
Program Counter = reg[t1]
Branch target = B Program Counter = reg[t2]
35
µCFI
CellIFT
Operand PC
information
Non-influencing:
arithmetic, logic, ...
CPU
if reg[t1] == reg[t2]
CellIFT [1]
tracks information = Taint
logic
data,
control & timing flows
36
[1] F. Solt, B. Gras, K. Razavi, "CELLIFT: Leveraging Cells for Scalable and Precise Dynamic Information Flow Tracking in RTL", USENIX Security 2022
µCFI
CellDFT – Data Flow Tracking
Operand PC
New:
data
CPU
reg[t1] == reg[t2]
37
[1] F. Solt, B. Gras, K. Razavi, "CELLIFT: Leveraging Cells for Scalable and Precise Dynamic Information Flow Tracking in RTL", USENIX Security 2022
Identifying Insecure Instructions
PC
38
Identifying Insecure Instructions
Operand
PC
39
Identifying Insecure Instructions
PC
40
Identifying Insecure Instructions
Operand
41
Identifying Insecure Instructions
Operand
43
µCFI - Verification Goals
44
µCFI - Verification Goals
To ease debugging:
• Identify the specific instruction that leaks
45
µCFI - Verification Goals
To ease debugging:
• Identify the specific instruction that leaks
PC
47
Precise Taint Injection
Instruction
x = (taint) logic abstraction Under
Verification
CPU + taint logic
REGISTERS
Instruction
MUL ADD BNE
x
start stop
Operand
taint
48
Precise Taint Injection
Instruction
Under
Verification
CPU + taint logic
REGISTERS
Instruction
MUL ADD BNE
start stop
Operand
taint
49
[1]https://github.com/YosysHQ/yosys
Declassification of Architectural Paths
Instruction
Under
Verification
CPU + taint logic
REGISTERS
Instruction
MUL ADD BNE
reg t1
Operand
Will the PC be
tainted?
50
Declassification of Architectural Paths
Instruction
Under
Verification
CPU + taint logic
REGISTERS
Instruction
MUL ADD BNE
forwarded reg t1
Operand data • Instruction result of 'add' forwarded to a
'branch' taints the PC.
instruction
result
PC
51
Declassification of Architectural Paths
Instruction
Under
Verification
CPU + taint logic
REGISTERS x
Instruction
MUL ADD BNE
forwarded reg t1
Operand
data
x • Declassification:
Block taint propagation via architectural
instruction (forwarding and register writeback) paths
result
• Forwarded data considered as instruction input
PC
• Yosys pass checks that declassified paths do
not reach the program counter
52
Declassification of Architectural Paths
buffer
Operand
PC
53
Verified Microcontroller-class, in-order CPUs
RISC-V
CPUs Ibex
Scarv
PicoRV32 Kronos
used in Zk scalar
crypto
Root-of-Trust extensions
State bits 3.2k 2.0k 2.5k 2.3k
Net bits 1.6k 1.4k 4.6k 6.7k
54
Verified Microcontroller-class, in-order CPUs
RISC-V
CPUs Ibex
Scarv
PicoRV32 Kronos
used in Zk scalar
crypto
Root-of-Trust extensions
State bits 3.2k 2.0k 2.5k 2.3k
Net bits 1.6k 1.4k 4.6k 6.7k
55
Verified Microcontroller-class, in-order CPUs
RISC-V
CPUs Ibex
Scarv
PicoRV32 Kronos
used in Zk scalar
crypto
Root-of-Trust extensions
State bits 3.2k 2.0k 2.5k 2.3k
Net bits 1.6k 1.4k 4.6k 6.7k
57
New Discovered Security Vulnerabilities
Ibex
Constant time violation: Kronos
CVE-2023-51974
Control-flow hijack
58
Conclusion
• Introduced and formalized a generalized CPU security property
59
Conclusion
• Introduced and formalized a generalized CPU security property
60
Conclusion
• Introduced and formalized a generalized CPU security property
@K_Ceesay-Seitz, @FlavienSolt
61
https://comsec.ethz.ch/ comsec-group/mucfi [email protected], [email protected]
BACKUP
62
CellIFT Yosys [1] pass
[2]
∀ cells (flip flops,
logic cells, …):
HDL RTLIL HDL
• Duplicate* in-/outputs for taint tracking
• Connect them with cell-type dependent
taint tracking logic
Taint
logic
a) State-holding
cells
b) Combinational
block
c) Gate-level
output of Yosys
*it is possible to add multiple independent taint instrumentations. Each in-/output gets a taint representation
per instrumentation.
[1] Yosys Open SYnthesis Suite - https://github.com/YosysHQ/yosys
63
[2] F. Solt, B. Gras, K. Razavi, "CELLIFT: Leveraging Cells for Scalable and Precise Dynamic Information Flow Tracking in RTL", USENIX Security 2022
Instruction classification
µCFI
information
Non-influencing:
add x4, x5, x6 PC Operand PC
arithmetic, logic, ...
information
Value-influencing:
jalr ra, x1, 80 PC
jumps
jump data
data
target
64
Taint Start Condition
Update Condition Yosys Pass
Read-from Condition = the condition in which a signal is
updated with a chosen signal's value.
Taint start
UC
Operand's register Condition in which
Yosys
data read signal the operand's register
pass
data read signal is updated
Register file name with register data
65
Taint Stop Condition
Update Condition Yosys Pass
Update Condition (UC) = the condition in which a signal is
updated with another value than its own previous value.
Taint stop UC
Operand's register Condition in which
Yosys
data read signal the read data MAY be new
pass
For example:
• enable condition of a flip flop
• '1' (True) for continuous
assignments
66
Precise Taint Injection Conditions
Instruction
Sample Instruction Word (IW) in Under
formal setup Verification
Potentially
IW == IUV and taint start condition stop
taint start
multiple taint
times per
stop
instruction
UC(s) = UC(a)
UC(s) = 1
68
Find Forwarding Multiplexer Yosys Pass
• Automatically identifies forwarding multiplexers
• Checks declassification precondition: all
outgoing paths of declassified signals reach
1. Traverse outgoing paths of
another declassified signal or data source
forwarded data output and
without passing PC
check declassification
precondition
2. If a mux uses forwarded data
output, back-traverse
multiplexers' other input's
driving logic.
forwarded 3. Is it directly assigned with
data output operand's register data read
signal?
instruction
Operand's register x input data
o No: continue at mux
output
data read signal x o Yes: Forwarding mux
found x --> return mux
select signal
69
mux = multiplexer
Formal verification of information flow
Instruction
Under
Verification
CPU + taint logic
REGISTERS
Instruction
MUL ADD BNE
forwarded
Operand data Forwarded data considered as instruction input:
PC
70
Taint injection assumptions
71
Introducing
µCFI - Microarchitectural Control-flow Integrity
Operand PC