What is a Rootkit? Link to heading

A rootkit is a type of malware designed to gain and maintain privileged access to a system while hiding its presence. The term comes from the combination of “root”, which refers to the user with maximum privileges on Linux systems, and “kit” which represents a set of tools used to control the compromised system

The main purpose of a rootkit is to ensure persistence, allowing an attacker to continue accessing the system even after reboots or removal attempts. To do this, it modifies critical components of the operating system, such as the kernel, drivers or system services, making it difficult to detect and remove.

The difference between traditional rootkits and firmware rootkits is that traditional rootkits operate in user-mode or kernel-mode, depending on the level of privilege they can obtain. They modify system files, processes or kernel structures to hide themselves and maintain persistent access. Unlike traditional rootkits, firmware rootkits infect hardware firmware such as BIOS, UEFI, network cards, storage controllers, and even GPUs. This means they can persist even after a complete system format, making the infection extremely difficult to remove!

Firmware Fundamentals Link to heading

Firmware is a special type of software built directly into a device’s hardware. It serves as the bridge between the hardware and the operating systems or software that use it, controlling its basic functioning and ensuring that it operates correctly and efficiently. Unlike conventional software, which can be easily installed or removed, firmware typically resides in non-volatile memory such as ROM, EEPROM, or Flash Memory and is designed to run every time the device is turned on.

Firmware is responsible for defining how hardware works and ensuring that it performs its functions correctly. Without firmware, electronic devices would be unable to operate as they would not have instructions to process commands or interact with other system components. On a computer, for example, the motherboard firmware (such as BIOS or UEFI) has the function of starting all essential components, checking their integrity and loading the operating system. Similarly, on a cell phone, firmware controls communication between the operating system and components such as the screen, sensors, camera and processor.

BIOS VS UEFI Link to heading

For decades, computers used BIOS as the motherboard’s primary firmware. However, with the advancement of technology, UEFI emerged, which brought significant improvements, such as support for larger disks, faster booting and greater security against malware.

Firmware attacks have become more sophisticated as critical devices have come to rely heavily on this type of software. Firmware rootkits, for example, exploit vulnerabilities in BIOS/UEFI to obtain persistence, becoming practically undetectable and resistant even to system formatting! So, firmware represents a highly strategic target for an attacker for several reasons:

  • 1 - Extreme Persistence: a successful firmware attack can survive operating system reinstallations, formats and even SSD/HD replacements.

  • 2 - Difficulty in Detection: most AVs do not check firmware, making these attacks invisible to many protection solutions.

  • 3 - Low level of Execution: as the firmware is loaded before the operating system, it can modify the system’s behavior without being detected by conventional security mechanisms.

  • 4 - Lack of Regular Updates: unlike application software, many firmwares do not receive frequent updates, leaving devices vulnerable for long periods.

The importance of firmware goes far beyond simply allowing the hardware to function correctly. It is one of the most critical components in terms of security and stability, being fundamental for the proper functioning of any computer system. For this reason, attacks targeting firmware represent a growing and complex threat, requiring special attention from both manufacturers and users.

Concept and Operation Link to heading

Firmware rootkits represent an evolution of traditional persistence methods used by attackers. Unlike conventional rootkits, which compromise operating system files or running processes, a firmware rootkit hides in hardware components, making its removal extremely complex.

Because they are at a lower level than the operating system itself, these rootkits can manipulate the environment even before the OS boots, allowing the modification of data in memory, the interception of system calls and even the injection of code into the bootloader.

The big difference between a firmware rootkit is its ability to remain active even after multiple removal attempts. Because it operates at a deeper level than the operating system itself, it survives:

  • Disk formatting: The firmware resides outside the SSD/HD, so erasing or replacing the storage does not remove the threat.

  • Operating system reinstallation: The rootkit is executed before the OS is loaded and can automatically reinfect it.

  • Component exchange: If the rootkit is in a compromised BIOS/UEFI, changing the HD, RAM or even the GPU does not remove the threat.

  • Poorly implemented firmware updates: Some rootkits modify the firmware update routine, preventing malicious code from being overwritten.

