Practical Boundaries of Using Large Language Models for Reverse Engineering
This article examines where large language models help in reverse engineering and where they fail. It explains why LLMs often misread complex control flow, presents an abstracted failure case, and defines reliability levels from instruction-level to mechanism-level analysis. It then walks through a practical workflow for analyzing a native dynamic library without an interpreted runtime, covering fact baselines, sliced decompilation, context feeding, and verification. A reusable workflow and compliance notes are included.
1. The Problem: Why “Letting AI Read Assembly” Is Harder Than It Looks
In reverse engineering practice, a common expectation is to paste an entire disassembly listing into a large language model and have it directly state what the code does. Real experience often falls short of that expectation. Explanations of individual instructions are usually accurate, but as soon as the code involves jump tables, indirect calls, or runtime-selected paths, the model may produce answers that contradict each other or drift entirely from the facts.
To understand this, start with how the model works. A large language model predicts the next token based on context. Its “knowledge” comes from statistical patterns in training data, not from dynamically executing a given binary. Assembly and decompiler output have two inherent weaknesses that make high-quality training material hard to build:
- Scarce and noisy corpus: High-quality public analysis text for assembly is far less abundant than source code in high-level languages. The same assembly can look very different across architectures, compilers, and optimization levels.
- Labels are error-prone: Even experienced engineers need context, calling conventions, and section layout to make reliable judgments. Human labeling error rates are not low, so what the model learns is a noisy prior.
The premise for every method that follows is therefore to treat the model as a fallible junior analyst, not an authority that outputs conclusions.
2. An Abstracted Post-Mortem of a Typical Failure
Consider this scenario. An engineer is optimizing the performance of a memory copy function. After disassembling it, they notice a large number of jumps and suspect the path is chosen at runtime. They hand the assembly (from a non-mainstream instruction set) to several AI coding tools and get conflicting explanations. They then ask about one instruction at a time; each explanation is correct, but the overall semantics still cannot be assembled. It is later confirmed that the implementation uses a mechanism that determines the concrete implementation address during load or initialization. The model did not recognize this and instead reasoned literally from the instructions, producing more wrong conclusions.
Three reusable lessons come out of this case:
- Literally correct is not semantically correct: Correct per-instruction explanations do not mean the control flow is understood correctly.
- The model “forces” an answer when metadata is missing: Without the architecture, calling convention, compiler, and optimization level, the model can only fill gaps with generic priors.
- Mechanistic patterns need external knowledge: Runtime implementation selection, symbol resolution, and relocation are engineering conventions. The analyst must supply hypotheses and verify them.
3. A Clear Division of Capability Boundaries
Layering the tasks significantly improves the experience:
| Task level | Typical content | Reliability | Recommendation |
|---|---|---|---|
| Instruction | Semantics of a single instruction, addressing modes, flag effects | High | Can be trusted directly; spot-check only |
| Basic block | Equivalent pseudocode for a jump-free code segment | Medium-high | Manually verify stack and register conventions |
| Function | Parameter sources, return values, side effects | Medium | Must be cross-checked against call sites |
| Control flow | Jump tables, indirect calls, loop invariants | Low | Use only for hypothesis generation; verify with tools |
| Mechanism | Runtime binding, lazy binding, symbol resolution | Low | Human supplies the mechanism hypothesis; model adds explanation |
The conclusion is direct: the model is good at explaining locally, not at closing the global picture. The biggest payoff comes from placing it in hypothesis generation and documentation.
4. Practice: Analyzing a Native Dynamic Library Directly, Without an Interpreted Runtime
Below is a generalized description of a real class of requirements. A statistical analysis package exposes a scripting interface. Its official integration approach depends on an interpreted runtime, loading the native engine library into the interpreter process through an external function interface. Command passing is in-process function calls rather than network communication. The goal is to remove the interpreter dependency and package it as a standalone executable. The analysis path for this kind of problem is broadly applicable.
4.1 Establish the Facts First, Then Involve the Model
The first step is not decompilation but building a factual baseline:
- Confirm how the interface layer locates the installation root and sets internal path variables.
- Confirm which native library is loaded and whether multiple versions exist.
- Confirm the calling convention, symbol export mechanism, and target architecture.
The following pseudocode is illustrative only. It expresses the investigation order and does not point to any specific implementation:
Locate entry script -> extract root directory derivation logic -> record environment variables-> enumerate native library export symbols -> mark candidate call sites -> then do local decompilation
4.2 The Practical Constraints of Full Decompilation
Fully decompiling a large native library often means tens of thousands of functions, memory usage on the order of tens of gigabytes, and a toolchain that crashes easily. The correct engineering approach is slicing on demand:
- First decompile only the export symbols and call graph of candidate functions.
- Generate a subgraph bounded by two hops of “entry function to callee.”
- Decompile functions in the subgraph one by one and write them to disk as text, avoiding loading everything at once.
4.3 Four Points for Feeding Context
- Provide enough metadata: architecture, compiler, optimization level, calling convention, and whether it is position-independent.
- Control granularity: one basic block or one function at a time, with call-site context attached.
- Require structured output: inputs and outputs, register and stack usage, side effects, and explicit uncertainty.
- Force confidence levels: require the model to label each conclusion as “certain” or “speculative,” and speculative items must include a verification method.
Illustrative prompt structure:
Architecture and calling convention: <fill in>Target function: <symbol name>Known call sites: <address and context>Please output: 1) equivalent pseudocode 2) registers and stack space used3) side effects 4) uncertainties and verification suggestions
4.4 Conclusions Must Be Verifiable
Every model conclusion must land on one of three verification methods: static cross-reference checks, dynamic breakpoints to observe actual values, and minimal reproduction experiments. For example, if runtime implementation selection is suspected, set a breakpoint after loading completes to observe the address actually called, rather than relying on textual reasoning.
5. A Reusable Workflow and Risk Controls
Consolidating the above experience yields a closed loop:
- Fact baseline: Confirm architecture, version, symbols, and calling convention first.
- Sliced decompilation: Use the call graph as the boundary and write results to disk in small batches.
- Layered questioning: Automate instruction-level tasks in batches; use control-flow-level output only for hypotheses.
- Cross-validation: Confirm with three layers: static references, dynamic observation, and minimal experiments.
- Knowledge capture: Write confirmed mechanisms into searchable analysis cards for the team.
For risk controls, compliance must be emphasized. Reverse analysis should be limited to software you own, authorized targets, or interoperability purposes, and should avoid crossing licensing and compliance lines. Analysis artifacts and intermediate files should be isolated with proper access management. Where necessary, general cloud capabilities such as object storage, logging services, and monitoring and alerting can support audit trails.
