Bare-metal security is an increasingly important consideration for connected embedded systems. In a bare-metal design, application firmware runs directly on the processor, without an operating system to separate tasks or mediate access to hardware. That arrangement can suit systems with tight resource and timing constraints, but it also means a memory-corruption flaw may expose the whole application, including peripherals and security-sensitive registers.
For industrial automation engineers and system integrators, the challenge is to add meaningful protection without assuming desktop-class resources or a conventional operating system. Three complementary approaches illustrate how embedded firmware can be protected and tested: limiting privilege, dividing applications into compartments, and re-hosting firmware for dynamic analysis.
Why bare-metal security needs a different approach
A bare-metal application commonly handles hardware configuration, input and output, and application logic in one privileged execution environment. With no operating-system boundary between these functions, code may have broad access to memory and memory-mapped peripherals. A buffer overflow or other write vulnerability can therefore do more than corrupt application data: it may alter control flow or write to a register that changes system behavior.
Microcontrollers may provide a Memory Protection Unit (MPU), which can set access permissions on physical memory regions. However, memory permissions alone are not sufficient if application code can also modify the MPU configuration. Effective protection requires controlling which code can perform privileged operations as well as which regions it can access.
These defenses must also fit constrained devices. The platform may have limited RAM, Flash, and processing capacity, while the application must continue to meet its runtime requirements. Security decisions can be application-specific, too: access to a peripheral register may be routine in one system and security-sensitive in another.
Privilege overlays: restrict elevated operations
EPOXY addresses the tension between application functionality and least privilege through a technique called privilege overlaying. Static analysis identifies instructions and memory accesses that require elevated privileges. The application runs with reduced privileges by default, and the identified operations receive elevated privileges only when needed.
This approach is designed to retain the application’s ability to interact with hardware while reducing the amount of code that executes with elevated permissions. EPOXY also combines privilege overlays with protections including data execution prevention, stack defenses, and diversification of code and data layouts. The work describes a compiler-based flow that applies these mechanisms without requiring changes to application source code, using a security configuration to express system-specific decisions.
In evaluations reported for the system, runtime overhead averaged 1.8% across three IoT applications, while energy overhead averaged 0.5%. These results are specific to the evaluated applications and platform; they do not establish the same overhead for every embedded workload. The broader engineering lesson is that protection mechanisms should be assessed against the target firmware’s timing, energy, and memory requirements.
Automated compartments for finer isolation
Privilege overlays limit elevated operations across an application. Automatic Compartments for Embedded Systems (ACES) takes a different approach by dividing a bare-metal application into compartments. Each compartment has defined memory permissions, and transitions between compartments are controlled. The aim is to contain access to data and code rather than letting every part of the application operate with the same permissions.
ACES uses program analysis and a developer-specified policy to identify and create compartments. Its design frames compartment creation as a graph-reduction problem, allowing policies to balance isolation with the costs of switching between compartments. This is relevant when a single-threaded firmware application contains functions or data that should not all share unrestricted access.
The reported evaluation showed that ACES could create tens of compartments within one application, with an average runtime overhead of 15%. As with the EPOXY results, this is an evaluation result rather than a universal performance guarantee. Integrators need to consider which functions and data warrant separation, and whether the resulting execution and memory costs fit the device and application.
Firmware re-hosting expands testing options
Protection at runtime is only part of the security effort; teams also need ways to find defects before deployment. Testing bare-metal firmware directly on hardware can limit the scale and flexibility of analysis. Re-hosting runs firmware in an emulated environment, but reproducing every clock, peripheral, and board component can make conventional emulation difficult and time-consuming.
HALucinator reduces that hardware dependency by identifying hardware abstraction libraries in firmware and replacing their interfaces with higher-level models. Rather than emulate every hardware detail, the approach uses abstractions that firmware already relies on to interact with device families and peripherals. This can make dynamic analysis and coverage-guided fuzzing more practical on commodity computers.
Re-hosting does not remove the need to validate behavior on target hardware. The emulated environment depends on appropriate models for the interfaces being exercised, and analysis covers only the behavior reached by its tests. Used as part of a broader verification process, however, it can help teams test firmware at scale and investigate memory-corruption vulnerabilities.
Putting the approaches together
These techniques address different points in the embedded security lifecycle:
- Privilege overlays reduce the instructions that need elevated execution privileges.
- Compartments separate parts of an application and restrict access between them.
- Firmware re-hosting supports dynamic analysis and fuzz testing without requiring a dedicated physical device for every test run.
They are not interchangeable, and each depends on the platform, firmware structure, and security policy. A practical assessment should identify critical memory and peripheral operations, evaluate where isolation is useful, and measure runtime and memory impact on representative application behavior. Testing strategy matters as well: static analysis, dynamic testing, and target-hardware validation reveal different aspects of a system.
Conclusion: Treat protection and testing as a system design concern
Bare-metal firmware does not have to remain without meaningful security controls. MPU-based permissions, carefully limited privileged operations, and compartmentalization can reduce the reach of a vulnerability, while re-hosted testing can help uncover defects earlier and at greater scale. For industrial and embedded teams, the practical objective is to choose protections that match the device’s architecture and operational constraints, then verify their behavior and cost in the application context.