Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel

Efstratios Chatzoglou (Penetration Tester · PwC Greece)

BruCON 0x11 · Day 1 · Gouden Carolus

Overview

In a revealing talk at BruCON, Efstratios Chatzoglou, a Penetration Tester at PwC Greece, unveiled a novel and highly stealthy method for establishing Command and Control (C2) over compromised systems by weaponizing a seemingly innocuous browser feature: the Native Messaging API. Titled "Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel," Chatzoglou's research demonstrates how attackers can leverage the trusted environment of a web browser to execute direct commands on an operating system, often bypassing sophisticated Endpoint Detection and Response (EDR) solutions.

Watch on YouTube

Visual summary for Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel by Efstratios Chatzoglou
Visual summary for Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel by Efstratios Chatzoglou

Key moments

  1. 0:00 Introduction to weaponizing browser native messaging
  2. 4:12 Understanding the Native Messaging API
  3. 8:00 Covert browser extension installation and persistence
  4. 14:40 Direct command execution via reflective DLL loading
  5. 23:20 Live demonstration of command and control
  6. 25:50 Zero EDR detections and process analysis
  7. 28:00 Mitigation strategies against this attack

Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel

Speakers: Efstratios Chatzoglou, Penetration Tester, PwC Greece

Conference: BruCON

YouTube: https://www.youtube.com/watch?v=f74h3-oeLr8

Overview

In a revealing talk at BruCON, Efstratios Chatzoglou, a Penetration Tester at PwC Greece, unveiled a novel and highly stealthy method for establishing Command and Control (C2) over compromised systems by weaponizing a seemingly innocuous browser feature: the Native Messaging API. Titled "Stealth in Plain Sight: Turning Native Messaging into a Covert C2 Channel," Chatzoglou's research demonstrates how attackers can leverage the trusted environment of a web browser to execute direct commands on an operating system, often bypassing sophisticated Endpoint Detection and Response (EDR) solutions.

This presentation delves into a decentralized C2 architecture that offers out-of-the-box persistence and direct command execution without relying on traditional shellcode, addressing common limitations of conventional C2 frameworks. The core innovation lies in transforming the legitimate communication channel between browser extensions and native applications into a covert conduit for malicious activity. This approach highlights a critical blind spot in current security paradigms, where browser-initiated processes are often granted a high degree of trust, making detection challenging for even advanced security tools.

The significance of this research extends beyond a mere proof of concept; it provides a blueprint for attackers to establish resilient and low-detection C2 channels that blend into legitimate network traffic and system processes. By exploiting the inherent trust placed in browser functionalities, Chatzoglou's work underscores the need for a re-evaluation of how security solutions monitor and scrutinize browser-related activities, particularly those involving inter-process communication with the underlying operating system.

Background

▶ Watch: Introduction to weaponizing browser native messaging (0:00)

Traditional C2 frameworks, while effective, often suffer from several inherent weaknesses. Many are centralized, creating a single point of failure that, once detected, can lead to the immediate collapse of the entire C2 infrastructure. Furthermore, they frequently rely on outdated post-exploitation techniques or predictable network patterns that are increasingly profiled and flagged by modern EDRs and network monitoring tools. The speaker aimed to address these limitations by developing a decentralized and adaptive C2 model that could achieve remote command execution, network enumeration, privilege escalation, and data exfiltration with greater stealth and resilience.

The foundation of this novel C2 channel is the Native Messaging API, a standard browser feature designed to facilitate communication between web browser extensions and native applications installed on a user's computer. This API enables extensions to exchange messages with trusted helper applications, providing a bridge between the browser's sandbox and the host operating system. Examples of its legitimate use include password managers like Bitwarden or 1Password, which might use a browser extension to interact with a desktop application to retrieve and fill credentials. This communication pathway is supported across major browsers (Chrome, Edge, Firefox) and operating systems (Windows, macOS, Linux), making it a ubiquitous and often overlooked vector for abuse.

The problem, as identified by Chatzoglou, stems from the inherent trust placed in browser processes and their legitimate communication channels. EDRs and other security tools are typically tuned to detect anomalous process creation, suspicious network connections, or the execution of known malicious binaries or shellcode. However, when a seemingly legitimate browser process, through its intended API, initiates communication with a user-installed application that then executes commands, it can easily fly under the radar. This "plain sight" approach leverages the browser's high trust level to mask malicious intent, presenting a significant challenge for defenders attempting to distinguish between legitimate browser-driven interactions and covert C2 activities.

