The creation of malware is, in every respect, a creative process that constantly seeks new ways to bypass security systems, adapting to technological progress and change. As we have already seen in previous articles, it is inevitable that even incredibly useful and effective tools in both professional and personal contexts—such as AI and LLMs—can also be misused to commit crimes.

This is the case with a new malware variant called LameHug, which leverages large language models (LLMs) to dynamically generate malicious commands on infected Windows systems.

Unlike traditional malware, which relies on predefined instructions, LameHug integrates an LLM to “think” on the spot. This allows it to craft tailor-made commands in real time, adapting to the victim’s environment and making detection significantly more difficult. It was first observed and reported by the Ukrainian CERT, in the context of the ongoing cyberwarfare between Russia and Ukraine.

In this article, we will take a closer look at its behavior, structure, how to detect it, and how to protect your systems.


How LameHug Works

At its core, LameHug behaves like a typical data-theft malware: once inside a Windows system, it searches for valuable files, browser data, and stored credentials. What sets it apart is how it generates its commands.

Instead of pulling hardcoded instructions from its binary or a command-and-control (C2) server, LameHug queries an integrated AI model. Researchers found that it employs the Qwen 2.5-Coder-32B-Instruct model (developed by Alibaba Cloud), accessed through Hugging Face APIs. The malware sends prompts (encoded in base64) describing its goals, and in return receives tailored Windows commands to execute.

Module for LLM's API

Attack chain and technical details

  • Initial delivery: LameHug has been observed spreading through spear-phishing emails, often disguised as government communications. Attachments included ZIP files containing a PyInstaller-compiled executable masquerading as a .pif or .exe. File names such as Attachment.pif and AI_generator_uncensored_Canvas_PRO_v0.9.exe were seen in the wild.

    Phishing Campaign with LameHug. Source: CERT UA
  • Reconnaissance: Commands like systeminfo, wmic, ipconfig, tasklist, and dsquery are dynamically generated and executed to gather system, process, and network details. Results are consolidated in %ProgramData%\info\info.txt.

  • Data staging: The LLM instructs the malware to recursively search user folders (Desktop, Documents, Downloads) for files of interest—Office docs, PDFs, and text files—which are then copied to staging folders for later exfiltration.

  • Exfiltration: Two methods have been observed: (1) via SFTP to a hardcoded IP (144[.]126[.]202[.]227), and (2) via HTTP POST to compromised infrastructure, e.g. stayathomeclasses.com/slpw/up.php.

This workflow shows how LameHug leverages AI not only for command generation but also for adaptive decision-making—choosing techniques based on the victim’s configuration.


Why This Matters

Security researchers have long speculated about the use of AI in offensive operations. LameHug shows that speculation is no longer theoretical—it’s happening now.

The use of an LLM introduces several challenges:

  1. Adaptability – Commands aren’t hardcoded; they’re generated dynamically, meaning defenders can’t rely on known indicators of compromise alone.

  2. Obfuscation – Each execution might look slightly different, frustrating reverse engineering and sandboxing efforts.

  3. Autonomy – Even if cut off from its C2 server, the malware can still “decide” what to do, guided by its embedded AI model.

    LameHug's C2 Connection

And so malware can become tools not only programmed, but also sufficiently “intelligent” to improvise.

Integrating an LLM makes LameHug’s behavior less predictable than that of traditional malware. Each infection can generate different sets of commands depending on the context.

For example, to steal credentials the LLM might decide whether to target Chrome, Edge, or Firefox based on what it finds installed. During reconnaissance it can switch between PowerShell scripts, WMI queries, or dsquery commands.

This variability renders defenses based on static signatures ineffective, and even behavioral tools may fail to recognize dynamically generated variants. In addition, LameHug communicates with legitimate AI infrastructures (such as Hugging Face), so its network traffic can easily blend in with normal outbound HTTPS connections.


Practical Defense Measures

Below are some practical suggestions to prevent and detect this malware in advance:

  • Monitor the use of AI APIs: in most cases, corporate endpoints have no reason to contact services like Hugging Face. Configure your SIEM/EDR to alert on outbound requests to huggingface.co or similar domains.
  • Block suspicious files at the email gateway level: the malware spreads via .pif or PyInstaller executables inside ZIP archives. Set rules to isolate emails with double extensions (e.g., .pdf.zip, .pif, .exe).
  • Detect abnormal reconnaissance activity: build detection logic for command chains such as systeminfo, wmic, and tasklist. Even if they vary, rapid execution by non-privileged users is a strong indicator of compromise.
  • Monitor indicators of compromise (IoCs): track and block known IoCs. The Ukrainian CERT has shared IoCs at this link.
  • Apply application allowlisting: prevent the execution of unauthorized or unsigned binaries, especially those originating from email attachments. Tools like AppLocker can block PyInstaller executables.

Daily Term
Can you guess today’s cybersecurity word in 6 tries?
Play now

Final Thoughts

LameHug illustrates how AI is a double-edged sword for cybersecurity. While it is increasingly adopted by security vendors to enhance detection and response capabilities, attackers are also experimenting with generative models to improve and refine their operations.

LameHug is likely just the prototype of a new generation of AI-driven threats. For security professionals, the challenge will be to integrate AI responsibly into defensive strategies, while anticipating how adversaries will exploit the very same technology.