Skip to content

Agentic Reverse Engineering Architecture (REA) with MCP

5 min readBug Hunting for Beginners

Reverse engineering native binaries, shared libraries (.so), or compiled client applications (Electron ASAR, iOS Mach-O) used to require years of assembly practice.

The Agentic Reverse Engineering Architecture (REA) pairs local coding agents (Claude Code, Cursor, Codex, Gemini CLI) with disassemblers (Ghidra, Hopper, IDA Pro) over the Model Context Protocol (MCP). You can trace native cryptographic signers, token routines, and IPC boundaries with machine help, as long as you keep a strict verification ledger so model guesses never turn into false reports.


1. REA architecture and supported ecosystem

Section titled “1. REA architecture and supported ecosystem”

The morluto/rea project (MIT licensed, TypeScript; over 470,000 GitHub stars and rea-agents v6.11.0 as of November 2026; docs at rea.tools) connects local coding agents to static and dynamic inspection backends. The installed MCP server exposes roughly 206 tools (older guides citing 126 or 170 tools are outdated).

flowchart TD
  Agent["Local Coding Agent<br/>(Claude Code, Cursor, Codex, Gemini CLI)"] <-->|Model Context Protocol| MCP["REA MCP Server / GhidraMCP"]
  MCP <--> Disassembler["Disassembler / Decompiler<br/>(Ghidra 12.1+, Hopper, JADX)"]
  MCP <--> Dynamic["Runtime Instrumentation<br/>(Frida, ADB, lldb)"]
  Disassembler <--> Binary["Target Binaries / APKs / Mach-O / ASAR"]

Run the setup helper in a clean workspace:

Terminal window
npx rea-agents setup
  • Runtime requirements: Node.js 22 (>=22.23.4), 24 (>=24.22.1), or 26.12.1+.
  • OS support: Official support covers macOS 12+, Ubuntu 24.04+, Fedora 41+, and 64-bit Arch Linux. Windows x64 support is experimental and Ghidra-only.
  • Disassembler licensing note: Ghidra is free and open source under Apache-2.0 (ignore older AI summaries claiming Ghidra requires a commercial license). Commercial licenses apply to Hopper and IDA Pro.
  • Performance reality check: Independent testing (Hoang Yell’s REA benchmark) measured Ghidra cold starts above 300 seconds (330 s), a 60-second MCP call timeout, and 2 GB to 6 GB of RAM usage. Open and analyze large binaries in Ghidra first before pointing an agent at them.
  • Standalone MCP bridges (independent of REA): REA ships its own internal Ghidra bridge. If you prefer standalone bridges, pick one maintained stack instead of mixing unrelated plugins:

2. The Reconstruction Obligation Ledger and evidence tiers

Section titled “2. The Reconstruction Obligation Ledger and evidence tiers”

To block hallucinated claims, REA uses a Reconstruction Obligation Ledger. Every tool response returns four structured fields: Evidence, Recovered Graph, Limitations, and Unknowns. When decompiled code contradicts a captured HAR request, the ledger flags a Contradiction Diagnostic.

Tag every conclusion during agentic reverse engineering with one of four tiers:

Tier Definition Allowed use
Tier 1: Confirmed observation Directly observed in decompiled code, runtime trace, or network capture, and independently reviewed by you. Cited as primary proof in triage reports.
Tier 2: Directly supported conclusion Follows logically from confirmed observations with no plausible alternative explanation. Stated with supporting Tier 1 observations attached.
Tier 3: Unverified hypothesis Plausible explanation that lacks direct disassembly evidence or depends on unobserved runtime behavior. Kept in internal notes; never reported as a finding.
Tier 4: Missing information Code, memory state, or server-side checks the agent could not inspect. Disclosed explicitly; never filled with speculation.

3. Four-layer evidence collection workflow

Section titled “3. Four-layer evidence collection workflow”

In bug bounty, the primary goal of reverse engineering is protocol comprehension: recovering request signing secrets, custom headers, or hidden authorization checks without writing C or C++ from scratch.

flowchart TD
  L1["Layer 1: Static Triage & IPC Mapping<br/>(Manifests, ASAR, JNI exports, symbols)"] --> L2["Layer 2: JNI & Native Boundary Analysis<br/>(Decompile target .so in Ghidra via MCP)"]
  L2 --> L3["Layer 3: Runtime Validation<br/>(Frida hook native offset to log live buffers)"]
  L3 --> L4["Layer 4: Reference Model Implementation<br/>(Clean-room Python script replicating logic)"]
  1. Layer 1: Static triage and UI/IPC mapping. Identify the entry points that build signatures or enforce client checks. In Android APKs, locate native method declarations (for example public native String signRequest(...)) and their .so library under lib/arm64-v8a/.
  2. Layer 2: JNI boundary and native analysis. Load the .so into Ghidra. Find the JNI entry point via static exports (Java_com_target_app_Native_signRequest) or dynamic registration in JNI_OnLoad via RegisterNatives. Trace input transformations, XOR masks, and cryptographic constants.
  3. Layer 3: Runtime validation and comparison. Hook the target method and native offsets in Frida on a test device. Log input buffers and return values, then compare live output against static decompilation to catch endianness, padding, or custom Base64 alphabet mistakes.
  4. Layer 4: Reference modeling. Write a clean Python or TypeScript reference script only after static and runtime evidence agree byte-for-byte. Annotate each routine with the library name, virtual offset, and verification date.

4. Token-budget discipline and workspace isolation

Section titled “4. Token-budget discipline and workspace isolation”

Large binaries hold megabytes of assembly that will burn through an agent’s context window and your API budget. Follow four stages:

  1. Stage 1: Zero-token CLI triage first. Run strings, nm, readelf, ipsw, and ripgrep to pinpoint candidate functions before calling an LLM.
  2. Stage 2: Call-graph skeleton. Query symbol tables and exports to map the call path before requesting decompiler output.
  3. Stage 3: Targeted single-function extraction. Decompile one function or call path at a time (procedure_pseudo_code), never the whole binary.
  4. Stage 4: Persistent notes. Write verified offsets and constants into a local notes.md file and reset context between milestones.

Multi-server MCP configuration (.vscode/mcp.json)

Section titled “Multi-server MCP configuration (.vscode/mcp.json)”

Configure your agent to connect to both REA and LaurieWired/GhidraMCP:

{
"mcpServers": {
"rea": {
"command": "npx",
"args": ["-y", "rea-agents@latest", "mcp"]
},
"ghidra": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/LaurieWired/GhidraMCP",
"ghidra-mcp",
"--ghidra-server",
"http://127.0.0.1:8080/"
]
}
}
}

Below is a reference Python model reconstructed from a native Android library (libsigner.so), replicating a custom HMAC-SHA256 request header:

# Clean-Room Python Reconstruction of a Recovered Native JNI HMAC-SHA256 Signer
import hmac
import hashlib
import base64
def reconstruct_native_signature(
http_method: str,
url_path: str,
timestamp_ms: str,
raw_body: bytes
) -> str:
"""
Reconstructed from libsigner.so :: sub_1049a0 (offset 0x001049a0)
Observed XOR-deobfuscated key from .rodata @ 0x00118020
Verified with live Frida trace on 2026-11-10
"""
obfuscated_key = bytes.fromhex("3a7f125b496e2c11085f337a6d44192e")
xor_mask = 0x5A
signing_secret = bytes(b ^ xor_mask for b in obfuscated_key)
# Canonical string construction verified via Ghidra decompilation
canonical_prefix = f"{http_method.upper()}\n{url_path}\n{timestamp_ms}\n".encode("utf-8")
body_sha256 = hashlib.sha256(raw_body).hexdigest().lower().encode("utf-8")
message = canonical_prefix + body_sha256
digest = hmac.new(signing_secret, message, hashlib.sha256).digest()
return base64.urlsafe_b64encode(digest).decode("utf-8").rstrip("=")
  • Store target binaries in read-only directories: chmod -R a-w ~/bounty-workspace/readonly-targets/
  • Direct agent output into an isolated folder: ~/bounty-workspace/agent-output/
  • Never launch coding agents in home directories containing ~/.ssh, ~/.aws, or browser profiles.
  • Review every agent-generated script line by line before running it.

5. Concrete agent prompts for verified MCP workflows

