fafde7b243 fix(javascript): resolve Electron paths held in definite constants (#9540)
* fix(javascript): resolve Electron paths held in definite constants

A preload, utilityProcess.fork module path, serviceName or loadFile path
written inline as path.join(__dirname, "preload.js") resolves, but the same
expression stored in a const first stays dynamic, because staticPathFact
returned undefined for every identifier. The ESM idiom
const __dirname = path.dirname(fileURLToPath(import.meta.url)) left
path.join(__dirname, ...) unresolved for the same reason.

The path intrinsic query now also returns the initializer of a single,
unreassigned, unprojected const whose initializer the shared lexical index
proves has run at the read (the proof constant BrowserWindow options use).
staticPathFact and the filesystem-context check recurse into that
initializer, so a source-directory base survives, and the source-directory
and source-file identity proofs follow const aliases. Each constant is
substituted at most once per evaluated expression, which keeps work and
spelling bounded by the source text.

let and var bindings, reassigned, destructured or shadowed constants, reads
that may run before initialization and URL objects stay unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(javascript): bound constant alias chains in static path facts

Root cause: staticPathFact and isFilesystemPathExpression recurse once
per substituted constant, and the once-per-initializer set only stops a
revisit. A linear chain of shallow declarations (const c1 = c0; const
c2 = c1; ...) admits every link, so a long enough chain exhausts the
call stack (12,000 `c + "a"` links throw RangeError in the domain test
worker). For plain aliases the same chain was quadratic instead:
isFilesystemPathExpression asked the source-directory proof at every
step, and that proof walks the whole remaining chain (4,096 aliases took
about 55 s). That proof reads initializers outside the per-expression
set, so a source-directory alias read twice, path.join(DIR, DIR, "x"),
still resolved. isFilesystemPathExpression also matched the name
__filename before following a constant of that name, so an ES module
const __filename = "service" got filesystem context, unlike the inline
string.

Structural fix, one bound owned where constants are substituted:
- The path query admits constant substitutions
  (admitConstantSubstitution): at most SEMANTIC_EXPRESSION_DEPTH_LIMIT
  per expression, the budget the expression shape resolver already uses
  for alias chains. substitutingConstantsOnce asks it, so a refused read
  is unknown, never a partial or truncated literal. A refusal records
  the expression-depth resource limit, so the examination is limited and
  the unresolved path still counts as an unknown finding.
- The source-directory proof's alias walk (constantTarget) asks the same
  question, and once the proof holds its top-level aliases are spent
  from the per-expression set like any other constant read.
- isFilesystemPathExpression follows a constant to its initializer
  before the name-based identity checks.

The guide documents the bound. Not changed: constants inside
new URL(CONST, import.meta.url) stay unknown, and the inline
path.join(__dirname, __dirname, "x") still resolves as before.

Validation:
- npm run test:local with the PR test file and nine neighbours:
  Test Files 10 passed (10), Tests 763 passed (763).
- With the two source files at 7d7180515 and the new tests, the rows for
  12,000 concatenations (RangeError: Maximum call stack size exceeded),
  4,096 aliases (resolved after about 55 s), 256 aliases to a source file,
  a chain of 256 aliases, both directory-alias rows and the __filename
  row fail; the 255-alias controls pass.
- npm run check:fast passed; oxfmt --check passed on the four files.
- Not run: the acceptance and boundary tests that need test:focused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(javascript): read the constant alias bound from the semantic precision

Main (#9706) removed SEMANTIC_EXPRESSION_DEPTH_LIMIT: the expression-depth
bound is now state.precision.expression_depth (default 256), so a caller
can raise or lower it per analysis. The constant-alias bound added by this
PR read the removed constant, so the tree merged with main did not compile.

Read the bound from index.bindings.precision, like the other semantic
evaluators. The test takes the default from
JAVASCRIPT_SEMANTIC_PRECISION_DEFAULTS and imports
analyzeParsedJavaScriptStaticSource from tests/fixtures, where main moved
it (#10275). Behavior at the default bound is unchanged.

Validation: npm run check:fast passed on the merged tree.
npm run test:local on javascriptStaticPathConstants.test.ts: Tests 34 passed
(34). The same command on 42 static-analysis test files (this one, the
javascriptStaticAnalysis* files and the electronStaticAnalysis app-path and
identity files): Tests 1004 passed (1004).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(javascript): keep file URLs with an unknown base unresolved

staticFileUrlPathFact read only the spelling of its argument's path fact,
so the unknown base that main's #11991 rejects through staticPath was
dropped. `fileURLToPath(path.join("file:", __dirname, "preload.js"))`
spells `file:/preload.js` after the leading source directory, and the
Electron findings reported `/preload.js` instead of an unknown path.

The reader keeps this branch's shared substitution set and now rejects a
fact whose base is unknown before it converts the URL.

Validation: the two new controls (inline and through a constant) fail on
the previous head with `/preload.js` and pass now. vitest on
javascriptStaticPathConstants.test.ts and
javascriptStaticPathResolution.test.ts: 153 passed (153).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(javascript): resolve a constant inside a source-relative URL

`const REL = "./preload.mjs"; fileURLToPath(new URL(REL, import.meta.url))`
stayed unknown while the inline literal resolved, because
staticSourceRelativeUrlPath read its first argument with stringValue only.

The decoder now takes the path query and follows a `const` chain to a
string literal, spending the same substitution bound as other constant
reads. A `let` binding, a joined path and a source-directory path inside
the URL stay unknown, and a stored URL object is still not followed.

Validation: the constant, alias and constant-path rows fail on the
previous head and match the inline result now; the three controls stay
unknown. vitest on javascriptStaticPathConstants.test.ts: 43 passed (43).
tsc --noEmit is clean. The CLI acceptance test needs the built runtime
and runs in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(javascript): share source path substitution budget

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 23:05:30 +08: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

REA: Reverse Engineer Anything logo

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
X
Follow REA on X

@reatools · Releases · Showcases


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.6%
JavaScript 4.9%
Python 1.1%
Java 1%
HTML 1%
Other 0.1%