Summary
emp3r0r C2 accepted untrusted agent metadata (such as Transport and Hostname) during check-in and later interpolated these values directly into tmux shell command strings that were executed via /bin/sh -c.
This behavior allows a malicious or compromised agent to inject arbitrary shell commands and achieve remote code execution on the C2 operator host when the crafted metadata is processed.
Affected context
The vulnerability exists in emp3r0r C2 deployments where:
- Agents can supply or influence metadata fields like Transport and Hostname during check-in
- The C2 server constructs tmux commands using these metadata fields
- Commands are executed via
/bin/sh -con the operator host
It is most relevant when operators manage multiple agents, including those in untrusted or potentially compromised environments, where agent-supplied values should not be treated as trustworthy input.
Exploit preconditions
- Attack surface: C2 control channel between agents and the emp3r0r operator host
- Required access: Ability to run or compromise an emp3r0r agent, or otherwise send crafted check-in data to the C2 server
- Trigger point: Processing of agent check-in metadata, where Transport and Hostname are interpolated into tmux command strings
- Why exploitation is possible: Unvalidated, unescaped agent-controlled strings are embedded into shell command lines executed via
/bin/sh -c, allowing command separators and shell metacharacters to alter command flow
Why this happens
The core issue is direct interpolation of untrusted input into shell command strings that are executed by /bin/sh -c.
This maps to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') and CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Instead of treating agent metadata as opaque data and passing it as separate, safely-encoded arguments, the application builds tmux command lines using string concatenation or formatting, allowing specially crafted values to break out of the intended command and introduce arbitrary shell syntax.
Potential impact
- Remote execution of arbitrary shell commands on the C2 operator host
- Full compromise of the C2 server, including access to all connected agents' data and tasking
- Installation of backdoors or persistence mechanisms on the operator infrastructure
- Exfiltration or tampering with operator-side logs, configurations, and operational tooling
- Use of the compromised C2 server as a pivot point into adjacent systems and networks
General mitigation guidance
Effective mitigation focuses on eliminating direct shell construction with untrusted input and reducing trust in agent-supplied metadata:
- Avoid building shell command strings with concatenation or interpolation of any untrusted values; instead, use APIs that accept argument lists (e.g., exec-style calls without a shell) when invoking tmux or other tools.
- Treat agent metadata (Transport, Hostname, and similar fields) as untrusted data and ensure they are never used as raw shell fragments or command-line templates.
- Apply strict validation and normalization to metadata fields: enforce allowed character sets, length limits, and expected formats (for example, hostnames matching RFC-compliant patterns).
- When shell usage is unavoidable, apply robust escaping and quoting to all data arguments and restrict allowed characters to the minimum needed.
- Run the C2 server under a dedicated, minimally privileged account with restricted filesystem and process permissions to limit blast radius if similar issues occur.
- Isolate C2 infrastructure from other critical systems using network segmentation, and apply host-level hardening (MAC/RBAC policies, locked-down sudo, minimal installed tooling).
How teams detect issues like this
High-level detection can focus on both code patterns and runtime behavior:
- Static analysis and code review:
- Search for locations where agent metadata (Transport, Hostname, or similar fields) flows into command construction, especially into tmux invocation code.
- Flag any use of
/bin/sh -c, system-like wrappers, or subprocess APIs withshell=Truecombined with string concatenation or formatting of untrusted data. - Establish secure coding guidelines that prohibit shell execution with untrusted input and enforce them in pull-request reviews.
- Automated security scanning:
- Use static analysis tools configured with rules for command injection (CWE-77/CWE-78) to highlight dangerous sinks and tainted data flows.
- Integrate these checks into CI pipelines so that new uses of shell execution with untrusted input are blocked before deployment.
- Runtime and operational monitoring:
- Monitor the C2 operator host for unusual tmux invocations or child processes spawned from the C2 server process.
- Collect and analyze process command-lines and logs for unexpected shell metacharacters or anomalous Hostname/Transport values associated with command execution.