Section titled “5. Concrete agent prompts for verified MCP workflows”

Use these structured templates inside Claude Code, Cursor, or Codex connected to REA and Ghidra:

Prompt A: Authentication flow and token lifecycle

Section titled “Prompt A: Authentication flow and token lifecycle”
Task: Trace the end-to-end authentication, token storage, and token refresh lifecycle in ./workspace/readonly/base.apk using the REA android and enhanced tool families.
Constraints:
1. Do not execute any dynamic tools or modify files in the target directory.
2. Rely only on static disassembly, decompiler output, and manifest analysis.
3. For every claim, cite the source file, class name, method name, and line numbers.
Deliverable: Produce an Evidence Ledger in ./workspace/output/auth_lifecycle.md separating Tier 1 (Confirmed Observations), Tier 2 (Directly Supported Conclusions), and Tier 4 (Missing Information).

Prompt B: Android IPC, intent, and exported component analysis

Section titled “Prompt B: Android IPC, intent, and exported component analysis”
Task: Audit all external input boundaries and Inter-Process Communication (IPC) handlers in ./workspace/readonly/base.apk using REA manifest and JADX analysis tools.
Constraints:
1. Enumerate every Activity, Service, BroadcastReceiver, and ContentProvider with android:exported="true" or an intent-filter lacking signature permission protection.
2. For each exported component, trace getIntent(), getData(), and getExtras() to downstream sinks (WebView.loadUrl, startActivity, ContentResolver, or internal API requests).
Deliverable: Return a Markdown table in ./workspace/output/ipc_attack_surface.md with columns: Component Name, Exported Status, Intent Filter / URI Scheme, Validation Check, and Sink Code Snippet.

Prompt C: Native library and JNI boundary analysis

Section titled “Prompt C: Native library and JNI boundary analysis”
Task: Analyze the JNI boundary and security-sensitive routines in ./workspace/readonly/libnative-auth.so using GhidraMCP and REA tools.
Constraints:
1. Enumerate all exports beginning with Java_ and inspect JNI_OnLoad for RegisterNatives function pointers.
2. Decompile the native routines responsible for HMAC signing, key derivation, or token generation.
3. Track data flow from JNI jstring / jbyteArray arguments into cryptographic APIs.
4. Record exact virtual offsets, cross-references (xrefs), and .rodata hex bytes. List stripped or indirect calls as Unverified Unknowns.
Deliverable: Save a structured analysis to ./workspace/output/jni_analysis.md with Ghidra pseudo-code excerpts and annotated offsets.

Prompt D: Protocol reconstruction and reference implementation

Section titled “Prompt D: Protocol reconstruction and reference implementation”
Task: Reconstruct the request-signing algorithm used for the X-Client-Sig header by correlating libnative-auth.so (offset 0x001049a0) against the captured HTTP request in ./workspace/readonly/sample_request.har.
Constraints:
1. Write a standalone Python 3.12 script in ./workspace/output/reconstructed_signer.py using only stdlib modules (hashlib, hmac, base64, json).
2. Verify the output matches the captured X-Client-Sig header byte-for-byte. If it diverges, output a Contradiction Diagnostic naming the exact step or byte offset that disagrees.

Prompt E: Evidence documentation and triage ledger

Section titled “Prompt E: Evidence documentation and triage ledger”
Task: Compile a formal Reverse Engineering Evidence Ledger in ./workspace/output/evidence_ledger.md for this session.
Constraints:
1. Structure the document into four strict sections:
Section 1: Confirmed Observations (Tier 1) - File paths, binary SHA-256, offsets, and verified outputs.
Section 2: Directly Supported Conclusions (Tier 2) - Complete call-graph paths.
Section 3: Unverified Hypotheses (Tier 3) - Claims requiring live Frida or proxy validation.
Section 4: Missing Information (Tier 4) - Obfuscated or server-validated components.
2. Never present decompiler-generated variable names as original developer symbols unless backed by debug symbols or string literals.

Next step: apply this workflow to mobile apps in Section 25.

Connections3 backlinks · 1 outgoingFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

Bug Hunting for BeginnersFor authorized testing only. Read the ethics note before you put a domain in scope.