← Back to Library

MGC: A Compiler Framework Exploiting Compositional Blindness in Aligned LLMs for Malware Generation

Authors: Lu Yan, Zhuo Zhang, Xiangzhe Xu, Shengwei An, Guangyu Shen, Zhou Xuan, Xuan Chen, Xiangyu Zhang

Published: 2025-07-02

arXiv ID: 2507.02057v1

Added to Library: 2025-07-04 04:02 UTC

Red Teaming

📄 Abstract

Large language models (LLMs) have democratized software development, reducing the expertise barrier for programming complex applications. This accessibility extends to malicious software development, raising significant security concerns. While LLM providers have implemented alignment mechanisms to prevent direct generation of overtly malicious code, these safeguards predominantly evaluate individual prompts in isolation, overlooking a critical vulnerability: malicious operations can be systematically decomposed into benign-appearing sub-tasks. In this paper, we introduce the Malware Generation Compiler (MGC), a novel framework that leverages this vulnerability through modular decomposition and alignment-evasive generation. MGC employs a specialized Malware Description Intermediate Representation (MDIR) to bridge high-level malicious intents and benign-appearing code snippets. Extensive evaluation demonstrates that our attack reliably generates functional malware across diverse task specifications and categories, outperforming jailbreaking methods by +365.79% and underground services by +78.07% in correctness on three benchmark datasets. Case studies further show that MGC can reproduce and even enhance 16 real-world malware samples. This work provides critical insights for security researchers by exposing the risks of compositional attacks against aligned AI systems. Demonstrations are available at https://sites.google.com/view/malware-generation-compiler.

🔍 Key Points

  • Introduction of the Malware Generation Compiler (MGC), which exploits compositional blindness in aligned LLMs for malware generation by decomposing malicious requests into benign sub-tasks.
  • Development of the Malware Description Intermediate Representation (MDIR) facilitating a modular approach to represent high-level malicious intents and detailed code snippets.
  • Extensive evaluation demonstrating MGC's effectiveness, showing improvements in functional correctness over existing ransomware generation methods by +365.79% compared to jailbreaking methods and +78.07% compared to underground services.
  • Case studies confirming the capability of MGC to reproduce and enhance 16 known malware samples, indicating its potential for significant security threats.
  • MGC incorporates a feedback loop between weakly aligned and strongly aligned LLMs, allowing for consistent, higher quality code generation while maintaining evasion of safety mechanisms.

💡 Why This Paper Matters

This paper is critical in highlighting the security vulnerabilities posed by advanced LLMs in generating malware through exploitative techniques such as compositional attacks. MGC serves as a potent example of how these vulnerabilities can be leveraged, which raises urgent questions about existing safeguard mechanisms, hence emphasizing the need for improved security frameworks in LLM design.

🎯 Why It's Interesting for AI Security Researchers

This paper is particularly significant for AI security researchers because it exposes the latent dangers associated with LLMs that can be manipulated for malicious intents. The findings offer crucial insights into the inherent weaknesses of current alignment strategies, urging researchers to develop more robust defenses against modular, composition-based evasion tactics that could be used for generating sophisticated malware.

📚 Read the Full Paper