2dea2c2038 feat(kuna): admit PE/COFF, and forward the engine's spec variables (#15058)
* kuna: admit PE/COFF and forward the engine's spec variables

PE x64 is the class kuna handles and no other provider here does; its .pdata is a
better boundary source than discovery (430,906 discovered against 299,257
.pdata extents on one 120 MB image). Admission is the format check only — kuna
opens at the header base itself.

A source-built kuna also finds its compiled specs through KUNA_SPECS or
SLEIGHHOME, and the child environment carried only HOME/XDG_CACHE_HOME/NO_COLOR,
so a build install failed with 'Could not find .sla' and it read as a target
problem. Both are forwarded when set; a release kuna carries its specs and is
unaffected.

Adds the env test, flips the PE admission assertion, and says both in the
provider doc.

* chore: rerun checks

* fix(kuna): bind selected spec trees into the child and the cache

Forward KUNA_SPECS and SLEIGHHOME from the environment captured for the
provider, not from the ambient process. Hash each selected tree into the
analysis profile and export key so an in-place rebuild cannot reuse an
older result, and give a tree that cannot be hashed its own inspection
fence.

* fix(kuna): revalidate spec trees at launch and admit only x86-64 PE

The session kept the first specification digest, so a later export could
read a rebuilt tree and publish it under the earlier key. Each command
and export now hashes the selected trees again and keys the result with
that read; a tree that cannot be confirmed becomes an unknown identity
with a new reuse fence.

Directory close failures are retained on the caller's resource scope, and
the entry cap stops the directory read instead of buffering every name.
PE admission is x86-64; other PE architectures are refused.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* style(kuna): format the launch-revalidation changes

oxfmt --check rejected KunaProjectCache, KunaSessionClient, KunaSpecIdentity,
and the spec identity test. Apply the repository formatter.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): own spec identity once per launching operation

Compute one specification snapshot inside the session's classified
failure boundary and use that value for the cache key, the close key,
the profile, and the launch. Cached answers from an adopted project do
not walk the tree again. A tree that differs from the committed profile
is refused and the adopted reader is dropped. Directory close retains
one lease, and the session dialect keeps that cleanup on the classified
error.

Delete the extra refreshes in project build and command launch.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): check spec identity when a child spawns

Drop the operation allowlist. Each operation carries one memoized
confirmation, and runKunaCommand runs it under that command's deadline
before spawn. An unidentifiable tree reuses the fence minted for the
resolved profile, so the export key matches the profile BinarySession
commits. Relative spec paths are resolved from REA's working directory
when they are selected. A spec-file close keeps the lease the hook
returns, and installation retention is keyed by the original owner.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): keep spec-scan leases with the spawn owner

A shared export was retaining a failed spec close on the client that
started the build. That client can close while another client still
waits, and its close does not join the scan. The scan now runs in the
cache scope and the lease it returns is the cache's hash lease, so
close and settled can still release it. A client-owned command keeps
the lease in that command's scope.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): isolate each spec scan's signal and deadline

Spawns still share one identity result, but each waits on its own abort,
budget, and cleanup owner. The child timeout is whatever budget remains
after the scan and names the Kuna timeout setting.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(analysis-view): accept either oversized-page parent recovery

Source tests merge this branch with main, whose fixed-allowance recovery
no longer says "caller-supplied bundle".

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(views): drop recovery-prose lock on oversized route refusal

* fix(kuna): bound installation spec reads by the function timeout

identifyKunaExternalSpecs requires the caller's deadline. Inspection uses
REA_KUNA_TIMEOUT_MS, or the version-probe deadline when that timeout cannot
be read, and reports AnalysisTimeoutError.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): own spec scans through close and register spec roots

A cancelled wait keeps the physical spec read on the command or export
scope until its close settles. Setup and doctor copy an explicit
KUNA_SPECS or SLEIGHHOME into the client registration.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): retry a clean spec timeout and re-list walked directories

A spec-read timeout keeps a failed close's lease. A clean installation
timeout is not reused, so the next settings scan again. The walk re-lists
each directory and refuses the digest when the name set changed.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(kuna): keep spec-scan waits bounded and save absolute spec roots

The caller's wait ends at its deadline while the scope still owns the
read. Setup stores KUNA_SPECS and SLEIGHHOME as absolute paths.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* refactor(kuna): verify spec trees inline at each spawn

Replace the shared, detached per-operation spec scan in KunaSessionClient,
and the ownSpecScan plumbing that kept it owned, with an inline check in
runKunaCommand beside the executable-digest check. Each spawn reads the
tree under its own signal, deadline and cleanup owner, so the scan cannot
outlive the request or the shutdown that admitted it.

- Route every Kuna deadline timeout, including the spec-read timeout and
  its cleanup facts, through one kunaDeadlineTimeout owner.
- Move spec-variable selection into KunaConfiguration, its only reader.
- Pass an owner cancellation reason to the scan timer and read the
  function timeout through readRuntimeSetting (architecture guards).
- Cover a spec-file close failure that coincides with the scan timeout.

* fix(kuna): report late spec scans as timeouts and keep empty selections

- Check the deadline after the final directory read and close, so a scan
  that finishes past its budget is a timeout, not an identified tree.
- Convert only a deadline-stopped read to a timeout; an earlier physical
  failure keeps its cause beside the cleanup it left.
- Keep an explicitly empty KUNA_SPECS or SLEIGHHOME empty in setup and
  doctor registrations instead of resolving it to the working directory.

* test(kuna): remove wall-clock timing from spec deadline tests

- Observe the timeout the strings child is granted instead of asserting
  elapsed time; the scan delay must come out of that grant. A control that
  gives the child the full budget fails the test.
- Block the failing spec close on the scan's own deadline signal, with a
  test-owned release, instead of racing a fixed delay against a 20 ms
  deadline.

* fix(kuna): keep launch directory cleanup and report doctor spec timeouts

- A spec directory whose close failed during a launch scan now reports its
  retained cleanup through kunaRetainedResourceCleanupError instead of a
  plain adapter error, so the command reports cleanupIncomplete until its
  scope retries the handle.
- Doctor projects a spec read that exceeds kuna.function_timeout_ms into a
  failed Kuna version check with the timeout's recovery, instead of
  aborting the doctor run.
- Narrow the granted child timeout in the deadline test (CI typecheck).

---------

Co-authored-by: sharif <sharif@localhost>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-29 22:51:59 +00:00

English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Türkçe · Русский · Tiếng Việt · ไทย · Deutsch · Español · Français · Українська · Polski · Português (Brasil) · العربية · فارسی · Bahasa Indonesia · Italiano · Ελληνικά · മലയാളം · Roman Urdu · Română · Български

REA: Reverse Engineer Anything

One MCP for reverse engineering across binaries, applications, and runtime behavior.

See a feature you like. Understand how it works, down to the binary level.

GitHub stars Monthly npm downloads MIT license Join the REA Discord Follow REA on X Supported platforms: macOS, Windows, and Linux skills.sh

Website · Guides · Showcases

Join the REA community on Discord

Quick start · Showcases · How REA works · What you can analyze · Build RL environments · FAQ · Documentation

npx rea-agents setup

Important

Get REA from morluto/rea, rea.tools, or the rea-agents npm package. Follow the installation and release links from these official sources. A similar repository name or copied README does not establish that a download is official.


REA launching its analysis bridge inside Hopper while inspecting a native binary



Discord
Join the Reverse Engineering Community

Discord · Q&A · Show and Tell


See a feature in an app that you want in your own product? Ask your agent to investigate it with REA. It can inspect the app without its source code, explain how the feature works, show the evidence, and build a version for your project.

REA connects your agent to tools for inspecting native binaries, JavaScript and Electron apps, .NET assemblies, and websites. You can also use the same tools from your terminal. Analysis runs locally, and results include the evidence and limitations behind each conclusion.

Setup registers REA with your agent and installs matching workflow instructions. Native analysis can use an existing Hopper, Ghidra, IDA or Kuna installation; setup can optionally install Hopper with approval. Static JavaScript analysis needs no native analysis engine.

Quick start

Get started at rea.tools for step-by-step instructions by operating system, agent, and analysis provider.

Connect your agent (MCP)

With Node.js and npm installed, run this from a trusted directory outside the project you plan to analyze.

npx rea-agents setup

Choose your agent, review and approve the setup plan, then restart your agent. Setup backs up existing configuration and adds REA's MCP connection and investigation skill. See the installation guide for supported clients, plugins, manual registration, and troubleshooting.

Try asking your agent:

Understand how search works in the Notes app, show me the evidence, and build a
similar feature for my project.

Replace Notes with your target app and the feature you want to understand.

Use REA from the terminal (CLI)

Inspect an extracted JavaScript/Electron app directory or ASAR:

npx -y rea-agents@latest analyze-javascript-application /absolute/path/to/app --json

The result includes modules, imports, Electron boundaries and their evidence. Replace the path with your target, such as "D:/apps/example" on Windows.

To install the rea command for regular use:

npm install --global rea-agents
rea --help

For native analysis, configure a provider first. The CLI and Evidence guide covers provider selection, native commands, snapshots, and scripting. For Linux prerequisites, see the installation guide.

Update REA

For a global npm or Bun installation, run the updater and follow its setup instructions.

rea update

If you use npx, refresh your agent setup with:

npx rea-agents@latest setup

Review the setup changes and restart your agent. See update and uninstall instructions for package runner options and troubleshooting.

Showcases

Illustrations of the DX-Ball sound-pan, Notion clipboard-bridge, and TH04 bullet-ring showcases

DX-Ball: reconstruct a sound-pan calculation

Recover a position-to-pan helper from x86 instructions and verify the C reconstruction against 3,205 original-x86 cases and all 63 compiled function bytes.