The only definitive solution often involves completely rewriting the firmware through a process called flashing or, in extreme cases, physically replacing the compromised chip.

Attack Vectors Link to heading

To compromise a system’s firmware, attackers use different infection techniques, exploiting both known vulnerabilities and flaws in the hardware security chain. Some of the most common methods include:

  • 1 - Exploitation of Vulnerabilities in UEFI/BIOS: Some firmware versions have flaws that allow arbitrary execution of malicious code. Attackers can exploit these vulnerabilities to inject rootkits directly into the firmware.

  • 2 - Malicious Firmware Updates: If an attacker compromises a manufacturer’s update server (supply chain attack) or tricks the user into installing a fake update, he can replace the legitimate firmware with a modified one.

  • 3 - Attacks via Compromised Hardware Components: Motherboards, USB devices and even peripherals can come from the factory with altered firmware. This has already occurred with tampered HDs and SSDs that installed malware on the system as soon as they were connected.

  • 4 - Remote Attacks on Connected Devices: In some cases, rootkits can be injected remotely by exploiting vulnerabilities in hardware management interfaces, such as the Intel Management Engine (IME) or the Baseboard Management Controller (BMC).

  • 5 - Physical Attacks and Evil Maid Attack: An attacker with physical access to the device can use techniques such as SPI flashing to directly overwrite the BIOS/UEFI firmware, installing a rootkit in a practically undetectable way.

BIOS/UEFI Link to heading

BIOS and UEFI are the first software components executed when turning on a computer, being responsible for initializing the hardware and loading the operating system. Because of this privileged position in the boot chain, modifying the BIOS/UEFI firmware is one of the most effective ways to ensure system persistence. The process of injecting a rootkit into the BIOS or UEFI can be done in the following ways:

  • 1 - Firmware Rewrite with Malicious Code:

    • The attacker obtains a copy of the device’s original firmware and modifies it, inserting malicious code that will be executed during boot.
    • The tampered firmware is then reinstalled on the device, replacing the legitimate version. This process can be carried out manually, if the attacker has physical access to the hardware, or remotely, exploiting update vulnerabilities.
  • 2 - ACPI Table Manipulation (Advanced Configuration and Power Interface)

    • ACPI manages communication between the firmware and the operating system. By altering ACPI tables within UEFI, a rootkit can inject malicious code that will be loaded directly into memory during boot.
    • This method is particularly effective because code executed by ACPI is not constantly checked by the operating system and can be modified without alerting conventional security tools.
  • 3 - Firmware Call Intercept

    • A rootkit can modify boot functions within the BIOS/UEFI, redirecting calls to malicious code. This allows the malware to have control over the system from the first moments of startup. Once installed, a firmware rootkit can modify the operating system’s loading, inject malware directly into RAM, or even automatically reinstall malicious files on the hard drive after formatting attempts.

Vulnerabilities in Signed Drivers and Firmware Link to heading

Many modern devices use digitally signed firmware to ensure authenticity. However, attackers often exploit vulnerabilities in these firmwares to inject malicious code without having to directly modify the BIOS or UEFI.

  • 1 - Use of Drivers with Known Vulnerabilities

    • Some hardware drivers, especially those signed by manufacturers, may contain flaws that allow privileged code to execute. If a vulnerable driver is installed on the system, an attacker can exploit it to write directly to the firmware memory.
    • A practical example of this attack was the use of overclocking drivers that allowed access to critical regions of memory, enabling firmware modification without needing administrative privileges.
  • 2 - Abuse of Firmware Update Mechanisms

    • Many manufacturers offer tools that allow automatic updating of system firmware. If an attacker compromises these tools or injects malicious code into the update process, they can install a rootkit without directly modifying the original firmware.
    • In some cases, downgrade attacks may be used, where old firmware (with known vulnerabilities) is reinstalled, allowing a known exploit to be used to compromise the system.
  • 3 - Attacks on the TPM Module and Intel ME

    • The Intel Management Engine (ME) and Trusted Platform Module (TPM) are hardware components designed to ensure firmware and operating system integrity. However, vulnerabilities in these modules have already been exploited to compromise the secure boot of the system.
    • Once a rootkit is injected at this layer, it can communicate directly with the firmware, modifying critical processes before the operating system has a chance to detect the threat.

