Firmware security

Compiler and linker hardening in firmware binaries

Firmware analysis: chip, layers, terminal arranged to illustrate compiler and linker hardening in firmware binaries.

Compiler and linker protections affect exploit difficulty but do not remove the underlying memory defect. Understanding compiler and linker hardening in firmware binaries helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Firmware security depends on the relationship between the distributed image, installed configuration and code that actually executes. Offline analysis, emulation and real-device testing provide different kinds of evidence and should be connected before a strong impact claim is made.

Compiled binaries within IoT firmware may lack standard exploit mitigation features that are enabled through compiler and linker security flags. Security hardening features such as Position Independent Executables (PIE), stack canaries, No-Execute (NX), Relocation Read-Only (RELRO), and FORTIFY_SOURCE provide critical defense-in-depth against memory corruption vulnerabilities. Research into IoT router firmware has found that a significant proportion of embedded binaries lack key mitigations such as stack canaries and full RELRO, leaving devices vulnerable to memory corruption exploitation. The absence of these protections reduces the complexity of exploiting vulnerabilities in the firmware — for example, an attacker can use Return-Oriented Programming (ROP) techniques against binaries that lack PIE/ASLR, and may inject shellcode into binaries that lack NX protection — and reveals details about the binary's security posture that enable more targeted exploitation strategies. Real-world impact is demonstrated by vulnerabilities such as CVE-2022-48174, a stack buffer overflow in BusyBox affecting millions of embedded and IoT devices, where missing stack canaries and ASLR significantly lowered the exploitation barrier.

Why it matters

Consider a realistic failure: a network service is shipped without mitigations present in the development configuration.

A firmware weakness may expose device credentials, permit privileged actions or affect availability. The practical consequence depends on reachable services, execution privileges and the trust placed in the device by other components.

Firmware evidence should identify the image, installed configuration and execution conditions. Static analysis, emulation and hardware testing answer different questions and should support a consistent conclusion.

How penetration testers check for it

Inspect the real release binaries and architecture-specific protections.

  • Compiled binaries within the firmware must be identified and analysed for the presence or absence of common exploit mitigation features, including.
  • NX/W^X (No-Execute): prevents execution of code injected into writable memory regions such as the stack or heap.
  • Tools such as checksec, readelf, objdump, and rabin2 should be used to assess binary hardening properties.
  • Identified missing mitigations must be documented and assessed in the context of the binary's role and potential exploitability.
  • Review privileges and externally influenced inputs.
  • Preserve reproducible evidence and representative recovery conditions.

How to fix it

Enable appropriate build hardening and fix unsafe memory operations directly.

  • Remove unnecessary code, accounts and capabilities.
  • Use safe input handling and narrow privileged interfaces.
  • Protect secrets and authenticate relevant executable content.
  • Verify fixes in the actual production and recovery artefacts.

A suspicious string or an emulation result is not enough to establish a working compromise. Validate the path and explain any environmental assumptions that affect the conclusion.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your firmware and embedded systems.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo