Translingual Obfuscation

Pei Wang, Shuai Wang, Jiang Ming, Yufei Jiang, Dinghao Wu

TL;DR

This paper introduces "translingual obfuscation," a novel software protection technique that makes programs harder to reverse engineer by translating parts of them into a language with a fundamentally different programming paradigm, like C to Prolog. Experiments with their tool, BABEL, show this approach effectively increases complexity, offers good stealth, and has a modest performance cost compared to commercial obfuscators.

What Problem Does This Paper Address?

Software obfuscation aims to protect intellectual property by making it difficult for attackers to understand and reverse engineer a program's logic. While existing methods like source-code obfuscation and binary obfuscation (e.g., virtualization-based) have been developed, they have limitations. Virtualization-based obfuscation, a current state-of-the-art, has been shown to have vulnerabilities that can lead to deobfuscation. The authors propose a new direction: leveraging the inherent complexity and unique features of different programming languages to create a more robust obfuscation layer. They specifically explore using Prolog, a logic programming language, to obfuscate C programs, arguing that the semantic gap between C's imperative model and Prolog's logic-based model can significantly hinder reverse engineering efforts.

Methods

The core of the paper is the concept of translingual obfuscation, which involves translating a program from its source language (C in this case) to a target language with a different paradigm (Prolog). The authors developed a tool called BABEL to implement this.

Key aspects of their method include:

  • Selective Translation: BABEL translates specific C functions into Prolog predicates, rather than attempting a full program translation. This allows for a hybrid C/Prolog executable.
  • Leveraging Prolog's Features:
    • Unification: Prolog's pattern-matching mechanism for unifying terms creates complex data structures and access patterns that are difficult to recover from binary representations, differing significantly from C's memory model.
  • Backtracking: Prolog's search-and-backtrack execution model fundamentally alters control flow, making it more convoluted and indirect than typical C control flow.
  • C Memory Model Simulation: To maintain semantic equivalence, BABEL preserves the C memory model. It achieves this by embedding a Prolog runtime within the C environment and using custom Prolog predicates implemented in C to simulate pointer operations (read/write). This "flush-reload" mechanism ensures consistency between the C and Prolog memory views.
  • Control Flow Regularization: Before translation, C code undergoes preprocessing to handle control flow constructs like loops and "cuts" (e.g., early returns) by transforming them into forms compatible with Prolog's evaluation model (e.g., tail-recursive functions, replicating basic blocks).
  • Hybrid Compilation: The final output is a combined C and Prolog executable, where C code acts as a wrapper to initiate Prolog queries for obfuscated functions.

Datasets

The authors evaluated BABEL on six real-world open-source C programs:

  • CPU-bound applications: bzip2 (data compressor), mcf (integer computation), regexp (state machine), svm_light (floating-point computation).
  • IO-bound servers: oftpd (FTP server), mongoose (HTTP server).

These programs were chosen to represent a diverse set of applications. The evaluation also used the SPECint2006 benchmarks as a baseline for "normal" program instruction distributions to assess stealth.

Key Insights and Ideas

  • Exploiting Paradigm Differences: The most significant insight is that the inherent differences in programming paradigms (imperative vs. logic) and execution models (sequential vs. search-and-backtrack) between languages like C and Prolog can be "misused" as a powerful obfuscation technique. This is a novel approach compared to traditional methods that focus on manipulating code within a single paradigm.
  • "Misusing" Language Features: The paper highlights how features designed for programming convenience (like Prolog's unification and backtracking) become significant hurdles for reverse engineering when applied in this context.
  • Hybrid Approach is Key: The success of BABEL relies on a hybrid C/Prolog execution environment. This allows for the preservation of the C memory model while still benefiting from Prolog's obfuscating features, striking a balance between complexity and semantic correctness.
  • Translingual Obfuscation as a Layer: The authors position translingual obfuscation as a complementary layer to existing techniques, applicable before or after other methods without interference.
  • Stealth Through Normalcy: Unlike some obfuscation methods that introduce abnormal binary characteristics (like unusual byte entropy), translingual obfuscation aims for stealth by maintaining normal statistical properties, making detection harder.

Key Results

  • Potency: BABEL significantly increased complexity metrics (call graph edges, CFG edges, basic blocks, cyclomatic number, knot count) for obfuscated programs, with geometric means showing substantial increases compared to original binaries.
  • Resilience:
    • Semantics-based diffing (CoP): BABEL-obfuscated functions showed very low similarity scores (below 20% for the third quartile) when compared to their original versions, indicating strong resilience.
  • Syntax-based diffing (BinDiff): BABEL achieved a matching rate of only 24.64% across all tested functions, suggesting it effectively hinders this type of analysis.
  • Cost: The performance overhead introduced by BABEL was generally modest, often comparable to or better than Code Virtualizer, especially at lower obfuscation levels. For example, at 30% obfuscation, BABEL's slowdown was often lower than Code Virtualizer's.
  • Stealth: Instruction distribution analysis showed that BABEL-obfuscated programs had instruction distributions that fell within the normal range of SPECint2006 benchmarks, indicating good stealth. In contrast, Code Virtualizer showed more deviant distributions.
  • Comparison with Code Virtualizer: BABEL generally outperformed Code Virtualizer in terms of potency and stealth. While Code Virtualizer showed higher resilience to CoP and BinDiff, the authors note this is partly because these diffing tools are not designed to handle virtualized code.

Limitations and Future Work

  • Limitations:
    • Integer Overflow/Underflow: The translation of C integer arithmetic to Prolog does not perfectly emulate C's behavior regarding overflows/underflows, which could cause issues for programs that rely on these specific behaviors.
  • Multithreading Support: The current implementation of BABEL does not support C multithreading due to limitations in the underlying GNU Prolog implementation.
  • Randomness: The current design does not explicitly incorporate randomness, which could be a valuable addition for further enhancing security.
  • Future Work:
    • Generalizing Translingual Obfuscation: The authors believe the framework can be extended to other source and target languages, and that control flow regularization methods are broadly applicable.
  • Improving Multithreading Support: Investing engineering effort to make GNU Prolog thread-safe or using a more mature Prolog implementation could enable multithreading support.
  • Incorporating Randomness: Exploring techniques to introduce randomness, such as mutating compilation configurations, could further enhance security.
  • Defeating Translingual Obfuscation: While challenging, the authors acknowledge that defeating translingual obfuscation is not impossible and suggest that mixing multiple languages could further increase the difficulty for attackers.

Summary updated

BibTeX
@inproceedings{wang2016translingual,
  author = {Pei Wang and Shuai Wang and Jiang Ming and Yufei Jiang and Dinghao Wu},
  title = {{Translingual Obfuscation}},
  booktitle = {EuroS\&P},
  year = {2016},
  doi = {10.1109/eurosp.2016.21},
}
Figure