[PR #2880] [CLOSED] fix(ida): stop legacy string paging against fake-paginated upstream #5464

Closed
opened 2026-10-31 01:06:51 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2880
Author: @sugeladi2450
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (4)

  • ef9353d fix(ida): stop legacy string paging against fake-paginated upstream
  • b46578c fix(ida): bound large stdio string replies
  • bf6e182 fix(ida): bound large legacy string replies
  • 60bd43c fix(ida): attribute oversized MCP replies

📊 Changes

4 files changed (+141 additions, -18 deletions)

View changed files

📝 src/ida/IdaMcpConnection.ts (+35 -11)
📝 src/ida/IdaOperationRunner.ts (+5 -7)
📝 src/ida/IdaSessionClient.test.ts (+62 -0)
📝 tests/boundary/mcp/idaTransport.test.ts (+39 -0)

📄 Description

Summary

Fixes IDA GUI hangs in legacy attached mode when running rea search <binary> <pattern> --json
or rea list strings against the ida-pro-mcp 1.4.0 server. Fixes #2786.

Problem and expected behavior

Smallest trigger: rea search test.exe hello --json against ida-pro-mcp 1.4.0 with a binary
containing a large number of strings. REA's legacy strings() loops over list_strings with
count: 100 until next_offset is null. Upstream 1.4.0's list_strings is only apparently
paginated: every call re-enumerates the whole database (for item in idautils.Strings()) and
then slices, so the paging loop forces O(N²/100) upstream enumeration work and IDA's GUI hangs
inside the "Generating strings" loop.

Expected behavior: listing and searching strings complete in one upstream round trip with the
same result set as before.

Change and scope

The upstream paginate helper documents count == 0 as "0 means remainder": it returns the
full remainder in one page and sets next_offset to null. Passing count: 0 in the legacy
branch of strings() turns the paging loop into a single call (O(N)) with the same page shape
and no server-side contract change. The existing "pagination did not advance" guard is kept.

Two additional adjustments are included in the same change:

  • The legacy branch appends mapped items with a for...of loop instead of a spread
    (result.push(...page.data.map(...))). With a single full-size page, a spread would exceed
    the JavaScript call argument limit (~65535) and throw RangeError on large binaries.
  • The regression test now asserts concrete values (hello-0/0x3000, hello-249/0x30f9,
    and the literal-search head/tail) in addition to result lengths, so wrong upstream data
    cannot pass the test.

Contribution scope fit: ordinary fix within existing boundaries — "not applicable" for a
maintainer scope decision (no new provider, no target execution/injection/mutation).

Contract and boundary impact

  • Semantic owner and earliest changed stage: legacy attached-mode string inventory read.
  • Contribution scope fit and linked maintainer decision: not applicable (existing boundary).
  • CLI and MCP/tool-catalog contract: none. count: 0 is documented upstream semantics;
    no tool added, removed, or renamed.
  • Provider, bridge, target-format, or platform compatibility: unchanged for native/headless
    modes; legacy mode result set unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata / package / installation impact: none.

Expected effects:

  • Read existing files or captured data. (reads upstream string pages; no new interaction)
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/ida/IdaSessionClient.test.ts — new
    "attached IDA legacy string inventory" case (fake-paginated upstream, 250 strings), asserting
    call counts, count: 0, and concrete address/value pairs at the head and tail of results.
  • Base reproduction or other evidence: temporary repro harness with N=2500 fake-paginated
    upstream, run against the upstream base revision and against this change:
    list_strings calls 25 (all count: 100) → 1 (count: 0); literal search_strings total
    calls 50 → 2. Result length identical (1111) both ways. A second harness with 200,000 strings
    confirmed no RangeError from the append path.
  • User-visible CLI/MCP output: none changed; output shape is identical.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/ida/IdaSessionClient.test.ts -t "single upstream calls" — 1 passed.
  • Repro harness (temporary, N=2500): base 25/50 calls → fixed 1/2 calls, same results.
  • Large-inventory harness (temporary, N=200000): no RangeError, full result returned.
  • npx tsc --noEmit — passes (0 errors) at the verification baseline.
  • npx oxlint src/ida/IdaOperationRunner.ts src/ida/IdaSessionClient.test.ts — 0 errors.
  • npx oxfmt --check on the changed files — passes.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. No call or configuration becomes invalid;
    count: 0 was already valid upstream input.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (IDA legacy path only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; no new target interaction.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved; maintainer scope decision
    covers the final diff (declared not applicable).
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked (Fixes #2786).
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed
    (none needed; no contract text changed).
  • User-visible CLI/MCP changes include representative output
    (no output shape change).
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2880 **Author:** [@sugeladi2450](https://github.com/sugeladi2450) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (4) - [`ef9353d`](https://github.com/morluto/rea/commit/ef9353da00c05fa444b20a91b0e1d9ae1ee54092) fix(ida): stop legacy string paging against fake-paginated upstream - [`b46578c`](https://github.com/morluto/rea/commit/b46578c6d3cd7a20942390fa1a36b48ffd73cfbb) fix(ida): bound large stdio string replies - [`bf6e182`](https://github.com/morluto/rea/commit/bf6e182b1935bc36cbe50355e3e6a912b91aa73e) fix(ida): bound large legacy string replies - [`60bd43c`](https://github.com/morluto/rea/commit/60bd43cfbc283540f6b41d1a6f34492e408b10cc) fix(ida): attribute oversized MCP replies ### 📊 Changes **4 files changed** (+141 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/ida/IdaMcpConnection.ts` (+35 -11) 📝 `src/ida/IdaOperationRunner.ts` (+5 -7) 📝 `src/ida/IdaSessionClient.test.ts` (+62 -0) 📝 `tests/boundary/mcp/idaTransport.test.ts` (+39 -0) </details> ### 📄 Description ## Summary Fixes IDA GUI hangs in legacy attached mode when running `rea search <binary> <pattern> --json` or `rea list strings` against the ida-pro-mcp 1.4.0 server. Fixes #2786. ## Problem and expected behavior Smallest trigger: `rea search test.exe hello --json` against ida-pro-mcp 1.4.0 with a binary containing a large number of strings. REA's legacy `strings()` loops over `list_strings` with `count: 100` until `next_offset` is null. Upstream 1.4.0's `list_strings` is only apparently paginated: every call re-enumerates the whole database (`for item in idautils.Strings()`) and then slices, so the paging loop forces O(N²/100) upstream enumeration work and IDA's GUI hangs inside the "Generating strings" loop. Expected behavior: listing and searching strings complete in one upstream round trip with the same result set as before. ## Change and scope The upstream `paginate` helper documents `count == 0` as "0 means remainder": it returns the full remainder in one page and sets `next_offset` to null. Passing `count: 0` in the legacy branch of `strings()` turns the paging loop into a single call (O(N)) with the same page shape and no server-side contract change. The existing "pagination did not advance" guard is kept. Two additional adjustments are included in the same change: - The legacy branch appends mapped items with a `for...of` loop instead of a spread (`result.push(...page.data.map(...))`). With a single full-size page, a spread would exceed the JavaScript call argument limit (~65535) and throw `RangeError` on large binaries. - The regression test now asserts concrete values (`hello-0`/`0x3000`, `hello-249`/`0x30f9`, and the literal-search head/tail) in addition to result lengths, so wrong upstream data cannot pass the test. Contribution scope fit: ordinary fix within existing boundaries — "not applicable" for a maintainer scope decision (no new provider, no target execution/injection/mutation). ## Contract and boundary impact - Semantic owner and earliest changed stage: legacy attached-mode string inventory read. - Contribution scope fit and linked maintainer decision: not applicable (existing boundary). - CLI and MCP/tool-catalog contract: none. `count: 0` is documented upstream semantics; no tool added, removed, or renamed. - Provider, bridge, target-format, or platform compatibility: unchanged for native/headless modes; legacy mode result set unchanged. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata / package / installation impact: none. Expected effects: - [x] Read existing files or captured data. (reads upstream string pages; no new interaction) - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/ida/IdaSessionClient.test.ts` — new "attached IDA legacy string inventory" case (fake-paginated upstream, 250 strings), asserting call counts, `count: 0`, and concrete address/value pairs at the head and tail of results. - Base reproduction or other evidence: temporary repro harness with N=2500 fake-paginated upstream, run against the upstream base revision and against this change: `list_strings` calls 25 (all `count: 100`) → 1 (`count: 0`); literal `search_strings` total calls 50 → 2. Result length identical (1111) both ways. A second harness with 200,000 strings confirmed no `RangeError` from the append path. - User-visible CLI/MCP output: none changed; output shape is identical. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/ida/IdaSessionClient.test.ts -t "single upstream calls"` — 1 passed. - Repro harness (temporary, N=2500): base 25/50 calls → fixed 1/2 calls, same results. - Large-inventory harness (temporary, N=200000): no `RangeError`, full result returned. - `npx tsc --noEmit` — passes (0 errors) at the verification baseline. - `npx oxlint src/ida/IdaOperationRunner.ts src/ida/IdaSessionClient.test.ts` — 0 errors. - `npx oxfmt --check` on the changed files — passes. ## Compatibility, safety, and release - Breaking changes or migration steps: none. No call or configuration becomes invalid; `count: 0` was already valid upstream input. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (IDA legacy path only). - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; no new target interaction. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved; maintainer scope decision covers the final diff (declared not applicable). - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked (Fixes #2786). - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed (none needed; no contract text changed). - [x] User-visible CLI/MCP changes include representative output (no output shape change). - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:06:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5464
No description provided.