Generating Functionally Equivalent Programs Having Non-isomorphic Control-Flow Graphs

Rémi Géraud, Mirko Koscina, Paul Lenczner, David Naccache, David Saulpic

Introduction

In software security, particularly within the context of white-box attacks, adversaries possess full access to a program's binary and its execution environment. To counter this, developers employ obfuscation techniques to hinder reverse engineering. While traditional methods often focus on "Straight-Line Code" (SLC) obfuscation—scrambling instructions within basic blocks—the high-level structure of the program, represented by its Control-Flow Graph (CFG), frequently remains exposed. This paper presents a novel transcompilation framework designed to produce functionally equivalent programs whose CFGs are radically different and non-isomorphic to the original, effectively masking the program's logic from static analysis tools.

The Problem: CFG as a Blueprint for Reverse Engineering

The Control-Flow Graph is a fundamental representation used by both compilers and reverse engineers. It maps the paths that execution can take through a program, revealing loops, conditional branches, and high-level logic. Even if individual instructions are obfuscated, the structural "skeleton" provided by the CFG can allow an analyst to identify critical algorithms or security checks. Existing CFG obfuscation techniques, such as "trampolines" (using exception handlers for jumps), often introduce recognizable patterns or signatures that automated de-obfuscators can easily detect and strip away.

A typical control-flow graph showing standard assembly instructions and jumps.

Proposed Methodology: Transcompilation to Random Graphs

The authors propose a "Transcompilation" process that transforms a program $P$ into an obfuscated version $P'$ by embedding its logic into a much larger, randomly generated target graph $G'$. This process involves four key stages:

1. Relabeling and Mapping

The first step involves generating a large, complex target graph $G'$. The original nodes (basic blocks) of the program $P$ are then mapped to a subset of nodes within $G'$. This mapping, denoted as $\pi$, ensures that the logical flow of the original program is preserved but hidden within the noise of the larger graph.

Mapping a program's original CFG to a complex target graph $G'$ via the transformation $\pi$.

2. Breaking Edges and Path Expansion

Direct jumps between original blocks are replaced by multi-node paths through $G'$. A single logical transition in the original code might now require traversing several intermediate "dummy" nodes, significantly increasing the structural complexity of the program.

3. Active and Passive Nodes

The resulting graph contains two types of nodes:

  • Active Nodes: These contain the original program logic and instructions.
  • Passive Nodes: These are the "dummy" nodes added during path expansion. To a static analyzer, these nodes appear functional, but they perform "passivation"—executing "trash" instructions that have no effect on the program's actual state.

4. Routing and the "Trash" Stack

To manage execution flow, every node is wrapped in a routing layer that checks a global routing variable. Active nodes update this variable to point to the next logical destination, while passive nodes simply pass it along. To further obscure the path, the authors use "onion routing," where the next destination is XORed with values stored in intermediary nodes.

A significant challenge in creating realistic passive nodes is handling stack operations. The authors introduce a "trash" stack: passive nodes can perform PUSH and POP operations on a dummy memory address, allowing them to contain realistic-looking code without corrupting the actual program stack.

Key Insights: Semantic vs. Structural Difference

The core innovation lies in making a node's behavior dependent on a runtime variable that is undecidable via static analysis, invoking Rice's Theorem. Because a static analyzer cannot determine the value of the routing variable, it cannot distinguish between an active node and a passive one. By embedding the program into a graph that resembles random noise rather than a structured "hub-and-spoke" pattern (common in control-flow flattening), the authors avoid creating obvious obfuscation signatures.

Security Analysis and Results

The primary achievement of this method is the formal generation of non-isomorphic CFGs, ensuring that $CFG(P)$ and $CFG(P')$ are mathematically distinct.

From a security standpoint, the scheme is robust against static analysis due to the undecidability of the routing logic. Against dynamic analysis—where an attacker observes the program during execution—the authors estimate a "work factor" of $O(|V|^3)$ operations to reconstruct the original CFG. While not providing absolute security, this represents a substantial increase in the effort required for manual or automated reverse engineering.

Limitations and Future Work

The primary trade-off for this increased security is performance overhead. Each logical jump now involves multiple nodes and routing checks, which likely results in a significant execution slowdown. Future research will focus on quantifying this overhead and exploring the potential for recursive obfuscation—applying the transformation multiple times—to further escalate the complexity for attackers.

Summary updated

BibTeX
@inproceedings{geraud2017generating,
  author = {Rémi Géraud and Mirko Koscina and Paul Lenczner and David Naccache and David Saulpic},
  title = {{Generating Functionally Equivalent Programs Having Non-isomorphic Control-Flow Graphs}},
  booktitle = {NordSec},
  year = {2017},
  doi = {10.1007/978-3-319-70290-2\_16},
}
Figure