Engineering Insights

Secure Embedded Firmware Development: Protecting Against Real-World Threats

Trust boundaries, device identity and firmware integrity.

Contents
Share
Download PDF

Get the PDF by email

We’ll send this whitepaper to your inbox.

Whitepaper

Secure Embedded Firmware Development: Protecting Against Real-World Threats

Verification loads when you prepare to submit.

Privacy Policy

1. Executive summary

Secure embedded firmware development protects a device's software, data and operating functions against unauthorised use or modification throughout its service life. In a connected controller, that responsibility extends from the code admitted at boot to the commands accepted during operation and the access permitted during maintenance. Security controls must also preserve the resources needed for local control when external inputs are hostile.

These protections depend on how the system assigns and enforces permission. Authenticating a connection establishes the identity of a peer under the selected protocol, but the firmware still has to decide which operations that peer may request. Similarly, verifying an update establishes its authenticity, while the boot design must ensure that the accepted image remains protected until it executes. Treating those decisions explicitly makes it possible to limit the consequences of a compromised component and to recover without restoring an obsolete or unauthorised configuration.

This paper examines the architecture and verification practices that connect those controls in resource-constrained embedded systems. It covers trust boundaries, executable integrity, command handling and key management, followed by recovery and release evidence. The central engineering requirement is to preserve the intended restrictions across normal operation, interruption and servicing. A security review should therefore establish which component enforces each restriction and what evidence demonstrates that it remains effective in the shipped device.

Publication details and citation

EEIO-INS-003 · Revision 1.3 · 2026

Published by EmbeddedExpertIO

Editor Israel Gbati

Suggested citation. EmbeddedExpertIO. Secure Embedded Firmware Development: Protecting Against Real-World Threats. EmbeddedExpertIO Engineering Insights, EEIO-INS-003, revision 1.3, 2026.

2. Threat models and trust boundaries

Before choosing security mechanisms, we need to identify what an attacker must be prevented from changing or using. For an embedded controller, protected assets include executable code and credentials, but also calibration, operating limits and the processor time needed to control equipment. A threat model connects these assets to the interfaces an attacker can reach and the capabilities the design is expected to withstand. This gives the architecture a concrete basis for restricting access and planning recovery [1, 2, 3].

To examine these decisions, consider an industrial dosing controller that dispenses a requested quantity of material. It has an RTOS, a network interface, external storage for update packages and a serial maintenance port. We will use it to illustrate how security decisions affect physical operation. The assumed threats include hostile network traffic, untrusted update packages, repeated commands and temporary access to external connectors and storage. We also examine the consequences of a compromised communications component, so that the architecture must account for failure within the device as well as attacks at its perimeter.

The communications component needs to submit requests, but it has no reason to write motor registers or replace calibration directly. A separate control service should validate requests against the caller's permissions, the operating limits and the current equipment state before commanding the actuator. Validation must apply to the same parameters that are subsequently used. Copying a bounded request into service-owned memory provides that stability; exclusive ownership can provide it where copying is unsuitable. Figure 1 shows the permitted access paths and the services responsible for enforcing them.

A representative industrial controller PCB provides physical context above the logical architecture. Callouts identify its network connector, service header and field I/O connections. The logical view preserves the communications, control, key and boot-verification services, permitted access paths, device boundary and required access-enforcement boundaries. The hardware view shows an example. Logical services do not identify separate physical chips.
Figure 1. Trust boundaries in an industrial controller View full size

For this separation to contain a compromise, the platform must enforce the permitted access paths. Zephyr and Cortex-M33 illustrate two complementary levels of access control: operating-system permissions and processor-enforced protection. In Zephyr, user mode restricts threads to granted memory and kernel objects, while supervisor code remains trusted [4]. The review must therefore examine the effective memory domains, object grants and peripheral mappings that implement the design.

At the processor level, Cortex-M33 can run application code unprivileged in Thread mode, while exception handlers run privileged in Handler mode. Where a memory protection unit (MPU) is implemented and configured, its region permissions can prevent unprivileged code from accessing protected memory [5]. The control service can then mediate requests without giving the caller direct access to its internal state.

