TL;DR
Malware authors are increasingly using less common programming languages and compilers to evade detection by static analysis tools. This paper investigates this trend, demonstrating that these choices significantly reduce detection rates while increasing the complexity of reverse engineering. The findings highlight a critical arms race between malware developers and security researchers, emphasizing the need for more robust and language-agnostic detection methods.
What Problem Does This Paper Address?
The cybersecurity landscape is constantly evolving, with malware becoming more sophisticated and numerous. A primary defense mechanism against malware is static analysis, which examines code without executing it. However, traditional static analysis methods, particularly signature-based detection, struggle when malware authors deviate from common programming languages and compilers. Minor changes in code structure, often introduced by different compilers or less mainstream languages, can render existing detection rules ineffective. This creates a blind spot for security professionals, allowing novel or re-engineered malware to slip through defenses. The paper addresses the question of how much this shift in programming language impacts malware detectability and reverse engineering effort, and what benefits attackers gain from it.
Methods
The researchers conducted a multi-faceted experiment to address their research questions.
- Dataset Creation: They generated a set of malicious samples using various programming languages and compilers. To avoid biases from obfuscation techniques, these samples were designed to be simple and directly implement common malware functionalities (e.g., reverse shell, shellcode execution).
- VirusTotal Analysis (RQ1): The generated binaries were submitted to VirusTotal to assess their detection rates by commercial antivirus engines. This allowed them to quantify the impact of language and compiler choice on detectability.
- Structural Analysis (RQ2): They analyzed the binaries to understand the structural differences introduced by various languages and compilers. This involved examining metrics like the number of sections, threads, loaded DLLs, functions, and overall size.
- Reverse Engineering Metrics (RQ3): To gauge the difficulty of reverse engineering, they collected metrics such as the number of functions, executed functions, average function size, basic blocks, instructions, cyclomatic complexity, indirect calls/jumps, and control flow graph (CFG) entropy.
- Shellcode Fragmentation Analysis: A custom script was used to analyze how shellcode was fragmented within binaries compiled with different languages, as fragmentation can hinder pattern matching.
- Case Study (Haskell): A detailed reverse engineering case study of a Haskell-compiled shellcode sample was performed to illustrate the practical challenges posed by runtime-heavy languages compared to a C-compiled equivalent.
Datasets
The paper utilized two primary datasets:
- Malware Bazaar: The latest export of the Malware Bazaar database was used to identify trends in the usage of programming languages and compilers by malware authors. This dataset was filtered to include only Windows executables.
- González-Manzano et al. [15]: A dataset focused on APT (Advanced Persistent Threat) samples was used for a more targeted analysis of language and compiler shifts in sophisticated malware.
The researchers also generated their own dataset of malicious binaries for experimental purposes, aiming for heterogeneity in programming languages and compilers.
Key Insights and Ideas
- Language as an Obfuscation Layer: The choice of programming language and compiler is not just about functionality; it's a powerful, inherent obfuscation technique that bypasses traditional signature-based detection.
- Compiler Matters as Much as Language: Even when using a common language like C, switching to a less common compiler can significantly impact detection rates and reverse engineering complexity.
- Runtime Complexity vs. Evasion: Languages with large runtimes (e.g., Java, Python, Haskell) often produce larger, more complex binaries with intricate control flows. While this complexity can lead to higher detection rates due to suspicious patterns, it also makes them harder to analyze, creating a trade-off for attackers.
- Fragmentation Hinders Pattern Matching: The way shellcode is laid out in memory can vary drastically between languages, with some languages fragmenting it extensively, making simple pattern matching ineffective.
- No Single Metric is King: A combination of factors—runtime complexity, fragmentation, control-flow intricacy, entropy, and function-level distributions—collectively influences how AV engines classify binaries.
Key Results
- Reduced Detection Rates: Many samples compiled with less common languages or compilers went undetected by VirusTotal, with some showing an overall detection rate as low as 6% for the first payload.
- Increased Reverse Engineering Effort: Languages with complex runtimes and execution models, like Haskell, resulted in significantly more instructions and intricate control flows compared to simpler languages like C, making reverse engineering orders of magnitude more difficult.
- Structural Diversity: Even for identical payloads, binaries compiled from different languages exhibited radical structural differences (e.g., number of functions ranging from 6 to 81,793), highlighting the impact of language and compiler choices.
- Correlation Between Evasion and Complexity: Samples with low detection rates often showed high levels of shellcode fragmentation and complex control flow, indicating a strong correlation between these structural characteristics and evasiveness.
Limitations and Future Work
Limitations:
- The study focused on simple, non-obfuscated payloads to isolate the effect of language and compiler choice. Real-world malware often employs additional obfuscation techniques.
- The analysis of .NET languages was limited, with only one C# sample including the runtime environment.
- The paper acknowledges that the malware samples represent a "small fragment of the total," implying that a broader scope could yield further insights.
Future Work:
- Developing more robust, language-agnostic detection methods that can handle the diversity introduced by various programming languages and compilers.
- Creating better reverse engineering tools that are specifically designed to cope with the complexities introduced by less common languages and their runtimes.
- Further research into the impact of specific compiler optimizations and configurations on malware detection.
- Investigating the role of Large Language Models (LLMs) in assisting malware authors to generate code in unfamiliar languages, as mentioned in the discussion.
- Expanding the analysis to include more programming languages, compilers, and obfuscation techniques.
Summary updated