Kuboid
Open Luck·Kuboid.in
Black Hat2023
Open in YouTube ↗

Mac'ing Sense of the 3CX Supply Chain Attack

Black Hat1,646 views41:54about 2 years ago

This talk provides a detailed technical analysis of the macOS payloads associated with the 3CX supply chain attack, specifically focusing on the 'PoolRAT' backdoor and the 'UpdateAgent' second-stage payload. The speaker demonstrates how to perform rapid triage and reverse engineering of these malicious binaries using tools like nm, c++filt, and lldb. The presentation highlights the importance of behavior-based heuristics and endpoint security monitoring in detecting sophisticated supply chain compromises that bypass traditional signature-based defenses.

Anatomy of the 3CX Supply Chain Attack: Lessons in macOS Payload Analysis

TLDR: The 3CX supply chain attack demonstrated how sophisticated actors can compromise build pipelines to distribute trojanized installers that bypass standard security controls. By analyzing the PoolRAT backdoor and the UpdateAgent payload, researchers uncovered how attackers use simple, obfuscated techniques to maintain persistence and execute arbitrary commands. This incident proves that signature-based detection is insufficient and that defenders must prioritize behavior-based monitoring to catch post-exploitation activity.

Supply chain attacks are no longer theoretical exercises for nation-state actors. The 3CX compromise serves as a masterclass in how a single point of failure in a development environment can cascade into a global incident. When an attacker gains access to a build server, they effectively become the vendor, signing malicious code with legitimate certificates and bypassing the very trust mechanisms designed to protect end users. For those of us in the trenches, this incident highlights a critical gap in our defensive strategy: we are far too reliant on static analysis and vendor-provided trust.

Deconstructing the Payload

The 3CX attack was not a single-stage event. It involved a multi-layered approach where the initial compromise of a Windows-based build environment led to the distribution of a trojanized macOS installer. The primary goal of the macOS payload was to establish a persistent foothold and facilitate the delivery of a second-stage implant.

The first component, dubbed PoolRAT, was a C++ macOS backdoor. Its functionality was relatively standard for this class of malware: it provided the attacker with the ability to execute arbitrary commands, exfiltrate files, and perform basic system reconnaissance. What made it interesting was its simplicity. The malware authors did not rely on complex, custom-built obfuscation engines. Instead, they used straightforward XOR-based encryption for their configuration data and strings.

For a researcher, this is a gift. During triage, you can quickly identify the capabilities of such a binary by examining its exported symbols. Since the malware was written in C++, the function names were mangled by the compiler. Using standard tools like nm and c++filt, you can demangle these symbols to reveal the underlying logic:

nm -gD PoolRAT | c++filt

This command reveals methods like Connect, LoadConfig, and SendPost. These names are not just descriptive; they are functional roadmaps. If you see a binary with these types of exported methods, you are likely looking at a command-and-control (C2) agent.

The Role of Dynamic Analysis

Static analysis has clear limitations, especially when dealing with self-deleting binaries. The second-stage payload, UpdateAgent, was designed to execute and then immediately remove itself from the file system to minimize its forensic footprint. This is a classic anti-forensics technique. If you rely solely on disk-based scanning, you will miss the execution entirely.

To capture these payloads, you must move to dynamic analysis. By using a file monitor or a process monitor, you can observe the malware’s behavior in real-time. In the case of UpdateAgent, the binary would write itself to a temporary location, set its permissions, and then execute. Watching these events in a sandbox allows you to intercept the binary before it triggers its self-deletion routine.

Debugging a dynamic library (dylib) presents its own set of challenges because they are not standalone executables. They require a host process to load them. To debug a dylib, you need to write a simple loader that calls dlopen on the target library. Once the library is loaded into memory, you can attach a debugger like lldb and set breakpoints on the library's constructor. Because of Address Space Layout Randomization (ASLR), the library will be mapped to a different memory address every time, so you must use the image list command in lldb to find the base address and map your disassembler to the correct memory offset.

Why Heuristics Beat Signatures

The 3CX attack underscores why we need to move beyond static signatures. The trojanized installer was signed and notarized by Apple. This means that, from the perspective of the operating system, the file was "approved." If your security strategy relies on checking if a file is signed by a trusted developer, you are already vulnerable to this class of attack.

Instead, focus on behavioral anomalies. A legitimate application like a desktop client for a VoIP service has a predictable communication pattern. It should only talk to its own update servers. When that same application starts making DNS queries to an unknown domain or executing shell commands via popen, that is a high-fidelity indicator of compromise.

Tools like BlockBlock can be configured to alert on or block the execution of non-notarized or suspicious binaries, providing a layer of defense that doesn't rely on the vendor's reputation. Similarly, implementing host-based DNS monitoring allows you to catch C2 traffic even if the binary itself is obfuscated or ephemeral.

Moving Forward

The reality of modern software development is that we are all running code we didn't write, compiled in environments we don't control. The 3CX attack is a reminder that the "trusted" software in your environment is only as secure as the build server it originated from.

As researchers and pentesters, we need to stop treating software updates as inherently safe. During your next engagement, look at the update mechanisms of the applications you are testing. Are they pulling updates over unencrypted channels? Do they verify the integrity of the downloaded payload? Can you intercept the update process and inject your own code? These are the questions that matter. The next big supply chain attack won't be stopped by a better antivirus signature; it will be stopped by a security team that understands the behavioral baseline of their own infrastructure.

Talk Type
research presentation
Difficulty
advanced
Has Demo Has Code Tool Released


Black Hat USA 2023

118 talks · 2023
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in