When the Armv8-M Security Extension is implemented, TrustZone adds Secure and Non-secure execution states. This is distinct from privilege: privileged Non-secure code cannot directly read or write memory attributed as Secure [5]. A credential service can therefore remain in Secure state while the communications stack runs in Non-secure state and calls only the exposed Secure entry points [6]. The entry-point code must still validate each request, because permission to enter Secure code does not authorise every operation it exposes.

These CPU mechanisms must be supported by the rest of the device. An MPU does not automatically constrain DMA or another processor sharing the same memory, so shared resources need the additional hardware enforcement described by Trusted Firmware-M [7].

Even with these access boundaries enforced, the control service still needs trustworthy evidence of who originated a request. If the control service relies solely on identity information supplied by a compromised communications component, that component can impersonate callers within the service's exposed operations even when it cannot bypass the operating limits.

The same access policy has to survive changes in the device's operating mode. A serial console disabled in the application may become privileged in a maintenance image, so the interface inventory must cover commissioning, service, recovery and retirement. For each relevant configuration, verification should establish that unnecessary services have been removed and that the remaining access rules are enforced at the shipped connectors [2, 8].

Restricting access to memory and peripherals still leaves the processor's time to protect. Hostile traffic can consume that time through incomplete frames, active sessions, cryptographic work or diagnostic output, so each of those demands needs a defined bound. Overload testing must measure the control response against the operating requirements, including the defined behaviour for any permitted degraded operation. Repeated restarts after rejected requests can undermine availability by keeping the controller in recovery instead of performing its control work.

3. Secure boot and executable integrity

The restrictions enforced by firmware depend on the code that actually runs. Secure boot establishes a chain of verification from a protected initial verifier and trust anchor to the executable image. In a public-key design, the device's verification key or its digest needs protection against replacement, while the private signing key belongs to a separate release authority. An unauthenticated checksum stored beside a writable image cannot establish authenticity because an attacker can replace both [1]. An encrypted image still requires that authenticity check; protecting its contents against disclosure does not establish permission to execute it.

The verification decision must cover the interpretation of the image as well as its contents. An authenticated manifest binds a payload digest to the intended device, payload type and installation information, as described in RFC 9124 [9]. The bootloader can then reject a correctly signed image intended for different hardware or an impermissible destination.

Once an image has passed verification, another writer must not be able to change the bytes that will execute. For code copied into RAM, this requires control of writes during loading and after verification. For code executed directly from external memory, it requires protection of subsequent instruction fetches against the physical access assumed in the threat model. The same principle applies to verified metadata used later in the boot process [9]. Figure 2 follows the verification decision through to protected execution.

The verifier must nevertheless examine some untrusted data before it can authenticate a package. Bounds on framing, lengths and allocation therefore belong in the parsing path, together with limits on nesting and decompression where used. An error can also stop parsing before initialisation is complete, so cleanup must not assume that every buffer or data structure is ready for use.

A candidate passes bounded parsing, metadata and payload authentication, and applicability and security-policy checks. Rejection preserves an existing authorised image or policy-controlled recovery. Verified metadata and executable bytes require protection from modification through execution.
Figure 2. From verification to protected execution View full size

In a security advisory published on 12 November 2026, MCUboot's maintainers described a fault in the serial-recovery upload path. A malformed upload could trigger a pre-authentication NULL pointer dereference in affected Zephyr and Mynewt builds with encrypted-image support. Versions from 2.0.0 up to, but excluding, 2.5.0 were affected; 2.5.0 contains the fix. The documented impact was a platform-dependent transient loss of recovery availability, not a bypass of image authentication [10].

Because this fault occurs before authentication, a valid image signature cannot prevent it. A component inventory that records the MCUboot version, port and enabled features of each shipped configuration lets the team determine which devices are affected and which correction they need.

4. Authentication and command execution

