Skip to content

Persisting in the boot chain

Writing OS Files from Firmware: Dropper Traces and Checks

How LoJax's SecDxe wrote autoche.exe and rpcnetp.exe into Windows through its own NTFS driver and edited BootExecute before boot: traces, checks, recovery.

Goal
Persisting in the boot chain
Layer
Firmware
Where it acts
UEFI drivers (DXE)On the system volumeOn the boot chain map
Platforms
Firmware, Windows
Also known as
firmware dropper, UEFI NTFS dropper
Used by
LoJax
Checked by
None: no module reads its traces

Overview

A firmware implant runs before the operating system, but most of what an attacker wants (a backdoor, a downloader, a document stealer) is easier to write and run as an ordinary program inside the operating system. This technique bridges the two. At every boot, code in the firmware opens the operating system's volume, writes a program onto it, and changes a setting so that the operating system starts that program itself. The firmware part stays small; the payload is a normal executable.

It works at the firmware layer and lands on the OS volume. The result is persistence that survives what usually ends an infection: deleting the files, reinstalling Windows, or replacing the disk. As long as the firmware implant is in the SPI flash, the payload comes back at the next boot.

The design is older than its malicious use. ESET's LoJax white paper describes how Absolute Software's Computrace (LoJack) anti-theft product, pre-installed in the firmware of many laptops, used a firmware module with an NTFS driver to replace autochk.exe with a dropper that installed its small agent, as research described as early as 2009. LoJax, described by ESET in 2018, followed that model with a trojanized Computrace agent and its own DXE driver.

How it works

UEFI firmware normally reads only FAT file systems, which is what the EFI system partition uses. To write into Windows it needs an NTFS driver of its own. The chain ESET describes for LoJax:

StepWhat happensWhere
1. CallbackThe implanted DXE driver registers a function for the ready-to-boot event, signalled when the boot manager is about to choose a device to boot fromFirmware (adding a DXE driver)
2. File systemThe callback loads an NTFS driver embedded in the implant and connects it to the disks, so NTFS volumes become readable and writableFirmware
3. FilesThe payload files are written into the Windows folderOS volume
4. AutostartThe registry hive file %WINDIR%\System32\config\SYSTEM is edited directly on disk so that Windows runs the dropped program early in its start-upOS volume
5. WindowsThe Session Manager runs the program, which installs the real payload and puts the setting backWindows

ESET found that LoJax's NTFS driver was compiled from Hacking Team's leaked UEFI project (vector-edk), itself a wrapper around the open-source ntfs-3g. It can write, which the vendor's AMI NTFS driver in the same firmware could not, and it does not enforce file permissions: a read-only file can be overwritten without error.

Why it hides:

  • The writes happen before Windows runs. No Windows driver, security product or log is active yet to see the files appear or the hive change.
  • The autostart setting is put back. LoJax's autoche.exe restores BootExecute once it has registered the service, so a running system shows the default value.
  • The payload looks legitimate. LoJax's agent is a near-identical copy of Absolute's 2008 small agent, under the service name the real product uses; ESET notes that many antivirus vendors had whitelisted LoJack.

How families use it

FamilyWhat the firmware writesHow Windows starts itSource
LoJaxrpcnetp.exe, the trojanized Computrace small agent, to %WINDIR%\SysWOW64 (64-bit Windows) or %WINDIR%\System32 (32-bit), and autoche.exe to %WINDIR%\SysWOW64The firmware changes autocheck autochk * to autocheck autoche * in the SYSTEM hive file, so BootExecute runs autoche.exe instead of the disk checker. autoche.exe registers rpcnetp.exe as a service named like the Computrace one and restores BootExecuteESET white paper

Outside this catalogue, Kaspersky's 2020 report on MosaicRegressor describes the same pattern in firmware found on two machines. A DXE driver registers a ready-to-boot callback that runs a module named SmmAccessSub. That module, shipped alongside an NTFS driver from Hacking Team's code, writes IntelUpdate.exe to ProgramData\Microsoft\Windows\Start Menu\Programs\Startup on the Windows drive. It first checks for a marker file, setupinf.log, in the Windows folder, and Kaspersky says the modules would rewrite the malware if it were removed. A separate module marks the firmware as infected by setting a UEFI variable named fTA.

Traces it leaves

WhereWhatSource
%WINDIR%\SysWOW64\autoche.exeLoJax's dropper; Windows ships autochk.exe, not autoche.exeESET
%WINDIR%\SysWOW64\rpcnetp.exe or %WINDIR%\System32\rpcnetp.exeLoJax's agent; Absolute's legitimate agent has the same nameESET
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecuteautocheck autoche * only between the firmware's edit and autoche.exe restoring itESET
HKLM\SYSTEM\CurrentControlSet\Services\<name>A service whose image is rpcnetp.exeESET
ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\IntelUpdate.exe, %WINDIR%\setupinf.logMosaicRegressor's payload and marker fileKaspersky
UEFI variable fTAMosaicRegressor's infection marker, in NVRAMKaspersky
NetworkAgent traffic to the servers in ESET's IOC listESET
BehaviourFiles that come back after deletion, at the next bootESET, Kaspersky
SPI flashThe implant that does the writingESET, Kaspersky

