Embedded System Design: How It's Different from Traditional Software Design
This talk provides a foundational overview of embedded system architecture, focusing on the critical differences between embedded and traditional software development. It highlights the importance of hardware-software co-design, the role of peripheral control registers, and the necessity of understanding datasheets for effective system interaction. The presentation emphasizes how improper handling of hardware interfaces and peripheral configurations can introduce exploitable vulnerabilities, such as those found in I2C drivers.
Why Your Next Embedded Target Is Probably Vulnerable to I2C Driver Exploitation
TLDR: Embedded systems often rely on vendor-provided libraries that abstract away hardware complexity, but these abstractions frequently hide critical security flaws. Researchers are finding that improper input validation in I2C drivers allows for memory corruption and arbitrary code execution. Pentesters should stop treating firmware as a black box and start auditing the peripheral communication layer to find these low-level bugs.
Hardware-software co-design is the standard for modern embedded systems, but it creates a massive blind spot for security researchers. When developers build on top of vendor-provided Hardware Abstraction Layers (HALs), they often assume the underlying drivers are secure. This assumption is dangerous. Recent research into ARM Cortex-M4 based systems shows that the complexity of managing peripheral control registers is where most vulnerabilities are born. If you are auditing an IoT device, you need to look past the high-level application code and start analyzing how the firmware interacts with its peripherals.
The Hidden Complexity of Peripheral Control
Embedded devices are not just small computers. They are systems where the software is tightly coupled to the hardware. A developer writing code for an STM32 or an ESP32 is not just managing memory; they are toggling bits in specific memory-mapped registers to control hardware peripherals like I2C, SPI, or UART.
The vulnerability often lies in the gap between the datasheet and the implementation. A datasheet might be 1,700 pages long, detailing every possible state of a peripheral. A developer, under pressure to meet a time-to-market deadline, will almost always reach for a vendor-supplied library to handle this complexity. These libraries are designed for efficiency, not security. They often lack the input validation you would expect in a standard web application. When a driver function takes a buffer from an external sensor and writes it directly to a memory-mapped register without checking the bounds, you have a classic buffer overflow waiting to happen.
Auditing the I2C Communication Layer
I2C is a common target because it is a multi-drop, multi-master protocol used to connect sensors, displays, and other components. If an attacker can influence the data coming from an I2C sensor, they can potentially trigger a vulnerability in the driver that processes that data.
Consider a scenario where a device reads data from an I2C-connected sensor. The firmware might use a function like this to process the incoming bytes:
void process_sensor_data(uint8_t *data, uint16_t length) {
uint8_t buffer[32];
// Vulnerable: No check on length before copying to buffer
memcpy(buffer, data, length);
}
This is a textbook OWASP A06:2021 – Vulnerable and Outdated Components issue. In an embedded context, this isn't just about crashing the process. It's about overwriting adjacent memory-mapped registers. If you can overwrite the configuration register of a different peripheral, you can change the system's behavior, disable security features, or redirect execution flow.
How to Approach Your Next Engagement
When you get your hands on a target, your first step should be to identify the communication protocols in use. Use a logic analyzer to capture the traffic between the main processor and its peripherals. If you see an I2C bus, that is your primary attack surface.
Don't just look for command injection. Look for how the firmware handles the data it receives. If you can dump the firmware using a JTAG or SWD debugger, you can reverse engineer the driver code. Look for functions that interact with the I2C data register. If you find a function that copies data from the I2C peripheral to a fixed-size buffer, you have found a potential exploit vector.
During a test, you can use a tool like a Bus Pirate to act as a malicious I2C master. By sending malformed packets to the target device, you can test if the driver handles unexpected lengths or invalid data gracefully. If the device reboots or behaves erratically, you have successfully identified a flaw in the driver's logic.
Defensive Strategies for Firmware Developers
Defending against these attacks requires a shift in how firmware is developed. First, stop trusting vendor libraries. Every function that interacts with a peripheral must treat the input as untrusted. If you are using a library, audit the source code for buffer copies and ensure that all inputs are validated against the expected size and format.
Second, implement hardware-level protections where possible. Many modern microcontrollers, such as those in the ARM Cortex-M series, support Memory Protection Units (MPUs). You can use an MPU to restrict access to critical memory regions, ensuring that even if a buffer overflow occurs, the attacker cannot overwrite sensitive registers or execute code from data memory.
Finally, move away from "bare metal" programming if your system complexity allows it. Using a Real-Time Operating System (RTOS) can provide better task isolation and memory management, making it harder for a single driver vulnerability to compromise the entire system.
The next time you are staring at a board, remember that the most interesting bugs aren't in the cloud or the web interface. They are in the bits and bytes being pushed across the I2C bus. Start probing the hardware, read the datasheets, and stop assuming the driver is doing its job. The hardware is only as secure as the code that controls it.
Vulnerability Classes
Target Technologies
OWASP Categories
Up Next From This Conference
Similar Talks

Hacking Apple's USB-C Port Controller

Unmasking the Snitch Puck: The Creepy IoT Surveillance Tech in the School Bathroom