During operation, the firmware has to connect an authenticated identity to a permitted action. TLS 1.3 protects communication between its endpoints; RFC 9846, published in July 2026, supersedes RFC 8446 [11]. With certificate-based service authentication, validating the certificate chain and checking that the certificate identifies the intended service are separate requirements [12]. Once the peer has been authenticated, the application must determine which operations that identity is allowed to request. A client authorised to read telemetry, for example, need not be allowed to alter calibration or start the dosing mechanism [8].

When a gateway terminates TLS, the protected channel ends there: the gateway can read the application traffic and originate messages on the next connection. We must therefore decide whether it is authorised to issue jobs or is simply carrying messages between other parties. In the first case, the device enforces the gateway's permitted operations. In the second, the communicating endpoints need message protection that remains intact across the gateway. OSCORE provides that protection for CoAP and CoAP-mappable HTTP exchanges across suitable intermediaries [13].

Even an authorised command requires rules for repetition. In the dosing example, sending the same job twice can dispense twice, so the operation is not idempotent. We should exclude dispense commands from TLS early data because early data is replayable [11]. A normal application retry can still arrive over a new connection, however, which means the controller also needs to recognise the job independently of the transport session. Figure 3 shows how the controller should distinguish a completed duplicate from a job whose physical outcome remains uncertain.

Serialised admission checks authority, parameters and job history. Durable acceptance precedes actuation. After reset, an accepted job with no durable completion requires physical reconciliation and must not be automatically repeated. A completed matching duplicate returns its recorded result. Invalid history is never treated as no history.
Figure 3. Job state after an interrupted command View full size

To recognise those retries, the controller needs a job identifier bound to the authorised device and the complete command parameters. It compares each request with the stored job history during serialised admission, so concurrent copies cannot both be accepted as new work. A reused identifier carrying different parameters is rejected. For a matching retry, the stored result is returned if completion has been recorded; otherwise, an accepted job enters reconciliation without automatically dispensing again. Only a new job proceeds to a durable acceptance record containing its identifier and parameter digest, which must be committed before movement is permitted.

The stored history must remain protected against unauthorised changes for the entire permitted retry lifetime. Deleting a record too early can make an executed command appear new, so retention rules belong in the command protocol as well as the storage design.

The difficult interval is between physical delivery and durable recording of completion. Power can fail after material has moved but before that record is committed. Recording acceptance first establishes intent, not delivery, so it cannot close this gap. Measured delivery, process accounting or an authorised inspection procedure must resolve the uncertainty before any decision to continue or repeat the operation. The persistence design must also distinguish a committed record from an interrupted write; an unreadable job history cannot be treated as an empty history.

Restoring the job history does not restore the freshness guarantees of the communication protocol. After a reset, the recovered security context must also avoid reusing sender sequence numbers or admitting messages that its replay window had already excluded. OSCORE specifies ways to recover freshness state or establish a fresh context [13]. These mechanisms address message replay; the job records address the separate question of whether a permitted physical operation has already taken place.

5. Key management and permitted use

Protecting a private key from extraction is only part of controlling its use. A compromised component that can submit arbitrary messages to a signing service may misuse a key without ever reading it. Key services must therefore restrict callers and operations, as well as the algorithms and data each operation accepts. PSA Crypto makes the distinction explicit by separating permission to export a key from permission to perform cryptographic operations with it [14].

Separate credentials and permissions for device identity, maintenance access, data protection and release signing limit the consequences of a compromise in any one function. For example, withdrawing maintenance access should not require replacing a device's identity credential, and permission to service equipment should not confer permission to sign its firmware. Commissioning establishes the device's initial identity by binding its credential to the inventory record; the provisioning path must then be closed when commissioning is complete. When the device is retired, its authority in the management system must be revoked and its local credentials removed.

Generating these credentials requires an entropy source assessed against the relevant entropy model and health-test requirements [15]. If random generation fails, the failure must propagate before any output is used, as required by the PSA Crypto API [16]. A timestamp or serial number cannot be substituted as a source of the required unpredictable entropy.