Malicious Firmware Update Link to heading

Firmware update processes generally involve replacing code stored in the device’s Flash memory. If an attacker compromises this process, they can install a rootkit in a virtually undetectable manner.

  • 1 - Compromise of Update Servers

    • Some companies distribute firmware updates through online servers. If an attacker compromises these servers, they can distribute tampered versions of the firmware to thousands of devices at once.
    • This type of attack has already been observed in supply chain attacks, where manufacturers have been compromised and distributed malicious firmware without realizing it.
  • 2 - “Evil Maid” Attacks and Physical Firmware Modification

    • If an attacker has physical access to the device, they can directly replace the original firmware with a modified version using techniques such as SPI flashing.
    • This method allows the rootkit to be installed even on protected systems, as the firmware can be rewritten using reverse engineering tools.
  • 3 - Use of Malicious Bootloaders

    • A rootkit can be installed through a fake bootloader update, which is responsible for loading the operating system. If an attacker modifies the bootloader, they can intercept the boot process and ensure that the malware is executed before the operating system is loaded.

Bootkits & Secure Boot Attacks Link to heading

Bootkits are a category of rootkits that install themselves in the system’s boot chain, modifying the bootloader or critical files responsible for loading the operating system. One of the main barriers against these attacks is Secure Boot, a mechanism that prevents unsigned code from executing during boot. However, there are methods to bypass this protection.

  • 1 - Forced Disable Secure Boot

    • Some firmwares allow Secure Boot to be manually disabled in BIOS/UEFI. If an attacker gains access to the firmware, they can disable this protection and allow malicious code to execute during boot.
  • 2 - Use of Compromised Certificates

    • Secure Boot relies on a chain of digital signatures to verify the authenticity of loaded code. If an attacker is able to use a valid signing key (for example, by exploiting a compromised certificate from a manufacturer), they can inject malicious code without triggering security alerts.
  • 3 - Attacks on Vulnerable Bootloaders

    • Some older bootloaders have flaws that allow unsigned code to run. If an attacker can force the system to load a vulnerable bootloader, they can inject a bootkit that will load before the operating system.

Real Examples of Rootkits in Firmware Link to heading

Firmware rootkits are not just a theoretical threat. There are records of real attacks in which rootkits compromised systems at the firmware level, ensuring extreme persistence and making their detection and removal difficult. And here are three emblematic cases that demonstrate the sophistication of these threats.

LoJax: The First Known Rootkit for UEFI Link to heading

LoJax was the first UEFI firmware rootkit detected in a real attack, being identified by security company ESET in 2018. It was attributed to the APT28 (Fancy Bear) hacker group, linked to Russian intelligence, and used mainly in attacks against government targets and high-value organizations.

Operation of LoJax Link to heading

LoJax exploited vulnerabilities in UEFI firmware to install itself directly into the motherboard’s SPI Flash. Its goal was to ensure full persistence, allowing attackers to maintain access to the system even after formatting or replacing the hard drive.

The attack happened in stages:

  • 1 - Initial Commitment

    • The attacker first infected the machine through conventional methods, such as phishing or exploiting vulnerabilities in the operating system.
    • Once inside the system, the malware identified whether the UEFI firmware was protected from modification (some motherboards allow the firmware to be rewritten without needing special permissions).
  • 2 - UEFI Firmware Dump

    • LoJax used tools to extract a copy of legitimate UEFI firmware, analyzing its structure.
  • 3 - Modification and Rewriting

    • The rootkit injected a malicious module into the UEFI, ensuring that it was executed on every boot.
    • The modified firmware was then rewritten to the motherboard’s SPI Flash, replacing the original version.
  • 4 - Persistence and Communication

    • Whenever the computer was turned on, LoJax activated its code before loading the operating system, being able to reinstall malware in the OS or manipulate boot settings.
    • It also used hidden channels to communicate with attackers, enabling remote control of the infected system.

