Skip to main content
Be Bitwise

Building Secure Embedded Systems

IoT & Embedded Security · Embedded Systems & Firmware track

6 min read

In this module

Security by Design

Building a secure embedded system means baking security into every design decision: chip selection, hardware layout, firmware architecture, deployment strategy, all of it. You can't bolt security on after the design is finished. This lesson covers the principles and practices for building embedded systems that survive real-world attacks.

Hardware Root of Trust

Every secure embedded design starts with a hardware root of trust: an immutable foundation from which all other trust is derived.

Secure element: A dedicated tamper-resistant chip (ATECC608A, OPTIGA Trust, SE050, take your pick) that stores keys, performs cryptographic operations, and anchors secure boot. The secure element's keys never leave the chip.

MCU with built-in security: Modern MCUs like STM32L5, nRF5340, or ESP32-S3 ship with hardware security features: hardware crypto accelerators, secure key storage, readout protection, and some form of isolation. The STM32L5 and nRF5340 are Cortex-M33 parts with Arm TrustZone; the ESP32-S3 isn't an Arm chip and offers secure boot, flash encryption and its own memory permission controls instead. These are dramatically harder to defeat than software-only security.

OTP fuses for root keys: Store the root of trust (public key hash for secure boot) in one-time programmable fuses. Software can't touch them, giving you an immutable trust anchor.

text
Secure boot chain with hardware root of trust:
OTP fuses: Hash of root public key (immutable)
Secure element: Device identity key, attestation key
Boot ROM: Verifies first-stage bootloader
Bootloader: Verifies kernel (using key from secure element)
Kernel: Verifies filesystem (dm-verity)

Secure Key Storage

Keys must be protected against both software and physical extraction:

  • Never store keys in firmware images: Keys in flash can be extracted through firmware dumping
  • Use the secure element: Store keys in dedicated secure hardware
  • Derive keys from hardware secrets: Use PUFs or OTP fuse values as root secrets, deriving application keys through KDFs
  • Minimise key lifetime: Use ephemeral session keys where possible, rotating them regularly
  • Separate key types: Use different keys for different purposes (device identity, communication, firmware verification)
Key Per Device

Every device should have a unique identity key, provisioned during manufacturing. If all devices share the same key, compromising one device compromises all of them. Device-unique keys ensure that extracting one device's key only affects that single device. Key provisioning during manufacturing (using a secure provisioning station) adds cost but is essential for fleet security.

Side-Channel Resistant Implementations

Embedded devices are wide open to side-channel attacks because attackers often hold the hardware in their hands:

Constant-time cryptography: Use crypto libraries that guarantee constant-time execution (mbedTLS with constant-time enabled, hardware crypto accelerators, etc.). Avoid conditional branches and variable-time operations on secret data.

Power analysis countermeasures: Inject noise into power consumption through random delays, dummy operations, and masking. Hardware countermeasures include on-chip voltage regulators that smooth power consumption patterns.

Electromagnetic shielding: Metal enclosures cut EM emissions. For high-security applications, active shields (conductive mesh layers on the chip or PCB) actively detect probing attempts.

Secure Coding for Embedded

Embedded C code demands extra discipline because there's no memory safety net waiting to catch you:

c
// BAD: Unbounded copy
void handle_packet(char *data, int len) {
char buffer[256];
memcpy(buffer, data, len); // len could be > 256
}
// GOOD: Bounds-checked copy that rejects oversized input
int handle_packet(const char *data, size_t len) {
char buffer[256];
if (len > sizeof(buffer)) {
return -1; // malformed packet: drop it, don't parse a truncated copy
}
memcpy(buffer, data, len);
/* ... parse buffer ... */
return 0;
}
// BETTER: Use a memory-safe language for application logic
// Rust's embedded support (no_std) provides memory safety without a runtime

Additional embedded security practices:

  • Enable compiler hardening: Stack canaries, FORTIFY_SOURCE, and friends — yes, even on embedded targets
  • Minimise attack surface: Disable unused peripherals, services, and debug interfaces in production firmware
  • Validate all inputs: Every external input (network packets, sensor data, user commands) gets validated before processing
  • Fail securely: When errors occur, default to a secure state (locked, disconnected), never an open one

Threat Modelling for Hardware

Hardware threat modelling identifies threats specific to the physical deployment:

Define the attacker model: Who's coming after the device? A script kiddie with network access? A skilled researcher with a lab? A nation-state with unlimited resources?

Map the physical attack surface: Which interfaces are physically accessible? Can the PCB be reached? Are debug ports exposed? Can the device be smuggled off to a lab?

Assess physical security controls: Is the enclosure tamper-evident? Are debug interfaces disabled? Is readout protection enabled? Is the PCB potted or coated?

Evaluate wireless attack surface: What protocols are in use? Which pairing methods? Is traffic encrypted? Can the protocol be downgraded?

text
Threat model matrix:
Attack Vector | Difficulty | Impact | Mitigation
UART access | Low | High | Disable UART in production
SPI flash dump | Medium | High | Encrypt firmware, use internal flash
BLE sniffing | Low | Medium | Use secure pairing, encrypt data
Voltage glitching | High | Critical| Voltage monitoring, redundant checks
Cloud API abuse | Medium | High | Proper authentication, rate limiting

Defence in Depth for Embedded

No single security measure is enough on its own. Layer defences so that defeating one mechanism doesn't unravel the entire system:

  1. Physical layer: Tamper-evident enclosure, disabled debug interfaces, readout protection
  2. Boot layer: Secure boot with hardware root of trust, anti-rollback
  3. Runtime layer: Memory protection (MPU), privilege separation (TrustZone), stack canaries
  4. Communication layer: TLS for cloud communication, encrypted and authenticated wireless
  5. Update layer: Signed OTA updates, A/B partitions, version validation
  6. Monitoring layer: Anomaly detection, tamper response, remote attestation

Read the diagram as one attacker trying a different trick against each layer. Any single layer can fall; the design goal is that falling through one still leaves the next in the way.

One example attack stopped at each of the six layers
Security Is a Process

Building secure embedded systems is not a one-time effort. It requires ongoing vulnerability monitoring, regular security updates, incident response planning, and periodic security assessments. The device you ship today will face threats that do not exist yet. Design for updatability, monitor for new vulnerabilities, and commit to supporting the device for its entire lifecycle.

Buyers and regulators increasingly ask for this in writing. Three names come up most. ETSI EN 303 645 is the European baseline for consumer IoT: no universal default passwords, a way to report vulnerabilities, a stated support period, secure updates. PSA Certified, started by Arm and partners, certifies chips and devices against a security model at increasing levels of attack resistance. And the EU Cyber Resilience Act makes security requirements and vulnerability handling a legal condition for selling products with digital elements in the EU, with vulnerability-reporting duties applying from September 2026 and the rest from December 2027. If you're designing a device today, expect at least one of these on the procurement checklist.