With AES-GCM, the key must be managed together with the state used to allocate nonces. A nonce must not be reused for distinct encryption invocations under the same key, because reuse with different plaintexts compromises confidentiality and authentication [17]. Resets, rollback and cloned images must therefore preserve nonce uniqueness, either through a suitable persistent allocation scheme or through an appropriate change of key. We need to document how nonce state and key replacement interact before testing interrupted rotation, loss of connectivity and rejection of replacement credentials.

The same distinction between storing a key and authorising its use applies to release signing. A hardware signing device can protect the key while still signing an unauthorised image submitted through a compromised release workflow, a risk identified in RFC 9124 [9]. The workflow must therefore admit only authorised, identified builds and retain the source, component provenance, executable image and approval record needed to establish what was released [18].

6. Secure updates and recovery

An update mechanism must preserve the same authorisation policy whether the package arrives over a network, through offline media or from a service interface. RFC 9019 describes a transport-independent update architecture in which the manifest carries the information needed to authenticate and apply the update [19]. This allows delivery methods to vary without making the transport itself the authority to replace executable code.

Authenticity does not establish that an older release remains acceptable. A vulnerable image can retain a valid signature, so the device needs a protected policy defining the minimum permitted security level. MCUboot's optional hardware-based rollback protection compares a signed image security counter with a value held in trusted non-volatile storage. The counter is independent of the ordinary image version, allowing several versions to remain acceptable at the same security level [20].

The minimum security level has to advance in step with the recovery process. If the device excludes the old image before an acceptable replacement or recovery image is durable, an interrupted installation can leave it unable to boot. If it retains the old minimum after a mandatory security transition, a disallowed release remains admissible. These two failure modes make interruption testing necessary at both transitions, using the actual bootloader and storage hardware.

Recovery must restore valid critical data as well as executable code. An approved image can still operate with corrupt calibration or inappropriate access grants, so restoring the image alone is insufficient. The fallback image must also remain acceptable under the current security policy; a factory image is not automatically suitable simply because it was originally shipped with the product [1, 21].

An alternate boot or service path can bypass these restrictions unless it enforces the same policy. We therefore need to inspect boot-selection pins, ROM download modes, debug settings, security fuses, serial commands and test credentials on representative hardware in the shipped configuration. Where authorised maintenance reopens a restricted interface, the maintenance policy must specify whether credentials have to be erased before access is restored. Any permission to reopen the interface must be limited to the intended device, and the reopening must be recorded.

Those interface checks do not establish resistance to fault injection or invasive extraction. A claim covering voltage manipulation, electromagnetic injection or physical probing requires evidence for that attack model. Trusted Firmware-M documents software countermeasures and explicitly limits their coverage [22]. The product's stated protection must match the combined hardware and software measures that have actually been assessed.

7. Verification and release evidence

Security verification should test the restrictions on which the architecture depends. For example, a rejected calibration command must leave the calibration unchanged, and a compromised communications component must remain unable to bypass the control service. Each test therefore needs a defined attempted violation and an observation that establishes whether enforcement held. Table 1 applies this approach to the controller and provides a basis for release testing.

Table 1. Security properties and required release observations.

Security property Adversarial test or analysis Required observation
Only approved executable content runs Alter the payload, authenticated metadata, signing authority and device applicability Rejection before execution, with the intended recovery behaviour
Network compromise remains contained Exercise a deliberately compromised communications component No unauthorised key, calibration, actuator or protection-controller access
Repetition cannot silently repeat a job Duplicate, reorder and concurrently submit requests; reset around persistent-state transitions Defined deduplication or reconciliation, without automatic repeated actuation
Recovery preserves security policy Interrupt installation and counter updates; present disallowed older images A recoverable authorised state without an unintended downgrade
Hostile traffic cannot consume the control budget Saturate sessions, malformed messages and expensive operations Control obligations remain satisfied or enter the specified degraded response
Production interfaces match the threat model Probe shipped debug, maintenance and alternate-boot configurations Only documented access remains available

Coverage-guided fuzzing with libFuzzer can exercise parser inputs and error paths, while AddressSanitizer can expose memory errors in instrumented executions [23, 24]. These results do not establish the effective permissions, fuse settings or boot behaviour of the production configuration, which must be checked on the target. The resulting release record should keep the bootloader options, component versions, image identity and actual results together so that the evidence can be traced to the released device [18].

