Media A Senior ・Interested in lower layer security around OS and CPU. Having Researched KASLR deployment using Prekern at SecHack365. A Japanese security Hackathon 2
for embedded systems. → Execute vulnerable test programs on embedded system, launch ROP Attack(details later). →Emulate both high spec and low spec embedded devices using QEMU. 3
IoT devices. → Due to various restrictions in some embedded devices, cannot deploy rich security systems. ・Low Power ・Small Capacity ・Low Electricity Consumption ・High Power ・Large Capacity ・High Electricity Consumption 4
an attack combining code execution snippets inside a program to perform arbitrary processing. →Derivative techniques of ROP attacks are being researched. ・ROP attacks can be utilized to various architectures. 5
Control-Flow Integrity Drawback: High cost to execute the security controls. →Implementing security control in low-spec embedded devices is difficult. 6
devised to circumvent Nxbit security control. ・No eXecutable bit (NX bit) → Security control that disables code execution of code set in the heap or stack region. This can hinder shell code execution by exploiting stack overflow vulnerabilities. 8
fragments called gadgets into a ROP chain. Command fragment 1 Command fragment 2 Command fragment 3 Command fragment 4 Command fragment 5 Command fragment 6 Ordinary Execution File Command Fragment 1 Command Fragment 3 Command Fragment 5 Command Fragment 6 ROP Chain Collect command fragments needed for attack Code Region Data Region Execution File ROP Chain Embed into ROP Chain 9
Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code buf (0x10) rbp rsp saved rbp Return Address rbp + 8 ! ! ! Stack Region Register rdi: Store parameter 1 rsi: Store parameter 2 rdx: Store parameter 3 rip: Store next address for execution rbp: Store lowest address inside the stack frame rsp: Store stack top address 10
with ‘A’ ROP on x86_64 Assembly Command Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 11 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code buf (0x10) rbp rsp saved rbp Return Address rbp + 8 ! ! ! Stack Region Register rdi: Store parameter 1 rsi: Store parameter 2 rdx: Store parameter 3 rip: Store next address for execution rbp: Store lowest address inside the stack frame rsp: Store stack top address
‘system’ actual address ・After embedding ROP Chain Assembly Command Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 12 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code Stack Region Register rdi: Store parameter 1 rsi: Store parameter 2 rdx: Store parameter 3 rip: Store next address for execution rbp: Store lowest address inside the stack frame rsp: Store stack top address
‘system’ actual address Assembly Command Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 13 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code Stack Region Register rdi: Store parameter 1 rsi: Store parameter 2 rdx: Store parameter 3 rip: 0x400100 rbp:0x4141414141414141 rsp: Store stack top address ・Right after processing functions (pop rbp; ret;)
rdi at pop rdi execution ・pop rdi execution time Assembly Command Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 14 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code Stack Region AAAAAAAA AAAAAAAA rsp AAAAAAAA 0x400100 “/bin/sh” Address ‘system’ actual address Register rdi: “/bin/sh” address rsi: Store parameter 2 rdx: Store parameter 3 rip: 0x400102 rbp:0x4141414141414141 rsp: Store stack top address
gets stored in rip ・ret execution time Assembly Command Used pop xxx: Contain rsp value into xxx register ret: Same value for pop rip 15 0x400100: pop rdi 0x400102: ret : 0x400200: pop rsi 0x400202: ret : 0x400300: pop rdx 0x400302: ret : Assembly Code Stack Region AAAAAAAA AAAAAAAA rsp AAAAAAAA 0x400100 “/bin/sh” Address ‘system’ actual address Register rdi: “/bin/sh” address rsi: Store parameter 2 rdx: Store parameter 3 rip: ‘system’ actual address rbp:0x4141414141414141 rsp: Store stack top address
is a security measurement that randomize the address space where program code and data are stored, which makes access to specific code and data difficult. KASLR is ASLR deployed to the kernel 16
Address rbp + 8 ! ! ! Stack Region Register rdi: Store parameter 1 rsi: Store parameter 2 rdx: Store parameter 3 rip: Store next address for execution rbp: Store lowest address inside the stack frame rsp: Store stack top address 17 0x400100: 0x400102: : 0x400200: 0x400202: : 0x400300: 0x400302: : pop rdi ret pop rsi ret pop rdx ret ?????? ?????? ?????? ?????? ?????? ?????? Address of the instruction has been randomized, so building ROP chains is not possible.
ROP attacks. →Find embedded devices that can be overtaken with simple ROP ・Use QEMU to emulate embedded devices. →QEMU enables us to check the register and memory content in the guest environment. 22
Security Symposium2022, I received the following proposal. 40 ・Stack protection →Detecting Return address errors ・Simplified CFI →Detecting ROP-specific memory violations by monitoring control flow. Invalid function calls occur after ROP.
program gaining control is possible with a simple ROP attack. ・Consider implementing ROP countermeasures in low spec embedded devices, implement security measures if necessary. 41
Communications Technology organized SecHack365 and its trainer Hiroaki Sakai , who showed the basics of program execution and debug methods, which this research is founded upon. Thank you Mr.Sakai and all SecHack365 staff. 42