← Lab /Security & privacy

LLM can cheaply generate many structurally diverse but behaviorally identical malware payloads

A single commercial LLM can produce large populations of behaviorally equivalent yet structurally diverse malicious code

Security & privacy arXiv 5 May 2026 Measurement Prototype evidence

Published as “The Infinite Mutation Engine? Measuring Polymorphism in LLM-Generated Offensive Code”

Why it matters

Static signature-based malware detection becomes ineffective against cheap, LLM-driven polymorphic payloads, pushing defenders toward semantic or runtime analysis.

Summary

A commercial LLM (Claude Opus 4.6) can cheaply generate large numbers of behaviorally identical but structurally diverse malware payloads, with mean AST distances of 0.76-0.85 while semantic distances stay below 0.25. When prompts explicitly inject a history of prior variants, structural diversity rises further (AST up to 0.92) and semantic variation increases, at the cost of roughly five times more tokens and a per-payload cost of $0.73. The study evaluates 200 generated Lua payloads (100 per prompting mode) and shows that static signature detection is easily evaded, though semantic similarity remains relatively stable. Evidence is based on systematic distance measurements and clustering analyses; no external real-world malware samples were used.

What they found 1

  1. Inherent prompting yields high structural but low semantic variation across payloads

    “We observe wide structural divergence coupled with semantic stability: mean AST distances reach 0.76-0.85 for early stages while all semantic embedding distances remain below 0.25.”

Caveats 1

  • Even with high structural divergence, semantic distances remain below 0.25, indicating that behavior-based defenses may still be effective.

What’s new here 4

  • Quantifies LLM-generated code polymorphism using both structural (AST) and semantic (embedding) distances.
  • Introduces a history-injection prompting technique to deliberately increase code diversity.
  • Provides a dual-agent pipeline that automatically generates, tests, and validates multi-stage malware payloads.
  • Measures operational cost (tokens, API calls, monetary) of producing polymorphic payloads at scale.