Skip to content
Threat Feed
medium advisory

Detection of Socat Usage for Stealthy Remote Connections

The socat utility is being identified in malicious contexts when used with local terminal echo disabled and configured for remote TCP or OpenSSL connections, often indicating C2 or lateral movement.

The 'socat' (multipurpose relay) utility is a powerful networking tool often abused by adversaries to establish bidirectional data channels, including reverse shells and C2 tunnels. When executed with the 'echo=0' flag, socat suppresses local terminal echo, a common technique used in malicious scripts to conceal interactive command execution and prevent sensitive data, such as passwords or command output, from being echoed to the local console or logged by terminal history. This behavior is particularly concerning when observed on macOS or Linux endpoints in conjunction with remote TCP, TCP4, TCP6, or OpenSSL sockets. Defenders should monitor for this process pattern as it may indicate an attacker establishing a stealthy remote access session or performing lateral movement across the internal network.

Attack Chain

  1. Attacker gains initial access to a macOS or Linux endpoint.
  2. Attacker downloads or identifies the presence of the legitimate 'socat' binary on the system.
  3. Attacker constructs a command string incorporating 'echo=0' and connection parameters like 'tcp' or 'openssl'.
  4. Attacker executes the socat command via an exploited process or terminal session.
  5. The utility establishes a connection to an attacker-controlled listener.
  6. The disabled local echo flag ensures that subsequent interactive input and output are not printed to the host terminal.
  7. Attacker performs post-exploitation activities, such as credential theft or internal network scanning, over the encrypted or obscured tunnel.

Impact

Successful abuse of socat in this manner allows attackers to maintain stealthy, interactive remote access to compromised systems. This can lead to unauthorized data exfiltration, internal network reconnaissance, and the deployment of additional malicious tools, significantly increasing the risk of environment-wide compromise.

Recommendation

Prioritize the investigation of socat executions that utilize the 'echo=0' flag.

  • Deploy the provided Sigma rule to detect socat executions with the specified command-line arguments.
  • Establish a baseline for legitimate socat usage by administrators and developers in your environment to reduce false positives.
  • Utilize EDR or OSquery telemetry to inspect the parent process of any socat instance identified with these parameters, as anomalous parent-child relationships (e.g., web server processes spawning socat) are a primary indicator of compromise.

Immediate actions

Deploy Sigma detection rule to monitor for socat usage

Detection Engineering 48h

Threat Hunt

Search for all instances of 'socat' in process logs over the last 30 days

T1059 medium medium confidence hunt now

Data: Process creation logs

Mitigations

Implement strict application allowlisting or block socat execution for non-privileged users

medium IT Operations

Detection coverage 1

Detect Socat Execution with Local Echo Disabled

medium

Detects the execution of socat with the 'echo=0' flag used in conjunction with TCP or OpenSSL network connections.

sigma tactics: execution techniques: T1059, T1572 sources: process_creation, macos

Detection queries are available on the platform. Get full rules →