Evasion of Static Analysis via Dynamic Code Execution

18 concepts16 papers1 proposal

Static program analysis operates on a fundamental assumption: the compiled binary or source code contains all the information necessary to understand a program's behavior. By parsing instructions, mapping control flow graphs, and identifying API calls, static security tools attempt to judge whether an application is safe before it ever runs.

However, modern runtime environments treat the boundary between code and data as fluid. By leveraging features like dynamic code loading, reflection, and runtime decryption, an application can fundamentally alter its structure during execution. This creates a visibility gap—a structural mismatch between the dormant code inspected by a static analyzer and the actual logic executed on the device.

The Mechanics of the Visibility Gap

To understand why static analysis fails against dynamic execution, we must look at how an analyzer builds its internal representation of a program. Typically, an analyzer constructs a Function Call Graph (FCG), where nodes represent functions and edges represent invocations.

Dynamic execution techniques systematically erase or misdirect these edges:

Static Inspection Phase (What the analyzer sees):
[ Main App ] ---> [ Safe Function A ]
             ---> [ Unresolved Reflection Call ] (Edge Broken!)

Runtime Execution Phase (What actually happens):
[ Main App ] ---> [ Decrypts Payload ] ---> [ Dynamic Class Loader ] ---> [ Malicious API Call ]
  1. Deferred Resolution via Reflection: In languages like Java or Go, reflection allows a program to look up class and method names using standard strings at runtime. As noted by Haoyu Wang 0001 et al., this completely blinds offline scanners trying to identify over-privileged applications. If a program invokes a sensitive API by passing a dynamically constructed or obfuscated string to a reflection API, the static analyzer cannot resolve the target edge. The connection disappears from the static FCG.
  2. Dynamic Class Loading and Unpacking: Instead of embedding malicious logic directly within the application bytecode, developers can store the payload as an encrypted asset or host it on a remote server. At runtime, the application decrypts or downloads the code into memory and invokes it using a dynamic class loader. Shifu Hou et al. and Jingfeng Xue et al. emphasize that this creates an absolute bottleneck for static disassemblers; the malicious execution logic simply does not exist in the file during the pre-execution scanning phase.

This limitation extends beyond mobile ecosystems. For instance, Xiaohong Li et al. observe that static analysis of Windows Portable Executable (PE) files frequently fails when malware delays or obfuscates its true intentions via dynamic API loading. Similarly, in web security, Feijiang Han et al. point out that static analysis of WebShell scripts is easily defeated by advanced obfuscation techniques that hide functional code paths.

The Asymmetry of Adversarial Manipulation

The weakness of static analysis is vividly illustrated by how it handles adversarial perturbations. Machine learning models trained on static features (such as FCGs or byte sequences) can be easily fooled by structural modifications.

For example, Heng Li et al. developed an attack that injects non-functional "dead code" blocks into an application's FCG. To a static classifier, these injected nodes alter the graph's topological signature enough to misclassify malware as benign.

Yet, this attack highlights the exact boundary of the visibility gap:

  • Why it fools static analysis: The static analyzer treats every visible node and edge in the binary with equal weight, regardless of whether it will actually be executed.
  • Why it fails against dynamic monitoring: As Heng Li et al. and Xiang Ling et al. demonstrate, a dynamic monitoring tool tracking actual runtime interactions immediately exposes the deception. Because the injected adversarial code is never executed, the runtime execution path remains identical to the original malware. The discrepancy between the static graph and the runtime trace instantly flags the manipulation.

Downstream Failures in Security Frameworks

When static analysis cannot accurately map a program's control flow, the security frameworks built on top of those analyses collapse.

  • Privilege Separation: Frameworks designed to restrict third-party libraries from abusing host permissions rely on knowing which library calls which API. Jaebaek Seo et al. show that when libraries use dynamic class loading and reflection, static permission enforcement becomes entirely ineffective because the boundaries between trusted and untrusted code cannot be drawn before execution.
  • Library and Component Detection: Automated tools designed to inventory third-party libraries or identify known vulnerabilities fail when components are invoked via reflection. As Xian Zhan et al. demonstrate, package flattening and dynamic invocation allow code to completely evade offline detection mechanisms.
  • Indirect Function Calls: Even at the compiler level, securing code against untrusted functions is difficult. Qi Zhang et al. note that static analysis struggles to secure indirect function calls (such as those made through function pointers) because the exact target of the call is determined dynamically at runtime, preventing the automated insertion of static protection boundaries.

Bridging the Gap

To counter the inherent limitations of static inspection, modern security research focuses on two primary directions: shifting toward dynamic behavioral tracking, and developing obfuscation-resilient static abstractions.

Dynamic and Behavioral Tracing

The most direct solution to the visibility gap is to analyze code while it runs. By monitoring runtime function call traces, security systems can capture payloads after they have been decrypted in memory and observe reflection calls after they have been resolved. Feijiang Han et al. advocate for incorporating these runtime traces to overcome the blind spots of static script analysis, ensuring that the detector evaluates actual execution behavior rather than dormant syntax.

High-Level Structural Abstractions

When runtime monitoring is too computationally expensive, researchers design static analysis techniques that look past superficial code structures to capture deeper semantic relationships.

Instead of relying on exact API signatures or rigid call graphs, systems like HinDroid (Shifu Hou et al.) model applications as Heterogeneous Information Networks (HINs). By analyzing the meta-paths between apps, APIs, and their execution contexts, they capture the underlying intent of the program.

Similarly, the authors of IFDroid (Yueming Wu et al.) utilize supervised contrastive learning to map program call graphs into a visual embedding space. By training neural networks to recognize core behavioral similarities rather than literal code paths, they can accurately classify malware families even when the underlying code is heavily fragmented by packers, reflection, or runtime loading.

Key Foundational Work

Make Evasion Harder: An Intelligent Android Malware Detection System (2018) — contributed 2 concept elements to this direction.
FLEXDROID: Enforcing In-App Privilege Separation in Android (2016) — contributed 1 concept elements to this direction.
Beyond Google Play: A Large-Scale Comparative Study of Chinese Android App Markets (2018) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_static_analysis_evasion_dynamic_code_loa_960ae3f8,
  title = {static analysis evasion (dynamic code loading)},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/static-analysis-evasion-dynamic-code-loading/rdr_960ae3f8134a45f6965b00d8e6fe74fb},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-22},
}

This exact version (version 1, frozen text):

@misc{lacuna_static_analysis_evasion_dynamic_code_loa_960ae3f8_v1,
  title = {static analysis evasion (dynamic code loading)},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/static-analysis-evasion-dynamic-code-loading/rdr_960ae3f8134a45f6965b00d8e6fe74fb/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-22},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake