Planting C4: Cross Compatible External C2 for Your Implants

Scott Taylor (Red Team Member · Sony Corporation)

DEF CON 33 · Day 1 · Main Stage

Overview

In the ever-evolving landscape of red team operations and advanced persistent threats, establishing resilient and covert command and control (C2) channels is paramount. Scott Taylor, a Red Team Member at Sony Corporation, presented "Planting C4: Cross Compatible External C2 for Your Implants" at DEF CON, addressing a critical challenge in this domain: the lack of portability and extensibility in existing external C2 profiles. His talk unveiled C4, a novel tool leveraging WebAssembly (Wasm) and the WebAssembly System Interface (WASI) to create a truly language-agnostic and framework-independent system for external C2 communications.

Watch on YouTube

Visual summary for Planting C4: Cross Compatible External C2 for Your Implants by Scott Taylor
Visual summary for Planting C4: Cross Compatible External C2 for Your Implants by Scott Taylor

Key moments

  1. 0:00 Introduction and overview of external C2 technique
  2. 2:40 Problem: limited external C2 options in frameworks
  3. 4:00 Initial C4 for Mythic and language portability challenge
  4. 5:40 Stumbling upon WebAssembly for cross-language compatibility
  5. 6:40 WASI: enabling WebAssembly to interact with operating system
  6. 7:50 WASI's plug-in system potential for external C2

Planting C4: Cross Compatible External C2 for Your Implants

Speakers: Scott Taylor, Red Team Member, Sony Corporation

Conference: DEF CON

YouTube: https://www.youtube.com/watch?v=O0-0u4zJWEM

Overview

In the ever-evolving landscape of red team operations and advanced persistent threats, establishing resilient and covert command and control (C2) channels is paramount. Scott Taylor, a Red Team Member at Sony Corporation, presented "Planting C4: Cross Compatible External C2 for Your Implants" at DEF CON, addressing a critical challenge in this domain: the lack of portability and extensibility in existing external C2 profiles. His talk unveiled C4, a novel tool leveraging WebAssembly (Wasm) and the WebAssembly System Interface (WASI) to create a truly language-agnostic and framework-independent system for external C2 communications.

Taylor's research stems from the observation that while numerous trusted third-party websites are viable for external C2, current C2 frameworks offer only a limited selection of compatible options, and porting custom C2 profiles between different agent languages is a significant hurdle. C4 aims to democratize the development and deployment of external C2 by enabling red team operators to write C2 plugins once, compile them to Wasm, and then seamlessly integrate them into implants written in virtually any programming language. This innovation promises to enhance operational flexibility, reduce development overhead, and allow red teams to rapidly adapt to new C2 vectors, ultimately making their operations more robust and difficult for defenders to detect.

Background

▶ Watch: Introduction and overview of external C2 technique (0:00)

The concept of external C2, also known as third-party C2 or trusted-site C2, is not new in offensive security, with its inclusion in the MITRE ATT&CK framework dating back to 2017. This technique involves malware communicating with its C2 server not directly, but through legitimate and commonly trusted third-party websites or services. The appeal for threat actors and red teams is clear: by masquerading malicious traffic as legitimate user activity on platforms like GitHub, Amazon Web Services (AWS), Google Drive, Dropbox, Microsoft OneDrive, or even Google Calendar, detection becomes significantly more challenging. These services are often whitelisted by enterprise firewalls and proxies, making egress filtering ineffective against such channels.

Earlier in the year of the talk, the LOL C2 (Living Off the Land C2) project further documented a plethora of websites compatible with this technique, highlighting the creative approaches security researchers and threat actors employ, including unusual mediums like Counter-Strike servers. Despite this wide array of potential C2 channels, Taylor pointed out a crucial limitation within existing C2 frameworks, such as Cobalt Strike and Mythic C2. While these frameworks offer some external C2 profiles, the selection is often narrow, and the profiles are typically hard-coded or highly specific to the framework's internal architecture and agent language. For instance, a C2 profile developed for a .NET agent in Mythic would be challenging to port to a Python or C++ agent without significant re-engineering. This lack of portability forces malware developers to either stick to a limited set of options or undertake substantial effort to re-implement C2 logic for each new agent language, hindering rapid development and operational agility. Taylor, as a self-proclaimed Mythic C2 enthusiast, recognized this as a major impediment to leveraging the full potential of external C2 techniques.

