Detection of Malicious Use of LLM Endpoints for Command and Control
Detection logic identifying unsigned binaries or scripting utilities establishing network connections to various Large Language Model API endpoints for potential command and control.
Adversaries are increasingly leveraging the capabilities of Large Language Models (LLMs) to dynamically perform malicious actions on compromised systems. This threat involves malware or post-exploitation scripts that utilize legitimate LLM APIs as a proxy for command and control (C2) or to execute logic within the affected system. This behavior is characterized by network connections to a broad range of AI and ML infrastructure providers, including OpenAI, Anthropic, Mistral, and various specialized inference services, initiated by unsigned binaries or common Windows/macOS scripting utilities such as PowerShell, curl, or WScript. Because these connections mimic legitimate traffic to AI services, detection must focus on the process context, specifically identifying unauthorized or unsigned code initiating the requests.
Attack Chain
- Initial access is established through standard means, such as spearphishing or exploiting a public-facing service.
- The attacker drops an unsigned or obfuscated payload (e.g., PowerShell script or malicious executable) into a non-standard directory like /tmp/ or \Users\Public.
- The malicious process executes and gathers system information or target data.
- The process initiates an HTTPS connection to an LLM provider's API endpoint (e.g., api.openai.com).
- The attacker sends instructions or prompts to the LLM API to generate code or malicious commands tailored to the system state.
- The response from the LLM is parsed and executed locally by the malicious process.
- The process performs further actions, such as exfiltrating data or establishing persistent access, based on the AI-generated logic.
Impact
Successful exploitation allows attackers to bypass traditional static signature-based defenses by using dynamically generated, AI-assisted malicious logic. This increases the complexity of incident response and attribution, as the malicious commands originate from a legitimate, trusted API service. Affected organizations risk unauthorized data exfiltration, automated system exploitation, and stealthy persistence, as the C2 channel is obscured by traffic destined for reputable AI infrastructure.
Recommendation
- Deploy the provided EQL-based detection rules across all endpoints to monitor for suspicious processes communicating with known LLM API domains.
- Implement strict network segmentation and egress filtering to prevent unauthorized processes from accessing cloud-based AI service APIs.
- Perform a historical search on network proxy and DNS logs for connections to the listed LLM endpoints originating from high-risk or non-standard process paths.
- Review and harden systems to prevent the execution of unsigned binaries or unauthorized scripting tools in sensitive environments.
- If an alert triggers, investigate the process tree and parent process to confirm whether the connection originates from a legitimate user-installed application or a malicious actor.
Immediate actions
Deploy detection rule to monitor connections to LLM domains
Threat Hunt
Search network logs for connections to documented LLM domains
Data: DNS and Proxy logs
Mitigations
Restrict outbound access for scripting tools and unsigned processes
Unauthorized C2 communication
Detection coverage 1
Connection to Common Large Language Model Endpoints
mediumDetects network connections to known LLM service domains initiated by unsigned binaries or common scripting utilities, a pattern often used by malware for C2.
Detection queries are available on the platform. Get full rules →