The device also needs records that support investigation after deployment [25]. The logging design must rate-limit records of repetitive failures while preserving space reserved for significant security transitions, and diagnostic output must exclude credentials. Where a trustworthy wall clock is unavailable, the records must retain event ordering and make the uncertainty in time explicit. A compromised component can falsify its own logs, so conclusions about its behaviour require corroboration from outside that component.

Release acceptance should establish that each protected operation has an effective enforcement point, that interruption leads to a defined recovery state and that hostile inputs do not remove the resources required for control. Keeping this evidence with the shipped configuration gives the team a practical basis for assessing a new vulnerability, deciding which devices are affected and delivering a correction that preserves the product's operating requirements.

Training for engineering teams

EmbeddedExpertIO provides professional training in embedded systems and firmware development. If you are planning training for your team, we can help you choose courses that suit your engineers’ experience and the work ahead. Teams can enrol in a selected group of courses or arrange access to the full course library.

Discuss your team’s training requirements · support@embeddedexpert.io

8. References

[1] NIST. SP 800-193: Platform Firmware Resiliency Guidelines, May 2018. Source

[2] UK National Cyber Security Centre. Device security principles for manufacturers: Constrain the use of all device interfaces. Source

[3] UK National Cyber Security Centre. Device security principles for manufacturers: Minimise the privilege and reach of applications. Source

[4] Zephyr Project. User Mode: Overview and Threat Model. Source

[5] Arm. Cortex-M33 Processor Technical Reference Manual, document 100230_0003_00_en. Sections B1.2 and B3.1. Source

[6] Arm. CMSIS-Core: Using TrustZone for Armv8-M, CMSIS 6.3.0. Simplified Use Case and Programmers Model. Source

[7] Trusted Firmware-M. FF-M Isolation, including hardware infrastructure and shared-resource protection. Source

[8] UK National Cyber Security Centre. Device security principles for manufacturers: Support appropriate authentication. Source

[9] IETF. RFC 9124: A Manifest Information Model for Firmware Updates in Internet of Things (IoT) Devices, January 2022. Sections 4.2.8, 4.2.16 to 4.2.18, and 4.3. Source

[10] MCUboot maintainers. GHSA-777r-3chm-p78c: Pre-authentication NULL pointer dereference in MCUboot serial-recovery image upload, published 12 November 2026. Source

[11] IETF. RFC 9846: The Transport Layer Security (TLS) Protocol Version 1.3, July 2026. Particularly Sections 1 and 8. Source

[12] IETF. RFC 9525: Service Identity in TLS, November 2023. Source

[13] IETF. RFC 8613: Object Security for Constrained RESTful Environments (OSCORE), July 2019. Particularly Sections 7–8 and Appendix B. Source

[14] Arm. PSA Certified Crypto API 1.5: Key policies. Source

[15] NIST. SP 800-90B: Recommendation for the Entropy Sources Used for Random Bit Generation, January 2018. Source

[16] Arm. PSA Certified Crypto API 1.5: Random number generation. Source

[17] IETF. RFC 5116: An Interface and Algorithms for Authenticated Encryption, January 2008. Particularly Sections 3.1 and 5.1.1. Source

[18] NIST. SP 800-218: Secure Software Development Framework, Version 1.1, February 2022. Particularly practices PS.1–PS.3. Source

[19] IETF. RFC 9019: A Firmware Update Architecture for Internet of Things, April 2021. Source

[20] MCUboot. Bootloader design: Downgrade prevention and protected metadata. Source

[21] UK National Cyber Security Centre. Device security principles for manufacturers: Enable recovery to a known good state. Source

[22] Trusted Firmware-M. Physical attack mitigation in Trusted Firmware-M. Source

[23] LLVM Project. libFuzzer: A library for coverage-guided fuzz testing. Source

[24] LLVM Project. AddressSanitizer. Source

[25] UK National Cyber Security Centre. Device security principles for manufacturers: Provide security logging, alerting and monitoring capabilities. Source