Key Findings

▶ Watch: Covert browser extension installation and persistence (8:00)

The central discovery of this research is the successful weaponization of the browser's Native Messaging API to establish a highly covert and persistent C2 channel. Chatzoglou demonstrated that this method offers direct command execution capabilities on the victim's operating system, circumventing many conventional security controls.

Key findings include:

  • Zero EDR Detections: Across extensive testing with multiple popular EDR systems (trial versions tested for over a month), the C2 framework consistently evaded detection. Even common commands like whoami and ping, which often trigger alerts when executed through suspicious channels, went unnoticed. This evasion is attributed to the attack's reliance on legitimate browser features and a communication flow that EDRs are not typically configured to scrutinize for malicious intent.
  • Out-of-the-Box Persistence: The technique allows for robust persistence mechanisms. By leveraging scheduled tasks to automatically launch the browser with specific flags (e.g., --headless --user-data-dir) and load the malicious extension, the C2 connection can be re-established automatically, even after system reboots.
  • Decentralized C2 Architecture: The framework supports a decentralized model, enabling unique domains per victim. This significantly reduces the risk of a single point of failure inherent in centralized C2s and complicates takedown efforts, as each victim can communicate with a distinct C2 server or domain.
  • Data Exfiltration Capability: The C2 can reliably exfiltrate data, demonstrated by grabbing files from the victim's system, encoding them in Base64 (primarily to prevent corruption during the multi-step transfer process, not for obfuscation), and uploading them to the C2 server.
  • HTTP/3 (QUIC) Support: The C2 framework can utilize modern communication protocols like HTTP/3 (QUIC), which offers performance benefits and can further blend into contemporary network traffic, making it harder to differentiate from legitimate web activity.
  • User-Level Access: The initial establishment of the C2 connection does not require administrative privileges; it operates entirely within the context of the user's access, simplifying the post-exploitation phase once initial access is gained.

These findings collectively highlight a potent new avenue for adversaries to maintain covert access and control over compromised systems, leveraging trusted components of the operating environment to remain undetected.

Technical Deep Dive

▶ Watch: Direct command execution via reflective DLL loading (14:40)

The architecture of this covert C2 channel is ingeniously designed around the interplay of several components, leveraging the Native Messaging API as its backbone. The overall threat model assumes initial access has already been established on the victim's system, allowing for the deployment of the necessary malicious components.

At a high level, the system comprises:

  1. An attacker-controlled web server (C2 server) on the internet.
  2. A malicious browser extension installed on the victim's machine, acting as a middleman.
  3. A native application deployed on the victim's machine, responsible for executing commands directly on the operating system.

Components and Their Roles:

  • Native Application (native_messaging.exe): This is a C++ executable (though other languages like Python or batch scripts could be used) that resides on the victim's machine. Its primary function is to receive commands from the browser extension, execute them, and return the output. It communicates with the browser extension via standard input/output streams, which is how the Native Messaging API works. The speaker noted that for HTTP/3 communication, an external library like libkl.dll was used, though it could be embedded. Crucially, the native application doesn't require administrative access to run or establish its connection.
  • native_app.json: This JSON manifest file is critical for the browser to recognize and interact with the native application. It specifies the native application's path, a description, and, most importantly, a list of allowed browser extension IDs that can communicate with it. This file must be correctly deployed alongside the native application.
  • Registry Entry: For the browser to locate the native_app.json manifest, a specific registry entry must be created. For Chrome on Windows, this path is typically HKCU\SOFTWARE\Google\Chrome\NativeMessagingHosts\<app_name>. This entry points to the location of the native_app.json file, effectively registering the native application with the browser. Different browsers (e.g., Microsoft Edge) will have slightly different registry paths.
  • Malicious Browser Extension: This extension, developed for Chrome and Microsoft Edge (due to their prevalence in enterprise environments), acts as the primary communication bridge. It consists of:
  • manifest.json: Defines the extension's properties, permissions, and, crucially, declares its ability to communicate with the native application specified by the native_app.json file.
  • background.js: This JavaScript file contains the core logic. It establishes a connection with the registered native application, polls the C2 web server every 30 seconds (like a beacon) for new commands, and forwards responses from the native application back to the C2 server. The speaker mentioned it's around 1000 lines of plain text JavaScript, without obfuscation in the proof-of-concept.

Installation and Persistence:

The installation process is relatively complex, requiring the deployment of multiple files and registry modifications. The speaker detailed challenges, especially with Chrome:

  • Extension Installation: Initially, the speaker attempted to use the --load-extension flag when launching the browser via a modified shortcut (.lnk file). While this worked for Microsoft Edge, Chrome would delete the extension upon browser termination.
  • Chrome Persistence Solution: To overcome Chrome's behavior, two methods were identified:
  1. Replacement: Replace the background.js file of an already installed, legitimate Chrome extension (e.g., Google Sheets) with the malicious one, maintaining the original extension's path in the user's AppData folder.
  2. Headless Mode with User Data Directory: Launch Chrome using both the --headless and --user-data-dir flags. This combination allows the extension to run in a non-visible browser instance, preventing user awareness of the extension or any "developer mode" pop-ups (especially relevant for Edge).
  • Scheduled Tasks: To achieve persistence, a scheduled task is created to automatically launch the browser (with the appropriate flags for the malicious extension) at system startup or regular intervals, ensuring the C2 channel remains active.

Command Execution Flow:

The execution of commands is a multi-stage process designed to bypass direct execution restrictions:

  1. Beaconing: The browser extension periodically (every 30 seconds) polls the attacker's C2 web server for new commands.
  2. Command Retrieval: The C2 server responds with a URL pointing to a DLL file. This DLL contains the actual command to be executed.
  3. DLL Download: The native application, upon receiving the DLL URL from the extension, downloads the DLL from the C2 server.
  4. Reflective DLL Loading and Execution: This is a critical step. The native application does not directly execute the command string it receives. Instead, it loads the downloaded DLL reflectively into its own process space. This DLL then contains the logic to execute the desired command. The speaker showed a C++ code snippet demonstrating a CreateProcess call to cmd.exe to run the command embedded within the DLL. This reflective loading helps evade direct static analysis of the native application for malicious command strings.
  5. Output Capture (with limitations): The DLL attempts to capture the output of the executed command. However, a significant limitation was noted: when commands spawn new subprocesses (e.g., net use), the native application does not have direct access to their output. Workarounds might involve writing output to a temporary file (less stealthy) or operating without direct output confirmation.
  6. Response Forwarding: The captured output is sent back to the native application, then forwarded to the browser extension, and finally transmitted by the extension to the C2 web server.

Communication and Decentralization:

The C2 server can be any web server (Apache, Nginx, Caddy) supporting HTTP/1 or, preferably, HTTP/3 (QUIC). The decentralized approach allows for unique domains per victim, making it challenging for defenders to block all C2 communications with a single network signature.

Demo / Proof of Concept

▶ Watch: Zero EDR detections and process analysis (25:50)

The speaker provided a live demonstration of the C2 in action, showcasing its stealth and functionality. The video portion of the talk displayed a split screen: on the left, the attacker's web-based C2 interface; on the right, the victim's Chrome browser.

The demonstration began with the victim's Chrome browser being launched, pre-configured with the malicious extension and native application. The C2 interface on the left initially showed no active connections. After a short delay, the browser extension successfully beaconed back to the C2 server, causing the interface to update and indicate an active victim.

The attacker then proceeded to issue commands:

  1. A URL pointing to a DLL containing the whoami command was sent to the victim. The native application downloaded and reflectively executed this DLL.
  2. Within moments, the output of the whoami command appeared on the C2 interface, confirming successful remote execution.
  3. The process was repeated with a ping command, demonstrating the speed and responsiveness of the C2 channel. The ping output was similarly retrieved and displayed on the attacker's dashboard.

A key aspect highlighted during the demo was the complete lack of user awareness. Even without the --headless flag, the victim's browser showed no warnings or indications of the malicious extension's activity. The communication appeared normal, and no EDR alerts were triggered, reinforcing the "stealth in plain sight" concept. The C2 interface itself was simple, displaying the upload directory, available files, last update times, and a query interface to send custom URLs (for DLLs) and view command outputs.

Defensive Implications

▶ Watch: Mitigation strategies against this attack (28:00)