Impact & Detection Link to heading

LoJax demonstrated that persistent attacks against UEFI were viable and difficult to mitigate. Its detection required advanced firmware analysis techniques, as the rootkit operated at a level invisible to traditional antiviruses. As the malicious code was recorded in the SPI Flash, the only definitive solution was to completely rewrite the firmware or replace the motherboard.

MoonBounce: Rootkit in Firmware Detected by Kaspersky Link to heading

MoonBounce was identified in 2022 by Kaspersky as one of the most sophisticated firmware rootkits ever seen. Attributed to the China-linked hacker group APT41, it exploited UEFI to ensure persistence and execute malicious payloads directly from firmware memory.

MoonBounce differences Link to heading

MoonBounce stood out from previous rootkits because it operated more discreetly and efficiently:

  • Code injected directly into PEI (Pre-EFI Initialization) memory: This allowed the rootkit to be executed without having to modify the bootloader or kernel.
  • Lightweight and modular payload: Unlike other rootkits that injected large amounts of code, MoonBounce used minimal code to maintain its presence, reducing chances of detection.
  • Persistence without modifying files on the disk: The code was loaded directly by the firmware and injected into the operating system’s memory without having to create files on the hard disk.

How the Attack Works Link to heading

  • 1 - The attacker compromised the system and gained administrative-level access.
  • 2 - Using specialized tools, the rootkit was injected directly into the UEFI memory.
  • 3 - During system startup, malicious code was loaded before the operating system, allowing it to communicate with command and control (C2) servers and execute new instructions.

Impact and Complexity Link to heading

MoonBounce demonstrated how firmware rootkits were evolving to be even more stealthy. Because it operated completely in memory during the boot phase, detection required detailed firmware analysis, making mitigation an even greater challenge.

Mebromi: Rootkit that Infected Award BIOS Link to heading

Mebromi was one of the first rootkits to compromise conventional BIOS firmware, having been identified in 2011. Unlike sophisticated attacks on UEFI, Mebromi targeted BIOS from the manufacturer Award, one of the most popular at the time.

How Mebromi works Link to heading

Mebromi was a hybrid rootkit, combining components for BIOS, MBR (Master Boot Record) and Windows. The attack followed these steps:

  • 1 - BIOS Firmware Injection

    • If the machine had a vulnerable BIOS Award, the rootkit modified the firmware, guaranteeing its execution at each boot.
  • 2 - Modification of the MBR (Master Boot Record)

    • The rootkit altered the hard drive’s boot sector to load malicious code before loading the operating system.
  • 3 - Windows Compromise

    • After Windows booted, Mebromi injected additional malware into the system, allowing the attacker remote control.
  • 4 - Self-reinstallation

    • Even if the malware was removed from the operating system, the infected BIOS automatically reinstalled the malicious files, ensuring persistence.

Impact and Limitations Link to heading

Although Mebromi was innovative at the time, its action was limited to systems that used BIOS Award and ran Windows. However, it demonstrated how firmware modification could be used to create highly persistent attacks.

Detect Rootkits in Firmware Link to heading

Detecting rootkits in firmware is a major challenge, as these threats operate at an extremely low level of the system, often leaving no traces detectable by traditional antiviruses. Because firmware runs before the operating system, a well-designed rootkit can modify system startup without raising suspicion.

Therefore, identifying these threats requires the use of specialized tools, detailed analysis of the integrity of the firmware and the observation of anomalies that may indicate compromise.

Firmware Analysis Tools Link to heading