Because the files are written from outside Windows, the usual records of their creation (a process that wrote them, a security product's file event, an audit event for the registry change) should not exist. A program that appears at boot with no Windows process behind it is itself a lead.

How to check a host

Offline, from a disk image or a collection:

  • SYSTEM hive. Read BootExecute under Session Manager in every control set: anything other than autocheck autochk * and known third-party entries needs an explanation. List services whose image path points to rpcnetp.exe or to any program in SysWOW64 that no product explains. See Boot Execute and Windows services on windowspersistence.com.
  • Files. Look for autoche.exe and rpcnetp.exe in System32 and SysWOW64, the common Startup folder for IntelUpdate.exe, and setupinf.log in the Windows folder. Compare any rpcnetp.exe with what the organisation's Absolute deployment, if there is one, should contain.
  • Timeline. Compare the files' creation times with the boot times in the System log, and with Prefetch and Amcache entries for the programs.

Live, elevated:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v BootExecute
Get-ChildItem C:\Windows\SysWOW64\autoche.exe, C:\Windows\SysWOW64\rpcnetp.exe, C:\Windows\System32\rpcnetp.exe, C:\Windows\setupinf.log -ErrorAction SilentlyContinue
Get-ChildItem "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" -Force
Get-CimInstance Win32_Service | Where-Object PathName -match 'rpcnetp' | Select-Object Name, PathName, State

Then the decisive test: preserve and delete a suspect dropped file, reboot, and see whether it returns. If it does and no Windows component put it back, the source is below the operating system. Dump and compare the firmware as described in adding a DXE driver.

What these checks cannot prove: LoJax's autoche.exe restores BootExecute, so a clean value on a running machine proves nothing. A file that returns may also be legitimate: Absolute's own product is built to survive reinstallation from firmware. Absence of the files clears neither the firmware nor the host: the payload may simply not have been dropped yet, or may be one these reports do not list.

What the checker looks for

None of the checker's modules can see this technique, so checks is empty for it. The writing code is in the SPI flash, and the files it drops are ordinary Windows files and registry values.

  • esp reads the EFI system partition and its BCD stores, not the Windows volume's SYSTEM hive or System32.
  • measuredboot does not compare firmware (PCR 0) measurements between boots, and the dropper writes after the boot applications are measured.
  • bootsector is not involved.

The Windows side is not a driver either: rpcnetp.exe is an ordinary service, and autoche.exe and BootExecute are outside rootkits.dev's driver and kernel module checks, as the LoJax page explains. Check them with the commands above. See what an offline bootkit check can and cannot prove.

Mitigation and recovery

Prevent the firmware implant, since the dropper cannot be blocked once it runs:

  • keep BIOS write protection enabled and locked, and use platforms with Intel Boot Guard or an equivalent (writing the SPI flash from the operating system);
  • Secure Boot does not help: ESET corrected its first LoJax guidance to say so, since it does not check the firmware's own drivers;
  • monitor BootExecute, services and Startup folders against a baseline, so an unexplained entry or a returning file raises an alert;
  • for Absolute customers, ESET relays Absolute's May 2018 statement that its recent agents are not affected by the weaknesses LoJax relied on.

The reports do not discuss disk encryption. Our inference, untested: a firmware NTFS driver has no key to a BitLocker-encrypted volume, so this kind of dropper should not be able to write into one.

Recover:

  1. Preserve the dropped files, the SYSTEM hive and a flash dump.
  2. Reflash the SPI flash with the vendor's image, or replace the board, and confirm with a new dump (adding a DXE driver).
  3. Only then clean the operating system. Deleting the files and the service while the firmware is infected is undone at the next boot. Reinstalling is the safer choice: ESET found other Sednit tools on the same hosts.
  4. Rotate credentials and investigate the network for the related malware the reports name.

Sources

Primary public reports, newest first.

  1. 2020-10-05MosaicRegressor: Lurking in the Shadows of UEFIKaspersky
  2. 2018-09-27LoJax: First UEFI rootkit found in the wild, courtesy of the Sednit groupESET
  3. 2018-09-27LOJAX: First UEFI rootkit found in the wild, courtesy of the Sednit group (white paper)ESET
  4. 2018-09-26LoJax indicators of compromiseESET
  5. 2018-05-01Lojack Becomes a Double-AgentArbor Networks ASERT

See also

Related techniques

Families that use it