NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Evading Malware Analysis Using Reverse Execution

Adhokshaj Mishra, Animesh Roy, Manjesh Kumar Hanawal · DOI

Abstract

Malware is a security threat, and various means are adapted to detect and block them. In this paper, we demonstrate a method where malware can evade malware analysis. The method is based on single-step reverse execution of code using the self-debugging feature. We discuss how self-debugging code works and use that to derive reverse execution for any payload. Further, we demonstrate the feasibility of a detection evading malware through a real implementation that targets Linux x86-64 architecture for a reference implementation. The reference implementation produces one result when run in one direction and a different result when run in the reverse direction.

Introduction

Malware analysts typically employ two primary strategies to dissect malicious software: static analysis and dynamic analysis. Static analysis involves reading disassembled code top-down using tools like IDA Pro, while dynamic analysis involves executing the code in a sandbox or attaching a debugger to monitor its behavior. To counter these methods, malware authors frequently develop obfuscation techniques such as packers, self-modifying code, and self-debugging.

This research addresses the challenge of evading both static and dynamic analysis simultaneously. Standard analysis assumes that code executes in a forward, top-down sequence. By introducing "reverse execution," where a program executes its own instructions backwards, the malicious logic remains hidden from standard top-down static analysis. Furthermore, by utilizing self-debugging to facilitate this reverse execution, the malware can effectively lock out external analysis tools.

Methodology and Architecture

The proposed reference architecture for reverse-executing malware integrates three core techniques: self-debugging, in-memory execution, and a reverse-execution stager.

Architecture of the reverse-executing malware binary and its execution flow.

Self-Debugging

In Linux, the ptrace system call allows one process to observe and control another. Since operating systems typically permit only one debugger to attach to a process at a time, the malware forks itself. The parent process then attaches to the child as a debugger. This mechanism serves a dual purpose: it facilitates the reverse execution logic and prevents external debuggers used by analysts from attaching to the process.

In-Memory Execution

To minimize the forensic footprint and evade Antivirus (AV) scanners that monitor disk activity, the malware utilizes Linux's memfd_create. This system call creates an anonymous file descriptor backed entirely by RAM. The malware can then load and execute its payload directly from memory without writing any artifacts to the hard drive.

Reverse Execution via a Stager

The core innovation lies in the reverse execution stager. The parent process (the debugger) maintains a pre-computed "address map" of the payload's instructions. Using ptrace, it single-steps through the child process. After each instruction, the parent intercepts execution, identifies the address of the preceding instruction in the map, and overwrites the child's instruction pointer (RIP register). This forces the child to execute the payload from bottom to top.

Key Insights

The research highlights several critical concepts in malware evasion:

  • Directional Behavior: Code can be structured to perform benign actions when executed forward but malicious actions when executed in reverse.
  • Static Analysis Blind Spots: Because disassemblers and analysts typically read code top-down, the true intent of a bottom-up payload is obscured.
  • Conditional Maliciousness: The self-debugging mechanism creates a "win-win" scenario for the malware. If an external debugger attaches first, the self-debugging fails, and the malware simply executes its benign forward path. The malicious payload is only triggered if the malware successfully secures debugging rights over itself.

Results

The feasibility of this approach was demonstrated through a proof-of-concept implementation for Linux x86-64. The reference implementation successfully produced divergent results: a benign output when run in the standard forward direction and a simulated malicious output when run in reverse. The source code for this implementation has been released to the security community for further study.

Limitations and Future Work

While the proof-of-concept is successful, it faces certain limitations. Modern Endpoint Detection and Response (EDR) systems may flag the anomalous and frequent use of ptrace single-stepping or memfd_create as suspicious behavior, even if the payload itself remains unreadable.

Future research could explore porting these techniques to other operating systems like Windows or macOS and different architectures such as ARM, utilizing their respective debugging APIs. Additionally, quantitative evaluations against contemporary security suites would provide deeper insights into the practical effectiveness of reverse execution as an evasion tactic.

Summary updated

BibTeX
@inproceedings{mishra2021evading,
  author = {Adhokshaj Mishra and Animesh Roy and Manjesh Kumar Hanawal},
  title = {{Evading Malware Analysis Using Reverse Execution}},
  booktitle = {COMSNETS},
  year = {2021},
  doi = {10.1109/comsnets53615.2022.9668485},
}
Figure