There are some tools specifically designed to analyze BIOS/UEFI firmware and embedded devices. They allow you to extract, modify and verify the integrity of the firmware, being essential for identifying rootkits.

CHIPSEC Link to heading

CHIPSEC is one of the most used frameworks for firmware security analysis, developed by Intel. It allows:

  • Analyze the integrity of SPI Flash to check for unauthorized modifications.
  • Check write permissions on the firmware, identifying whether write protection has been disabled by a rootkit.
  • Review UEFI security settings such as Secure Boot and Boot Guard configuration.

UEFITool Link to heading

UEFITool is a powerful tool for reverse engineering UEFI firmware. With it, you can:

  • Extract and view individual modules within the firmware.
  • Identify possible injections of malicious code.
  • Modify and rebuild UEFI firmware (useful for research, but dangerous in real environments).

Binwalk Link to heading

Binwalk is a widely used firmware analysis tool for embedded devices. It allows:

  • Identify and extract specific firmware sections.
  • Look for patterns that indicate the presence of hidden malicious code.

In addition to these tools, some manufacturers provide their own firmware integrity checkers, such as Windows Defender System Guard and utilities from Intel, AMD and Dell.

Memory Analysis and Firmware Integrity Link to heading

An effective approach to detecting rootkits in firmware involves checking the integrity of the code stored in the motherboard’s SPI Flash and analyzing the memory while the system is running.

Firmware Dump and Comparison Link to heading

One technique used by security researchers is to extract a copy of the SPI Flash firmware and compare it with the official version provided by the manufacturer. This can be done with tools like CHIPSEC and Flashrom. If discrepancies are found, it is a strong indication that the firmware has been modified.

Volatile Memory Analysis Link to heading

Some rootkits only operate on the firmware memory during boot, without permanently modifying the files in the SPI Flash. To detect this behavior, you can use memory forensics techniques, such as:

  • RAM dump during boot and compared to a clean boot.
  • Monitoring firmware calls to identify injected malicious code.

UEFI Integrity Check Link to heading

Specialized tools, such as Microsoft Defender ATP, offer automatic UEFI checks to detect suspicious modifications. Some manufacturers also include internal protection mechanisms, such as:

  • Boot Guard (Intel) prevents firmware modification at boot.
  • AMD PSP verifies firmware integrity on select AMD processors.

Signs of Infection and System Anomalies Link to heading

Although firmware rootkits are highly stealthy, some signs may indicate their presence:

1. Unexplained Boot Changes Link to heading

  • The operating system boots with unexpected settings.
  • Change of boot order without user intervention.
  • Secure Boot disabled for no apparent reason.

2. Abnormal Persistence of Malware Link to heading

  • Malware that reappears even after complete formatting and system reinstallations.
  • Suspicious files being recreated shortly after deletion.

3. Anomalies in Hardware Devices Link to heading

  • Network card, GPU or other hardware working strangely.
  • System logs showing unexpected access to hardware controllers.

4. Suspicious Communication Link to heading

  • Network traffic to unknown addresses even before the operating system loads.
  • Connections established with remote servers without visible processes on the system.

Ultimately, the use of tools such as CHIPSEC, UEFITool & Binwalk, combined with memory forensic analysis and system anomaly monitoring, can help identify the presence of these rootkits before they cause irreversible damage.

Development of Rootkits in Firmware Link to heading

The development of firmware rootkits is a highly specialized field within offensive security, requiring in-depth knowledge of firmware architecture, reverse engineering and code injection techniques in embedded systems. Unlike conventional rootkits, which operate in the kernel or user space, firmware rootkits act directly on hardware, ensuring extreme persistence and advanced evasion.

Necessary Environment for Research and Development Link to heading

Before developing or analyzing rootkits in firmware, a suitable environment is required, including a retoolkit, development kits, and testing devices.

