Skip to content

Core Software Fundamentals

DJShepherd edited this page Mar 1, 2024 · 8 revisions

Programming Languages

C/C++ Translation to Machine Code

Safety Proven Languages

  • C and C++ has been the most popular languages for embedded and low level applications for a while since:
    • The language is meant to be platform agnostic
    • Code directly translates to machine code (as opposed to high level language intermediate bytecode)
    • Allows for fine control of the software stack, design, CPU, etc
  • However, because of the open-endedness of control given to developers, it is much more prone to bugs, and thus, security vulnerabilities.
  • More modern languages have been emerging to tackle removing the most common and critical of vulnerabilities since the language is secure, by design, with things like garbage collection, length constrained array buffers, etc.
    • Rust (most upcoming and popular amongst security driven embedded projects)
    • Ada
    • Lua

CPU fundamentals

System/OS fundamentals

Memory Paging

Assembly

  • Basic understanding of assembly design
    • Calling conventions (stack owner, argument passing)
    • Prolog, epilog (stack manipulation, return address)
    • Local variables/stack access
    • Registers/flags
    • Standard/common control flows
    • Common optimization techniques
      • Control flow optimizations
      • Integer bit tricks/data manipulation optimizations
    • Execution context switching
      • Thread switching
      • Interrupt processing
  • RISC vs CISC architectures
  • RISCV - Used in a lot of custom/proprietary controllers/sub systems
  • ARM - Used for a lot of public/consumer IoT products
  • X86/64 - Home/business computers
  • Instruction pipelines

Interrupts

Inter Process Communication (IPC) designs

Secure System Software Layers

  • What they do/contain, how they provide security, etc

Security Modules

Hypervisor

  • Multi OS system
    • For consumer/IoT devices, it isolates a vulnerable user OS from a trusted, higher privileged system OS
    • In a cloud environment, it isolates separate customer’s OS’ from each other
  • Hypervisor - Geeks for Geeks
    • Type 1 HV: bare metal. Better VM isolation but less support for peripherals, cross VM communication, etc.
    • Type 2 HV: Container inside a host OS. Better support for host to container communication, peripherals, etc. But not as good isolation and more risk of container breakout to host.

Kernel

OS/User Mode

Containers

  • A container is a method used for cloud application deployment that isn’t as secure/isolated as compared to using a VM.
  • A container application runs as a normal application within a host OS alongside other deployed container applications. Container applications are configured with a set of versioned support libraries that make it run in a constantly defined environment, regardless of the host OS.
  • Popular modern host OS’ have containerization support that help with security and isolation, such as a sandbox environment (isolated view of files, system resources, etc) and fine-grained permissions (accessible socket ports, files, system resources, etc).
  • Because it runs in the context of a shared host OS, any vulnerable or malicious container application can put the system at risk of compromising the host and all other containers, resources, etc. If the host OS provides containerization features, this would require using an exploit to break out of the container sandbox to gain system level access (“container/sandbox escape”).
  • Security can be comparable to a Type 2 hypervisor where the hypervisor runs in the host OS. The main difference is that containers will interact with the host OS kernel while applications in a VM will interact with the hosted VM kernel. Container Escape is comparable to VM Escape.

VM Protection from Hypervisor

  • Modern CPU's on Cloud infrastructure have HW extensions to securely isolate VM's from the HV with an integrated crypto engine on main memory bus.
  • After the HV configures and deploys the VM, the VM becomes a black box to the HV such that the HV can only see the encrypted bytes of the VM memory.
  • AMD SEV (PDF)
  • Intel SGX vs TDX

System Boot, Drivers

Registers

Driver Development

Bootstrapping

I/O, Direct Memory Access (DMA)

Common Bus Protocols

  • Basic familiarity
  • UART
  • I2C
  • JTAG
  • SPI

Common Driver Stacks

  • Basic familiarity
  • USB
  • Network
  • Bluetooth