Key Findings

▶ Watch: Initial C4 for Mythic and language portability challenge (4:00)

Scott Taylor's research and the development of C4 yielded several key findings that address the limitations of traditional external C2 implementations:

  1. The Portability Problem is Solvable: The primary finding is that the challenge of porting external C2 profiles across diverse C2 frameworks and agent programming languages is not an inherent technical limitation but rather a design problem that can be overcome.
  2. WebAssembly (Wasm) as the Universal Language: Wasm, traditionally associated with browser-based applications, can serve as a highly effective, near-native speed, and language-agnostic compilation target for C2 logic. This allows a single C2 plugin to be written in a high-level language (like Rust), compiled to Wasm, and then executed by agents written in any language that can host a Wasm runtime.
  3. WASI Bridges the Gap to the OS: The WebAssembly System Interface (WASI) is critical to Wasm's utility in offensive security. It provides the necessary bridge for Wasm modules to interact with the underlying operating system, enabling essential C2 functionalities such as making network requests (sockets), reading/writing files (file system interaction), and querying system time. This elevates Wasm beyond a browser-only technology to a powerful tool for system-level operations.
  4. Axism Provides a Robust Plugin System: The project Axism, developed by Dipso, was identified as an ideal universal Wasm plugin system. It provides the runtime environment and host kit necessary to load and execute Wasm modules in various programming languages, complete with features like persistent memory, host-based control over module capabilities (e.g., allowed network endpoints), and execution guardrails for security.
  5. C4 Demonstrates Practical Cross-Compatibility: The C4 tool itself is the culmination of these findings, proving the practical viability of a cross-compatible external C2 system. It successfully abstracts the complexities of C2 communication into modular, Wasm-compiled plugins that can be integrated into implants written in different languages (demonstrated with Python, .NET, and implicitly, others supported by Axism). This significantly reduces the development burden for red teams and expands the operational possibilities for external C2.

Technical Deep Dive

▶ Watch: Stumbling upon WebAssembly for cross-language compatibility (5:40)

The core innovation of C4 lies in its strategic adoption of WebAssembly (Wasm) and the WebAssembly System Interface (WASI), facilitated by the Axism project, to achieve unprecedented portability for external C2 implants.

WebAssembly (Wasm): A Universal Intermediate Format

Wasm is a low-level bytecode format designed for efficient execution in web browsers, but its utility extends far beyond. It compiles to .wasm files, which are compact, load quickly, and execute at near-native speeds, often comparable to compiled C/C++ code. While initially conceived for complex browser applications (e.g., Photoshop in the browser), its key advantages—performance, security (sandboxed execution), and language agnosticism—make it highly attractive for offensive security. The ability to compile code written in languages like C, C++, Rust, and Go into a common Wasm format means that the C2 logic can be developed once, independent of the final implant's language.

WebAssembly System Interface (WASI): Bridging to the Operating System

The limitation of traditional Wasm in offensive operations is its sandboxed nature, preventing direct interaction with the host operating system. This is where WASI becomes indispensable. WASI is an API that allows Wasm modules to access system resources like the file system, network sockets, and the system clock. With WASI enabled, a Wasm module can:

  • Read, write, and delete files.
  • Query the system time.
  • Make network requests, including HTTP/HTTPS.

These capabilities are fundamental for C2 operations, allowing modules to send and receive messages, exfiltrate data, and manage timing. WASI effectively transforms Wasm from a browser technology into a powerful, portable executable format for general-purpose applications, including malware components.

Axism: The Universal Wasm Plugin System

Taylor discovered Axism, a project by Dipso, which provided the perfect framework for C4. Axism is explicitly designed as a universal WebAssembly plugin system. It comprises two main components:

  • Plugin Kit: Allows developers to write plugins in various languages (e.g., Rust, C, C++, Go), compile them to Wasm, and ensure they conform to the Axism plugin interface.
  • Host Kit: Enables applications (like C2 agents) written in different languages (e.g., Python, .NET, JavaScript) to load and execute these Wasm plugins.

