ESET eggheads have shed more light on the Unified Extensible Firmware Interface (UEFI) rootkit being used by the Kremlin's Fancy Bear hacking crew.
Dubbed Lojax, the software nasty embeds itself within the motherboard firmware of infected Windows PCs, allowing it to run as soon as the machine is powered up or reset, allowing it to ideally spy on the user and evade detection by the operating system or any antivirus tools. The firmware executes at the lowest levels, underneath OS kernels and apps, with full system access.
While ESET blew the whistle on Lojax with a disclosure back in September, the nitty-gritty of how the malware operates was withheld until the annual Computer Chaos Club conference at the end of December, where researcher Frederic Vachon described in a presentation how the UEFI-based rootkit is able to hide in modern firmware. ESET was able to get its hands on a copy of Lojax when one of its customers' computers picked up the cyber-nasty.
In short, Lojax – a modified version of the legitimate Lojack anti-theft software – starts out as a poisoned application delivered via spear phishing emails that, when run by hoodwinked victims, unpacks and runs code that hijacks a vulnerable driver, which is loaded by the UEFI firmware during startup, to install the rootkit in flash memory.
UEFI has a mechanism called DXE that locates and runs device drivers needed to get a machine going, before the OS is booted. Lojax tampers with one of the loaded drivers so that it flips the switch on the firmware's write protection, disabling the safeguard and allowing the chips' contents to be overwritten. At that point, the malware can inject its rootkit into the firmware so that it is run following a subsequent power or reset cycle.
So, the driver is fiddled with so that it unlocks the firmware during next boot, then Lojax alters the flash chip contents to inject its rootkit, and then on next boot, the spyware is up and running. This is because the firmware is expected to maintain its own security.
"The chipset exposes write protection mechanisms that need to be properly protected by the firmware," he explained. "Because there is no such thing as BIOS write protection by default, it is the job of the firmware to do that."
In order to turn off the firmware's write protection, Lojax exploits a known race-condition in Intel's flash memory controllers by repeatedly enabling BIOS updates and attempting to write to flash memory before the motherboard software steps in and automatically disables updates.
Once that is done, Lojax is able to write the full rootkit on to the UEFI firmware, which ensures the malware is installed and run during the operating system startup, making it nearly impossible to remove by anything short of a complete reflash of the board's SPI memory.
Fortunately, Vachon notes, vendors themselves can protect against the attack by fixing and patching the driver vulnerabilities, and/or enabling Secure Boot. This will cause the Lojax malware to automatically abort installation attempts. Secure Boot cryptographically ensures the firmware contents isn't altered. Also, not opening emailed applications as a system administrator helps a lot: the rootkit installer requires sysadmin access. However, it could exploit privilege escalation holes to gain admin control, so the real solution is enabling Secure Boot in the BIOS settings and set a password or other lock to prevent any changes.
"The tool only works if the platform is misconfigured," he explained. "If firmware vendors would have done their job correctly here, this tool would have failed at flashing the firmware, it's a great example of how [important] firmware security is." ®