Skip to content

fix(ida): stop legacy string paging against fake-paginated upstream - #2880

Closed
sugeladi2450 wants to merge 4 commits into
morluto:mainfrom
sugeladi2450:main
Closed

sugeladi2450 wants to merge 4 commits into
morluto:mainfrom
sugeladi2450:main

Conversation

@sugeladi2450

@sugeladi2450 sugeladi2450 commented Oct 13, 2026 •

Copy link
Copy Markdown

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 [Bug] ida 1.4.0 mcp string search causes hang #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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:49:39.771354Z 60bd43c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Legacy IDA string reads request the full inventory with count: 0, avoiding repeated upstream scans.

  • Legacy IDA string listings and searches now load in one upstream call.

The earlier spread-limit and transport-test assertion issues are fixed. The existing result-content thread was already conceded; it is not reposted.

No new actionable issue or security issue was established. A replacement PR could not be checked because GitHub access was unavailable. Tests were inspected, not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Legacy string listing or search] --> B["list_strings: count 0"]
  B --> C[Full inventory reply]
  C --> D[Parse and append each string]
  D --> E[Return inventory or filter search matches]
Loading

Reviews (12) · Last reviewed commit: "fix(ida): attribute oversized MCP replie..." · Reviewed by Greptile

Comment thread src/ida/IdaOperationRunner.ts Resolved
Comment thread src/ida/IdaSessionClient.test.ts Resolved
@sugeladi2450
sugeladi2450 force-pushed the main branch 2 times, most recently from ef5fe5b to c5ae1de Compare October 13, 2026 15:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5ae1de525

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (name === "list_strings") {
const offset = Number(args.offset ?? 0);
const count = Number(args.count ?? 100);
const data = count === 0 ? all : all.slice(offset, offset + count);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exercise count-zero against the supported legacy provider

For the large-string legacy-IDA case this patch claims to fix, the fixture makes the expected producer behavior true by construction: count === 0 returns all and forces a null cursor. The validation recorded in this commit contains only this simulated boundary/harness, not the documented verify:ida CLI/MCP lane against ida-pro-mcp 1.4.0, so it cannot establish that the real bridge accepts and serializes the full reply or that the GUI hang is gone. Run that lane, or explicitly mark the provider behavior unverified.

AGENTS.md reference: AGENTS.md:L77-L77

Useful? React with 👍 / 👎.

const s = legacyStringSchema.parse(item);
return { address: s.address, value: s.string };
}),
await this.call("list_strings", { offset, count: 0 }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Measure the unbounded page before claiming the hang is fixed

For large inventories, this changes a series of bounded 100-item MCP responses into one unbounded response, changing transport/serialization peak memory and runtime. The commit compares only call counts and checks that 200,000 in-memory items avoid RangeError, but reports none of elapsed time, CPU time, peak process-family memory, cold/warm runs, token usage, or unmeasured costs; without equivalent before/after measurements, the performance claim could merely shift pressure from IDA enumeration to the bridge or Node process. Record the required metrics on representative completed tasks.

AGENTS.md reference: AGENTS.md:L52-L56

Useful? React with 👍 / 👎.

Comment thread src/ida/IdaOperationRunner.ts Resolved

@Bobtoshi Bobtoshi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked ida-pro-mcp 1.4.0's actual paginate/list_strings source: count zero returns the complete remainder and terminates the cursor, so the single-read correction matches the pinned protocol.

I ran the session-client and native-protocol suites, and added a permanent 200,000-string companion regression in sugeladi2450#1. It verifies one upstream call plus the exact first/last records; it passes with the loop append and fails with a spread append (RangeError). The supplement keeps this work on the existing fix rather than introducing a competing upstream PR.

This validates recorded protocol behavior. Real Windows IDA 9.3 GUI execution was unavailable, so I am not claiming an independent real-GUI hang reproduction or verification.

Comment thread tests/boundary/mcp/idaTransport.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7707a4d39

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ida/IdaMcpConnection.ts Outdated
if (bufferLimit !== null)
throw new AnalysisResourceConstraintError(
"ida_mcp_response",
"memory",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Classify receive-buffer overflow as a transport constraint

When a stdio reply exceeds the new 64 MiB maxBufferSize, this tags the measured receive-buffer cap as resource: "memory". projectAnalysisError therefore serializes a memory constraint, and analysisErrorPresentation.ts tells CLI/MCP callers to inspect worker/host memory, even though additional RAM cannot alter this hard-coded framing limit. Classify it as transport (with boundary-specific recovery if necessary) so the reported limit and remediation remain accurate.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c24e345822

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ida/IdaMcpConnection.ts Outdated
: null;
if (bufferLimit !== null)
throw new AnalysisResourceConstraintError(
"ida_mcp_response",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report the requested operation on buffer overflow

In the attached legacy list_strings/search_strings path, when a reply crosses the 64 MiB cap, IdaSessionClient.#failure preserves this object unchanged through its cause instanceof AnalysisError branch, and projectAnalysisError publishes this constructor argument as details.operation. The caller therefore receives operation: "ida_mcp_response" instead of the analysis operation it invoked; translate the boundary failure to the current requested operation so CLI/MCP error attribution remains meaningful.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40cfb1c11e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ida/IdaMcpConnection.ts Outdated
Comment on lines +160 to +161
if (bufferLimit !== null)
throw new AnalysisResourceConstraintError(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve stderr on oversized replies

When the stdio provider has emitted stderr before a reply exceeds 64 MiB, this early throw bypasses the bounded, redacted stderr-capture path immediately below it. The resulting AnalysisResourceConstraintError therefore has no capturedOutput, so diagnostics preserved for every other transport failure are lost specifically on this new capacity failure; attach the same bounded/redacted tail to the typed error before throwing.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53f2d10705

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

await client
.callTool({ name, arguments: args }, { timeout: config.timeoutMs })
.catch(transportFailure),
.catch((cause: unknown) => transportFailure(cause, name)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the public operation on oversized replies

When an oversized reply occurs for a public operation whose upstream tool has a different name—e.g. search_strings calls list_strings in IdaOperationRunner.run—the fresh evidence in this revision is that this catch now passes only the upstream tool name. IdaSessionClient.#failure preserves this AnalysisResourceConstraintError, so CLI/MCP details.operation and the message say list_strings instead of the requested search_strings; translate the constraint at the session boundary to the current AnalysisOperation while retaining its capture and limits.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

if (bufferLimit !== null)
throw new AnalysisResourceConstraintError(
operation,
"transport",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Override remediation for upstream receive limits

When a legacy reply exceeds 64 MiB, using transport without a custom remediation makes analysisErrorRemediationAction select the generic outbound-delivery advice: discover retained records/export Evidence and assume the connection remains usable. This failure explicitly retained no partial Evidence and occurred while receiving the inventory from IDA, so those steps cannot recover the missing result; provide a boundary-specific remediationAction for this constructor instead.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbb06706d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

throw new AnalysisResourceConstraintError(
operation,
"transport",
`Upstream IDA MCP reply exceeded the ${bufferLimit[1]}-byte transport limit; no partial Evidence was returned.`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid denying partial Evidence from earlier IDA calls

In the legacy attached path, when procedure_pseudo_code or analyze_function has completed lookup or assembly calls and a later decompilation reply exceeds 64 MiB, those completed calls are already in runner.raw; IdaSessionClient.#failure then exposes them through retainPartialObservation. This unconditional reason therefore tells CLI/MCP callers that no partial Evidence was returned while the same projected error contains partial Evidence; limit the statement to the failed reply or derive it after session-level retention.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7133822929

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +159 to +162
const bufferLimit =
cause instanceof Error
? /ReadBuffer exceeded maximum size of (\d+) bytes/u.exec(cause.message)
: null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle buffer overflow on the transport error channel

When a legacy reply actually exceeds 64 MiB, the pinned SDK reports ReadBuffer exceeded... from the stdio stdout/transport error path rather than using that Error as the rejection reason for callTool; the pending request then sees only a timeout or generic connection closure. Consequently this regex is never matched and callers do not receive the intended AnalysisResourceConstraintError or reported byte limit. The new 11 MiB test only verifies that the limit was raised, not the over-limit path, so retain the transport error and exercise a reply above the configured cap.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Share tagged readiness observations, retain partial provider facts, authenticate bridge identity, bound diagnostics, and preserve cancellation and lost-session reasons. Fail closed for unparsed MIPS ABI attributes and macOS saved Hopper databases without a script-capable bridge route.

Reviewed fixes: #2010, #2108, #2513, #2695, #2731, #2771, #2828, #2867, #2868, #2870, #2880, #2919, #2945, #2961, #2981, #2998, #3000, #3002.

Validation: 285 focused source/boundary tests passed. Real Ghidra, IDA, Linux Hopper, and Windows provider runs were not repeated.

BREAKING CHANGE: MIPS targets with unresolved GNU ABI attributes and saved Hopper databases on macOS are refused rather than advertised as supported.
@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in d4bd65c. The code is in src/ida/IdaOperationRunner.ts, and fetches legacy strings and literal searches in single upstream calls covers it. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Superseded by the delivered IDA compatibility changes in d4bd65c53. Main bounds upstream transport replies and fetches legacy string inventories/searches in a single upstream request instead of following fake pagination, with production-boundary regressions. Closing this earlier proposal; #2786 is already resolved.

@morluto morluto closed this Oct 15, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@sugeladi2450, thanks for investigating legacy IDA string handling and transport limits. Main includes the bounded single-call handling for that path.

@morluto morluto added the provider: ida Analysis provider / engine: ida label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working provider: ida Analysis provider / engine: ida

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ida 1.4.0 mcp string search causes hang

4 participants