Axism's runtime environment offers several features crucial for C2 operations:

  • Persistent Memory: Plugins can maintain state across calls, useful for managing session data or partial messages.
  • Host-Based Control: The host application (the implant) can specify what resources the Wasm module is allowed to access. For example, it can limit network requests to specific HTTP endpoints, enhancing operational security (OPSEC).
  • Execution Guardrails: These security features help prevent malicious or buggy Wasm modules from compromising the host application or system, although in a red team context, the "malicious" intent is often by design.

C4's Architectural Flow

The C4 development pipeline and operational architecture are elegantly designed:

  1. Plugin Development: External C2 logic (e.g., how to send/receive messages via AWS S3) is written in a language like Rust. This code defines specific actions, primarily send and receive functions.
  2. Compilation to Wasm: The Rust code is compiled into a .wasm module. This .wasm file is the portable C2 plugin.
  3. Agent Integration: An implant (the "agent") written in any language (e.g., Python, C#, Go) integrates the Axism host kit.
  4. Plugin Loading and Execution: The agent loads the .wasm plugin. Before execution, the agent's manifest configuration explicitly enables WASI and specifies necessary permissions, such as allowing network connections (potentially restricted to specific domains for OPSEC).
  5. C2 Communication: The agent calls the send and receive functions within the loaded Wasm plugin, passing parameters as a JSON blob. For an AWS S3 plugin, this JSON might include access_key, secret_key, bucket_name, and region, along with the actual message content. The Wasm module then handles the low-level interaction with the external C2 service.

Operational Considerations for Robust C2:

Taylor highlighted several critical aspects for developing operationally ready external C2 channels, which C4's design addresses:

  • Support for Multiple Agents: To handle multiple implants calling back simultaneously without message collision, C4 plugins organize messages into distinct folders or prefixes based on agent identification.
  • Unique Message Naming: To prevent file overwrites on the external service, Wasm modules leverage WASI to read the system time, using it to generate unique filenames for uploaded messages.
  • Large Message Compatibility: The chosen external C2 services (like AWS S3) must support large file sizes to facilitate data exfiltration, a common red team objective. C4's design ensures that the underlying communication mechanism can handle such requirements.

By abstracting the C2 communication logic into portable Wasm modules, C4 allows red teams to develop a rich library of external C2 channels that can be rapidly deployed across diverse implant ecosystems, significantly enhancing their operational flexibility and resilience.

Demo / Proof of Concept

▶ Watch: WASI: enabling WebAssembly to interact with operating system (6:40)

Scott Taylor demonstrated the efficacy of C4 through a series of practical examples, starting with fundamental proofs of concept and culminating in a fully functional AWS S3 external C2 plugin.

The initial steps focused on validating the core capabilities of WebAssembly and Axism:

  1. Hello World: A basic, six-line Rust program designed to simply return "Hello World" was compiled to a .wasm module. Taylor then showed how this module could be loaded and executed across different programming languages (implied to be Python, .NET, etc., given the context of Mythic agents), with each successfully returning the "Hello World" message. This confirmed the fundamental cross-language compatibility of the Wasm-Axism setup.
  1. Reliable HTTP Requests: Stepping up the complexity, a more elaborate Rust program was developed to perform HTTP requests. This module was designed to interact with an external web server and return its status. Again, upon compilation to .wasm and execution within various host languages, each test successfully returned an HTTP status 200, indicating a successful connection and response. This crucial demonstration validated WASI's ability to facilitate network interactions, a cornerstone for any C2 channel.

Following these foundational tests, Taylor presented the first fully realized external C2 plugin: the AWS S3 Plugin.

AWS S3 Plugin Details:

  • Service: Amazon Web Services S3, a widely used cloud storage service popular for file sharing and hosting. Its ubiquitous nature and high trust factor make it an ideal candidate for covert C2.
  • Actions: The plugin exposed two primary functions:
  • Send: An agent sends a message by uploading a file to a designated AWS S3 bucket.
  • Receive: An agent receives a message by downloading a file from the S3 bucket. After retrieval, the plugin automatically deletes the file to maintain operational cleanliness and prevent message re-processing.
  • Operational Robustness:
  • Multiple Agents: Messages were organized into distinct folders within the S3 bucket, each corresponding to a unique agent ID. This prevents message collisions and allows multiple implants to communicate simultaneously.
  • Unique Filenames: To avoid overwriting existing messages, files uploaded to S3 were named dynamically using the system time (obtained via WASI).
  • Large Message Support: S3's inherent support for large files ensures that the channel can be used for exfiltrating significant amounts of data.
  • JSON-based Parameters: All interactions with the Wasm plugin were handled via JSON blobs. For the S3 plugin, the JSON parameters included sensitive AWS-specific details such as the access_key, secret_key, the bucket_name for communication, and the region where the bucket was located. This standardized interface simplifies plugin development and integration.

Python Integration Example:

Taylor provided a clear Python example demonstrating how an agent would interact with the C4 AWS S3 plugin:

  1. Installation: pip install exism – This simple command installs the Axism Python host kit.
  2. Import: import exism – Imports the necessary library.
  3. Manifest Configuration: A manifest file or in-code configuration explicitly enables WASI and grants network permissions. While the demo allowed connections "anywhere" for simplicity, Taylor noted that for real-world OPSEC, these permissions could be restricted to specific AWS S3 endpoints.
  4. Plugin Loading: The .wasm file for the S3 plugin is loaded into the Axism runtime.
  5. Calling Actions: With the plugin loaded, the agent constructs a JSON message containing the necessary AWS credentials, bucket details, and the message payload. This JSON blob is then passed to the plugin's send or receive function. The example showed a basic "test message" being sent. The process for receiving messages was described as equally straightforward.

The presentation concluded by mentioning other developed plugins for popular services like Confluence (a documentation platform) and GitHub Gist (a code snippet sharing service), further underscoring the versatility and extensibility of the C4 framework. This practical demonstration effectively showcased how C4 simplifies the creation and deployment of robust, cross-compatible external C2 channels.

Defensive Implications

▶ Watch: WASI's plug-in system potential for external C2 (7:50)

The C4 tool and the underlying methodology of using WebAssembly for external C2 present significant challenges for defenders, demanding a shift in detection and prevention strategies. The core defensive implication is the increasing difficulty of distinguishing malicious C2 traffic from legitimate enterprise network activity.

  1. Increased Evasion of Egress Filtering: Traditional network perimeter defenses, such as egress filtering, are often rendered ineffective. By leveraging trusted cloud services like AWS S3, Confluence, and GitHub Gist, C4's C2 traffic blends in with legitimate user activity. Defenders need to move beyond simple domain blacklisting and implement more sophisticated behavioral analytics and deeper inspection of traffic to whitelisted domains.
  1. Monitoring Trusted Cloud Services: Organizations must implement robust monitoring for their sanctioned cloud services. This includes:
  • API Call Monitoring: Scrutinizing API calls to services like AWS S3 for unusual patterns. For example, excessive file uploads/downloads, rapid creation/deletion of S3 buckets/objects, or access from unusual geographical locations or user agents could indicate compromise.
  • Unusual File Activity: Look for unusual file types, naming conventions (e.g., timestamp-based names used by C4), or sizes within cloud storage buckets. While S3 supports large files, a sudden influx of large, encrypted, or unusual file types could be suspicious.
  • Access Key Management: The talk's example showed AWS access and secret keys passed directly to the plugin. While this is for demonstration, it highlights the critical need for secure handling and rotation of API keys. Compromised API keys can directly lead to C2 establishment.
  1. Behavioral Analytics on SaaS Platforms: Beyond raw network traffic, defenders should focus on the behavioral patterns of users and applications interacting with SaaS platforms. For instance, an internal system communicating with GitHub Gists or Confluence in a manner inconsistent with typical developer or documentation workflows (e.g., frequent, small, automated interactions) could be a red flag. Establishing baselines for legitimate usage is crucial.
  1. Detection of WebAssembly Runtimes and WASI Usage: While WebAssembly itself is not inherently malicious, its use in non-browser contexts for C2 could become a novel detection vector.
  • Process Monitoring: Monitor for the execution of Wasm runtimes (like those provided by Axism) as standalone processes or as embedded components within suspicious applications.
  • WASI System Calls: If endpoint detection and response (EDR) solutions can monitor low-level system calls, detecting unusual WASI calls (e.g., network socket interactions, file system modifications) originating from Wasm modules in unexpected contexts could be an indicator. This is an advanced detection technique, as WASI is a relatively new interface.
  1. Enhanced Endpoint Security: Given the language-agnostic nature of C4 plugins, endpoint security solutions need to be robust enough to detect the initial compromise and agent deployment, regardless of the agent's programming language. This includes behavioral detection of malicious process injection, memory resident implants, and obfuscated code.
  1. Threat Intelligence Sharing: Staying updated on new external C2 channels and techniques, especially those leveraging emerging technologies like Wasm/WASI, is vital. Sharing threat intelligence about specific cloud service abuse patterns can help organizations proactively defend against these evolving threats.

In essence, C4 forces defenders to move beyond perimeter-centric security and adopt a more granular, behavior-focused approach to monitoring internal systems and their interactions with legitimate cloud services, recognizing that the "trusted" nature of these platforms is precisely what makes them attractive to adversaries.

Key Takeaways

  • External C2 is a Pervasive and Evolving Threat: Threat actors and red teams continue to leverage trusted third-party services (AWS S3, GitHub, Confluence, etc.) for command and control, making detection challenging for traditional network defenses.
  • WebAssembly (Wasm) and WASI Offer Unprecedented C2 Portability: Wasm provides a language-agnostic, high-performance compilation target for C2 logic, while WASI enables these modules to interact with the operating system, bridging the gap between browser-centric Wasm and system-level offensive operations.
  • C4 Enables Cross-Compatible External C2 Plugins: The C4 tool leverages Wasm and WASI, facilitated by the Axism project, to create a modular system where C2 communication logic can be written once (e.g., in Rust), compiled to Wasm, and then seamlessly integrated into implants written in any language (e.g., Python, .NET).
  • Operational Flexibility and Reduced Development Overhead: This approach significantly reduces the effort required for red teams to develop and maintain diverse external C2 channels, enhancing their ability to adapt to new environments and rapidly deploy custom C2 solutions.
  • Defenders Must Adapt to Covert C2 on Trusted Platforms: Blue teams need to evolve their strategies beyond basic egress filtering, focusing on deep monitoring of API calls to sanctioned cloud services, behavioral analytics on SaaS platform interactions, and potentially detecting unusual Wasm runtime activity on endpoints.
  • WebAssembly is an Emerging Technology with Security Implications: Wasm is rapidly developing, and its capabilities, particularly when paired with WASI, have significant implications for both offensive and defensive security, warranting continued research and monitoring by the security community.

About the Speaker(s)

Scott Taylor is a Red Team Member at Sony Corporation, where he applies his expertise in offensive security. Prior to his role at Sony, Taylor honed his skills through red team work at T. Rowe Price and the MITRE Corporation, an organization renowned for its contributions to cybersecurity frameworks like ATT&CK. His foundational experience in technology began as a Linux system administrator, a background he credits with teaching him how to "build before you break things," providing a comprehensive understanding of system architectures that underpins his offensive security work. "Planting C4" marked Scott Taylor's debut as a speaker at DEF CON, and also his first time attending the conference.

Reviews

Dr. Zero (Offensive Security Researcher) — STRONG ACCEPT

Taylor solves a real, underappreciated problem in the red team tooling space — C2 profile portability — with a technically elegant answer: compile your logic to Wasm, deploy everywhere. The Axism integration is genuinely clever, the demos are concrete, and the work is clearly his own. Not groundbreaking enough to redefine the field, but this is exactly the kind of sharp, practical research DEF CON was built for.

Heather Calloway (CISO) — PASS

Technically competent DEF CON offensive tooling talk — WebAssembly as a portable C2 plugin layer is a legitimate engineering contribution for red teams. Outside my lane, and that's the whole story.

→ Top-rated talks at DEF CON 33

All talks from DEF CON 33