1. Tools and Frameworks Link to heading

  • UEFI Development Kit (UDK): Official framework for developing UEFI firmwares.
  • TianoCore: Open-source UEFI implementation used to understand its architecture.
  • CHIPSEC: Security audit and analysis tool for firmware.
  • UEFITool: Used for extracting, modifying and reinserting UEFI firmware modules.
  • IDA Pro / Ghidra: Disassemblers used to reverse engineer compiled firmware.
  • QEMU with OVMF: Emulator to test UEFI firmwares without the need for physical hardware.
  • Binwalk & Firmwalker: Analysis and extraction of firmware from embedded devices.

2. Testing Hardware Link to heading

  • Motherboards with SPI Flash accessible for writing and modifying BIOS/UEFI.
  • SPI programmers such as Bus Pirate or CH341A for reading and writing directly to the firmware.
  • Network cards and storage controllers vulnerable to code injections.

Firmware Reverse Engineering Link to heading

To develop a firmware rootkit, the first step is to understand its structure and identify possible injection vectors. This involves extracting and analyzing firmware, disassembling binary code, and identifying modifiable areas.

1. Firmware Extraction and Analysis Link to heading

Firmware can be extracted from the motherboard’s SPI Flash or directly from manufacturer-supplied update files:

  • Firmware reading via SPI using a physical programmer.
  • Firmware extraction from memory dumps (RAM).
  • Decompression of firmware images with Binwalk.

After extraction, the firmware can be analyzed in tools such as IDA Pro or Ghidra to identify critical functions and modules subject to code injection.

2. Identification of Boot Modules Link to heading

In UEFI, rootkits typically inject themselves into DXE (Driver Execution Environment) modules, which run before the operating system and can modify its startup. Some common targets are:

  • DXE Core: Code responsible for executing UEFI drivers.
  • Boot Services: Temporary services used at boot, but which can persist if handled correctly.
  • Runtime Services: Maintain access to the operating system even after boot.

After identifying the modifiable points, the next step is code injection.

Code Injection in UEFI and BIOS Link to heading

Code injection into firmware can be done in several ways, depending on the protection present in the system.

1. Valid Firmware Modification Link to heading

A common approach is to directly modify an original firmware by inserting malicious payloads into existing modules. This can be done with:

  • UEFITool for modifying DXE modules and adding persistent code.
  • Manual editing of ACPI or SMBIOS tables to hide malicious code.
  • Insertion of backdoors in Runtime Services to ensure continuous access to the system.

After modification, the firmware is rewritten to SPI Flash, replacing the original.

2. Exploiting Vulnerabilities in Signed Firmware Link to heading

On systems that require digitally signed firmware, it is possible to exploit vulnerabilities such as:

  • Bypass signature checks on poorly protected firmware.
  • Downgrade attacks, where vulnerable old firmware is installed to allow code injection.
  • NVRAM variable manipulation to modify critical UEFI settings without changing firmware directly.

These techniques allow rootkits to infect systems even without physical access to the hardware.

Persistence and Stealth in Firmware Rootkits Link to heading

1. Persistence through Bootkits Link to heading

A bootkit modifies the system boot process to ensure that the rootkit is executed before the operating system loads. This can be done by:

  • Replacement of Boot Manager in UEFI firmware.
  • Modified boot chain to intercept OS loading.
  • Use of corrupted Root of Trust, where a malicious signed firmware is accepted as legitimate.

2. Detection Evasion Link to heading

To avoid detection by analysis tools, firmware rootkits use techniques such as:

  • Modification of SPI Flash at runtime, preventing analysis tools from detecting changes.
  • System call interception, hiding firmware change logs.
  • Use of malicious Runtime Services to periodically reinfect the operating system.

3. Survivability of Firmware Updates Link to heading

Even if the user tries to remove a rootkit by updating the firmware, some techniques can guarantee persistence:

  • Modification of SPI Flash permissions preventing legitimate firmware rewriting.
  • Backup malicious code on secondary devices (network cards, storage controllers) to reinfect BIOS/UEFI after update.
  • Use of vulnerabilities in the update process to inject code during firmware rewriting.