Read the case study · Reconstruction repository

Notion: trace the Electron clipboard bridge

Follow the renderer’s clipboard API through preload and IPC into the main process to see how Notion handles rich clipboard data.

Read the case study

TH04: recover a DOS bullet-ring calculation

Recover fixed and aimed angle calculations from the PC-98 game’s 16-bit instructions and compare the reconstructed C++ with historical compiler output.

Read the case study · Reconstruction repository

If you've used REA on something interesting, we'd love to see it. Share your case in an issue or a pull request, including the target, your question, how REA helped, and what you found.

How REA works

Your agent uses REA through MCP to inspect a target and trace the relevant code. It can use the evidence REA returns to ask follow-up questions, explain behavior, or build and test an implementation. The CLI uses the same workflows.

REA investigation flow: your agent asks about a local target, REA inspects and traces it using analysis tools, and the agent uses the returned code, references and unknowns to explain, implement and test.

Open the full-size figure.

What you can analyze

REA covers native binaries, JavaScript and Electron apps, websites, .NET assemblies, Android apps, firmware, and recorded runtime and network activity.

Supported targets and requirements

For native decompilation, choose a provider that supports your target format and host OS. See choosing a deep analysis provider.

Build RL environments

Build a local environment from a recorded web session or a Linux desktop app so an agent can practice a task and check its result. Build an RL environment with REA.

FAQ

Which agents can use REA?

Any agent that supports local MCP servers. Setup configures the supported agents; other clients can use manual MCP registration.

Do I need a native analysis engine?

Deep native analysis uses Hopper, Ghidra, IDA or Kuna, depending on the target and operation. Static JavaScript and .NET inspection work without a native analysis engine. Setup can install Hopper after approval; Ghidra, IDA and Kuna use your existing installations. See provider setup for the options and their supported targets.

Do I need to start Hopper first?

REA starts Hopper when an operation needs it. On macOS, a first-run dialog may ask you to choose demo mode or activate your license. Complete that prompt in the same user session before your first CLI/MCP operation or unattended job. Open Hopper manually if needed. See Hopper startup and troubleshooting.

What does installing the skill from skills.sh do?

The skill supplies investigation instructions for your agent. Use npx rea-agents setup to register REA's MCP server and install the matching instructions, then restart your agent. See skill-only installation.

What code does REA return?

Native analysis returns pseudocode and assembly. JavaScript/Electron analysis recovers modules and their relationships. Your agent uses these findings to write and test an implementation; the showcases give worked examples.

Does REA upload my app?

REA analyzes targets locally. Your agent receives the tool results, and its model provider has its own data policy.

What should I do if I hit a bug?

Update first; a recent release may already fix it.

For a CLI installed with npm install --global or bun add --global:

rea update

For agent setup through npx:

npx rea-agents@latest setup

If you're using an agent, complete the setup refresh and restart it. Retry the same task. If the problem persists, open an issue with your REA version, target type, steps to reproduce and error output.

Documentation

Start with the website's worked guides. For exact options, prerequisites and result contracts:

Report vulnerabilities through SECURITY.md.

Community & Support

  • Discord — Ask questions and share what you’re investigating with our passionate community of over 50,000 reverse engineers and builders! Join the REA Discord
  • Twitter / X — Follow @reatools for updates and announcements.
  • Feedback & Ideas — Want a new feature or support for a file format? Open a GitHub issue or join our Discord and let us know.

Star history

🎉 400,000 GitHub stars — thank you!

Thanks to everyone using REA, reporting bugs, requesting features, testing builds, and contributing fixes.

REA contributors REA GitHub star history

Contributing

We'd love your help with REA! Open an issue to report a bug or suggest a feature, or send a pull request to improve the code or docs.

See CONTRIBUTING.md for development setup and checks. See the testing guide for verification lanes.

Disclaimer

See DISCLAIMER.md for responsible-use guidance.

The project's position on illegal or unauthorized use covers all REA versions, distribution channels, and platforms; each copy retains its applicable licenses.

REA is for lawful research, education, interoperability, software preservation, and analysis of software you own or are authorized to examine.

License

MIT

REA-authored code is licensed under MIT. Third-party material retains its own licenses and copyright notices; see Third-party notices for the dependency inventory, preserved license texts, and external-tool terms.

You must legally obtain and be authorized to use commercial tools, including IDA Pro / Hex-Rays decompilers, Hopper, and JEB, under their applicable licenses. REA grants no tool license, key, or activation entitlement. Trials and demos remain subject to vendor terms, including user, feature, automation, and output sharing restrictions. Cracked copies, stolen keys, unauthorized key sharing, and bypassing license restrictions are not authorized. This guidance does not amend MIT or third-party licenses.

Languages
TypeScript 91.5%
JavaScript 4.9%
Python 1.1%
Java 1.1%
HTML 1%
Other 0.1%