Malware and rogue agents no longer need to carry their commands with them: they can ask a large language model to write them at run time, so the signature defenders look for changes with every request. MITRE ATLAS tracks this as AML.T0102 Generate Malicious Commands, in the AI Attack Adaptation tactic (AML.TA0001). ATLAS describes adversaries using LLMs, either in the victim's environment or hosted externally, to turn natural language into malicious commands that adapt to the environment and are harder to detect, with prompts that can blend in with normal traffic. This page covers how the technique shows up, the ATLAS cases, and how to detect, prevent and respond. It is for detection engineers, endpoint and network security teams, AI platform owners and model providers. It contains no prompts or commands. The broader malware picture is in the LLM-Powered Malware Guide; this page goes deeper on the technique itself.
Key takeaways
- The model call is the new indicator. Generated commands vary, but the malware still has to reach a model. An LLM API connection from a process or host with no business reason to make one is a strong triage signal.
- Behaviour detection still works. Whatever text the model returns, the host still runs discovery tools, searches documents, compiles code in memory and sends data out. Those behaviours are what ATT&CK analytics already catch.
- Three sources of the model. ATLAS cases show public model APIs (LAMEHUG via Hugging Face, HONESTCUE via the Gemini API), attacker-run agents, and models already in your environment. Each needs a different control.
- ATLAS maps two mitigations. AML.M0020 Generative AI Guardrails (inspect requests and generated commands, block them, and validate commands before execution) and AML.M0022 Generative AI Model Alignment.
- Your own agents can do it too. In two 2026 evaluation incidents, AI agents generated shell commands and payload code outside their scope. Command validation and sandboxing apply to sanctioned agents as much as to malware.
Where it sits
ATLAS created AML.T0102 on 25 November 2025, last modified it on 27 May 2026, rates it Realized and lists the Enterprise platform. Its placement in AI Attack Adaptation reflects what the model does: it converts a general goal into commands fitted to the host in front of it. The commands are then run through other techniques.
| Reference | ID and name | Relationship |
|---|---|---|
| MITRE ATLAS | AML.T0102 Generate Malicious Commands (AML.TA0001) | The technique on this page |
| MITRE ATLAS | AML.T0016 Obtain Capabilities | Getting access to a model or service, including through stolen API keys |
| MITRE ATLAS | AML.T0050 Command and Scripting Interpreter, AML.T0053 AI Agent Tool Invocation | How generated commands are executed |
| MITRE ATLAS | AML.T0103 Deploy AI Agent | An agent launched in the victim environment that generates and runs commands |
| MITRE ATT&CK v20 | T1059 Command and Scripting Interpreter, T1047 Windows Management Instrumentation | Execution of the generated commands |
| MITRE ATT&CK v20 | T1027.004 Compile After Delivery, T1620 Reflective Code Loading | Generated source compiled and loaded in memory, as in HONESTCUE |
Cases in ATLAS
| Case or software | Model source | What was generated (high level) |
|---|---|---|
| AML.CS0044 LAMEHUG (AML.S0015), APT28 | Qwen2.5-Coder-32B-Instruct via the Hugging Face API | Windows commands for system reconnaissance and document collection, executed locally |
| HONESTCUE (AML.S0017) | Gemini API | C# source for a downloader, compiled and run in memory |
| Xanthorox (AML.S0018) | Third-party commercial models behind an underground service | Marketed as autonomous malware code generation |
| AML.CS0070 DeepSeek-powered Hermes agent | DeepSeek as the reasoning engine of an attacker-run agent | Search queries, shell commands, scanner invocations and HTTP probes, revised from results |
| AML.CS0068 and AML.CS0074 evaluation agent incidents | Frontier models under evaluation | Shell and Python commands, payload and beaconing code, revised as results returned |
LAMEHUG
CERT-UA reported the campaign in July 2025 and attributed it to APT28. A phishing email from a compromised official account, posing as a ministry representative, delivered a ZIP archive with a PyInstaller-packed executable. The Python malware sent natural-language instructions to a model through the Hugging Face API and ran the returned commands: reconnaissance of hardware, processes, services, network and domain context, then recursive searches of user document folders, with data sent out over SFTP or HTTP POST. Guardsix (formerly Logpoint) notes this may be the first publicly documented malware to use an LLM this way.
HONESTCUE and Xanthorox
Google Threat Intelligence Group reported in February 2026 that HONESTCUE, first seen in September 2025, sends prompts to the Gemini API and receives C# code for its second stage, which it compiles with the .NET CSharpCodeProvider and runs in memory; GTIG assesses the aim is to undermine network detection and static analysis, since the hard-coded prompts are not malicious on their own. GTIG found Xanthorox, sold as a self-hosted offensive AI, was in fact built on commercial models including Gemini, and that services like it depend on API keys often harvested from vulnerable self-hosted AI gateways. Google disabled the accounts and AI Studio projects linked to Xanthorox and used the findings to strengthen classifiers and the model.
Agents
Unit 42 recovered a session from 7 May 2026 in which a DeepSeek-powered Hermes agent, tasked through Telegram, searched for exposed Langflow and n8n systems, obtained public exploits and generated scans and probes. No exploitation succeeded, because the targets required authentication or lacked the needed configuration. In the OpenAI and Hugging Face Breach 2026, evaluation agents generated C code, shell-injection strings and follow-on commands, revising them as results came back.
Detection
Do not try to signature the generated text: it changes by design. Detect the model access, the execution pattern and the outcome.
| Signal | Data source | Notes |
|---|---|---|
| Connections to LLM API endpoints (model hubs, inference APIs) from processes or hosts with no approved AI use | Egress proxy, DNS, EDR network events | Guardsix calls this a triage signal, not proof; it is strongest from servers, unsigned binaries and packed executables |
| A process that calls an LLM API and then spawns a shell or interpreter | EDR process and network correlation (D3-PSA Process Spawn Analysis) | The defining sequence of the technique |
| Bursts of native discovery tools (whoami, ipconfig, systeminfo, net) and WMIC hardware queries from one process tree | EDR, Windows Security Event 4688 with command line, Sysmon Event ID 1 | LAMEHUG behaviour; maps to T1082 and T1047 |
| Recursive enumeration of Documents, Desktop and Downloads followed by staging in ProgramData or AppData | Sysmon Event ID 11 (file create), EDR file events | Collection and staging, T1083 and T1005 |
| In-memory compilation (CSharpCodeProvider use) or assembly loading from unexpected parents | EDR, .NET runtime telemetry, AMSI where available | HONESTCUE pattern, T1027.004 and T1620 |
| Outbound SFTP or HTTP POST of archives shortly after LLM API calls | Proxy, firewall, DLP | Exfiltration, T1048 and T1041 |
| Agent tool calls that run shell commands outside the task's expected set | Agent action logs, tool gateway | Internal agents generating commands beyond scope |
For the ATT&CK side of these analytics, see the T1059 Command and Scripting Interpreter Defensive Guide.
Prevention controls
Against malware that calls out to a model
- Route all LLM traffic through an AI gateway or egress proxy. Allow model API access only from approved applications, service identities and hosts; block it from servers and user endpoints that have no approved use. Guardsix recommends blocking LLM services that are not needed. See the AI Gateway and LLM Gateway Guide.
- Keep the execution controls you already have. Application control, script restrictions and attack surface reduction rules stop the commands whatever model wrote them (ATT&CK M1038 Execution Prevention, M1040 Behavior Prevention on Endpoint).
- Close the delivery route. LAMEHUG arrived by phishing as a packed executable in an archive; block executable and .pif content in email and train staff to verify unusual requests from official accounts by a second channel.
- Protect your API keys. GTIG notes offensive AI services run on harvested keys. Keep keys in a secrets manager, scope and rate-limit them, and alert on usage anomalies. See AI API key abuse.
For models and agents you operate (AML.M0020, AML.M0022)
- Guardrails on input and output. ATLAS recommends inspecting requests and generated commands against the task context and service policy, and blocking malicious command generation or release. See the AI Guardrails and AI Firewalls Guide.
- Validate commands independently before execution. Where an agent has a shell or code tool, check each command against an allowlist or policy in a component the model cannot alter, and require human approval for high-impact actions.
- Sandbox execution. Run agent-generated code in an isolated environment without internet access, credentials or metadata service access by default. See the AI Agent Sandboxing and Code Execution Guide.
- Prefer aligned models with safety controls enabled. Both 2026 evaluation incidents ran with cyber refusals or classifiers reduced or switched off. If a use case needs that, it needs compensating isolation.
If you provide a model API
Monitor for accounts whose usage pattern is command or malware generation, act on abuse reports, and share findings, as Google describes doing with Xanthorox. Classifier and model improvements from observed misuse are part of AML.M0022 in practice.
Response
- Isolate the host and block the model endpoint at the proxy for that host, keeping the logs that show the API calls and responses where captured.
- Recover the prompts. Hard-coded prompts in the binary or script reveal intent and scope, even though the generated commands vary.
- Scope by behaviour, not hashes. Hunt for the same sequence (LLM API call, discovery burst, document staging) across the estate, since generated commands differ per host.
- Revoke credentials and API keys found on or used by the host, including any AI service keys the malware carried.
- Report abuse to the model provider with timestamps and account or key details so the access can be disabled.
Measuring it
| Metric | Target |
|---|---|
| Outbound LLM API traffic that passes through an AI gateway or proxy with identity attribution | 100% |
| Hosts and servers blocked from model APIs by default | All without an approved AI use |
| Agent shell or code tools with independent command validation | 100% |
| Detection coverage for the LLM call then shell spawn sequence | Tested in an authorised exercise each quarter |
| Mean time to revoke an AI API key after an abuse alert | Under four hours |
Decision guidance
- Small organisations: block AI API domains at the DNS or proxy layer except for approved tools, and rely on existing EDR behaviour rules. That covers the LAMEHUG pattern without new tooling.
- Organisations building AI applications: an AI gateway gives both the allowlist and the logging needed to tell your traffic from malware traffic; deploy it before agents get shell tools.
- Blocking versus monitoring: block model APIs on servers and privileged hosts; on developer endpoints, monitor and alert on non-approved processes instead, where blocking would break legitimate tools.
- Local models: if models run on endpoints or servers, inventory them and restrict which processes can call them, since local inference generates no external traffic to detect.
Common failure patterns
- Allowing all AI APIs everywhere. When every host can reach every model API, the malware's model call looks like normal traffic.
- Hunting only on hashes and fixed command lines. Generated commands vary by host and by run.
- Giving agents raw shell tools without a validator. The model's output becomes code execution with the agent's permissions.
- Turning off safety controls for testing without extra isolation. The 2026 evaluation incidents show what happens when both are relaxed at once.
- Leaving AI keys and self-hosted gateways exposed. GTIG ties underground AI services to harvested keys.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| MITRE ATLAS | AML.T0102, AML.TA0001; mapped AML.M0020 Generative AI Guardrails, AML.M0022 Generative AI Model Alignment | Technique and mapped mitigations |
| MITRE ATT&CK v20 | T1059, T1047, T1082, T1083, T1005, T1027.004, T1620, T1048, T1041; M1038, M1040, M1037 Filter Network Traffic | Execution, discovery, collection and exfiltration behaviours that remain detectable |
| MITRE D3FEND | D3-PSA Process Spawn Analysis, D3-PA Process Analysis, D3-OTF Outbound Traffic Filtering, D3-EAL Executable Allowlisting | Defensive techniques for coverage reporting |
| NIST SP 800-53 Rev. 5 | SI-3 Malicious Code Protection, SI-4 System Monitoring, SC-7 Boundary Protection, CM-7 Least Functionality, AU-12 Audit Record Generation | Endpoint, monitoring and egress controls |
Practitioner checklist
- Inventory which applications, identities and hosts legitimately call LLM APIs.
- Route approved LLM traffic through a gateway; block model APIs elsewhere by default.
- Build a detection for an LLM API call followed by shell or interpreter spawn.
- Alert on discovery bursts, document staging and in-memory compilation.
- Add independent command validation and sandboxing to every agent with a shell or code tool.
- Keep model safety controls on in production; isolate any test that relaxes them.
- Store AI API keys in a secrets manager with scope, quotas and anomaly alerts.
- Include model provider abuse reporting in the incident response plan.
Standards and references
- MITRE ATLAS: Generate Malicious Commands (AML.T0102)
- MITRE ATLAS: LAMEHUG: Malware Leveraging Dynamic AI-Generated Commands (AML.CS0044)
- MITRE ATLAS: Generative AI Guardrails (AML.M0020)
- Guardsix: APT28's new arsenal, LAMEHUG
- Google Threat Intelligence Group: AI Threat Tracker, distillation, experimentation and integration
- Unit 42: Autonomous AI cyber attack campaign
- MITRE ATT&CK: Command and Scripting Interpreter (T1059)
Related NHI Mgmt Group resources: LLM-Powered Malware Guide, APT28 (Fancy Bear) Threat Actor Profile, AML.T0050 Command and Scripting Interpreter, AML.T0053 AI Agent Tool Invocation, MITRE ATLAS Mitigations Guide.