Given the stealthy nature of this C2 channel, traditional EDRs often fail to detect it. Chatzoglou outlined several crucial defensive strategies to mitigate this threat:

  1. Group Policy Objects (GPOs) / Mobile Device Management (MDM):
  • The most effective defense is to disable the installation of non-whitelisted browser extensions through GPOs or MDM solutions. This policy directly prevents the initial compromise step, as the malicious extension cannot be installed. While attackers might attempt to replace existing extensions, robust browser validation features usually prevent this.
  • This measure essentially cuts off the attack chain at its root, preventing the establishment of the browser-based communication conduit.
  1. Application Control (AppLocker / Windows Defender Application Control - WDAC):
  • Organizations should implement application control policies to restrict the execution of unauthorized executables, including the native application component (native_messaging.exe).
  • However, the speaker noted a limitation: the Native Messaging API is not restricted to .exe files. Attackers could potentially use Python scripts, batch files, or other legitimate interpreters to achieve the same goal, requiring a broader and more sophisticated application control strategy. While this limits the specific attack vector, it doesn't entirely eliminate the potential for abuse of the Native Messaging API.
  1. Enhanced Monitoring and Alerting:
  • Registry Entry Monitoring: Crucial for detection is the monitoring of specific registry keys, particularly those related to Native Messaging Hosts. Any unexpected or newly created entries under paths like HKCU\SOFTWARE\Google\Chrome\NativeMessagingHosts\ should be immediately flagged and investigated. These entries are non-standard for most users and indicate a deliberate attempt to register a native application with the browser.
  • Scheduled Task Monitoring: Keep a close eye on newly created or modified scheduled tasks, especially those configured to launch web browsers with unusual command-line arguments such as --load-extension, --headless, or --user-data-dir. These flags, particularly in combination, are strong indicators of suspicious activity aimed at achieving persistence and covert execution.
  • Process Analysis: Implement behavioral detection rules for suspicious process chains. A clear indicator of this attack is the process tree: a browser (e.g., chrome.exe or msedge.exe) spawning cmd.exe, which then launches the native_messaging.exe (or a similar native application), which in turn spawns another cmd.exe to execute the actual command. This nested process creation pattern involving browser processes and cmd.exe is highly anomalous and should trigger high-severity alerts.
  • Network Traffic Analysis: While the communication blends into legitimate HTTP/3 or HTTP/1 traffic, monitoring for unusual beaconing patterns (e.g., consistent polling to new or suspicious domains) or large Base64-encoded uploads to non-standard endpoints could provide indicators of compromise.

By combining stringent application control with vigilant monitoring of system configurations and process behaviors, defenders can significantly enhance their ability to detect and prevent this sophisticated C2 technique.

Key Takeaways

  • Novel C2 Vector: The browser's Native Messaging API presents a stealthy and largely undetected channel for establishing Command and Control, leveraging legitimate browser functionalities to evade EDRs.
  • Decentralized and Persistent: This C2 framework offers a decentralized architecture, mitigating single points of failure, and achieves robust persistence through scheduled tasks and headless browser execution.
  • Direct Command Execution: Attackers can execute direct operating system commands by having a native application download and reflectively load malicious DLLs containing the commands, bypassing traditional shellcode detection.
  • Challenging EDR Evasion: The reliance on trusted browser processes and their internal APIs allows the C2 to operate "in plain sight," leading to zero detections in tests against popular EDR solutions.
  • Critical Defensive Focus Areas: Effective defenses require strict GPO enforcement to prevent unauthorized extension installations, application control for native applications, and meticulous monitoring of registry entries, scheduled tasks, and anomalous process chains involving browser executables and cmd.exe.
  • User-Level Compromise: The attack primarily operates at the user level, requiring initial access but not necessarily administrative privileges to establish the C2 connection, simplifying post-exploitation efforts.

About the Speaker(s)

Efstratios Chatzoglou is a Penetration Tester at PwC Greece. His work focuses on uncovering novel attack techniques and vulnerabilities to enhance cybersecurity defenses. His research, as presented at BruCON, demonstrates a deep understanding of browser internals and operating system interactions, highlighting innovative ways to achieve covert command and control over compromised systems.

Reviews

Dr. Zero (Offensive Security Researcher) — SOLID

This is a slick post-exploitation trick that abuses the Native Messaging API to turn Chrome into a covert C2 beacon. Chatzoglou builds a functional, decentralized framework that weaponizes trust in browser processes, forcing defenders to actually look at extension manifests and registry keys instead of just staring at network logs.

Heather Calloway (CISO) — SOLID

This is a technical demonstration of how attackers can bypass modern EDRs by weaponizing the browser's Native Messaging API to establish a covert C2 channel. It proves that relying solely on endpoint agents for malicious binary detection fails when the browser itself acts as a trusted conduit. Worth your endpoint architecture team's time to ensure extension whitelisting policies are actually deployed and enforced.

→ Top-rated talks at BruCON 0x11

All talks from BruCON 0x11