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:
| Step | What happens | Where |
|---|---|---|
| 1. Callback | The 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 from | Firmware (adding a DXE driver) |
| 2. File system | The callback loads an NTFS driver embedded in the implant and connects it to the disks, so NTFS volumes become readable and writable | Firmware |
| 3. Files | The payload files are written into the Windows folder | OS volume |
| 4. Autostart | The registry hive file %WINDIR%\System32\config\SYSTEM is edited directly on disk so that Windows runs the dropped program early in its start-up | OS volume |
| 5. Windows | The Session Manager runs the program, which installs the real payload and puts the setting back | Windows |
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.exerestoresBootExecuteonce 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
| Family | What the firmware writes | How Windows starts it | Source |
|---|---|---|---|
| LoJax | rpcnetp.exe, the trojanized Computrace small agent, to %WINDIR%\SysWOW64 (64-bit Windows) or %WINDIR%\System32 (32-bit), and autoche.exe to %WINDIR%\SysWOW64 | The 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 BootExecute | ESET 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
| Where | What | Source |
|---|---|---|
%WINDIR%\SysWOW64\autoche.exe | LoJax's dropper; Windows ships autochk.exe, not autoche.exe | ESET |
%WINDIR%\SysWOW64\rpcnetp.exe or %WINDIR%\System32\rpcnetp.exe | LoJax's agent; Absolute's legitimate agent has the same name | ESET |
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute | autocheck autoche * only between the firmware's edit and autoche.exe restoring it | ESET |
HKLM\SYSTEM\CurrentControlSet\Services\<name> | A service whose image is rpcnetp.exe | ESET |
ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\IntelUpdate.exe, %WINDIR%\setupinf.log | MosaicRegressor's payload and marker file | Kaspersky |
UEFI variable fTA | MosaicRegressor's infection marker, in NVRAM | Kaspersky |
| Network | Agent traffic to the servers in ESET's IOC list | ESET |
| Behaviour | Files that come back after deletion, at the next boot | ESET, Kaspersky |
| SPI flash | The implant that does the writing | ESET, 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
BootExecuteunderSession Managerin every control set: anything other thanautocheck autochk *and known third-party entries needs an explanation. List services whose image path points torpcnetp.exeor to any program inSysWOW64that no product explains. See Boot Execute and Windows services on windowspersistence.com. - Files. Look for
autoche.exeandrpcnetp.exeinSystem32andSysWOW64, the common Startup folder forIntelUpdate.exe, andsetupinf.login the Windows folder. Compare anyrpcnetp.exewith 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.
espreads the EFI system partition and its BCD stores, not the Windows volume's SYSTEM hive orSystem32.measuredbootdoes not compare firmware (PCR 0) measurements between boots, and the dropper writes after the boot applications are measured.bootsectoris 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:
- Preserve the dropped files, the SYSTEM hive and a flash dump.
- Reflash the SPI flash with the vendor's image, or replace the board, and confirm with a new dump (adding a DXE driver).
- 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.
- Rotate credentials and investigate the network for the related malware the reports name.
Sources
Primary public reports, newest first.
- 2020-10-05MosaicRegressor: Lurking in the Shadows of UEFIKaspersky
- 2018-09-27LoJax: First UEFI rootkit found in the wild, courtesy of the Sednit groupESET
- 2018-09-27LOJAX: First UEFI rootkit found in the wild, courtesy of the Sednit group (white paper)ESET
- 2018-09-26LoJax indicators of compromiseESET
- 2018-05-01Lojack Becomes a Double-AgentArbor Networks ASERT
See also
Related techniques
- Adding a DXE driver to the firmwarePersisting in the boot chain
- Writing the SPI flash from the operating systemGetting past Secure Boot
- Patching an existing firmware modulePersisting in the boot chain
Families that use it
- LoJaxFirmware implant