#13299

[Design] Native composed workflows and provider scale bounds (binary_overview, trace_feature, call graph BFS, decompile_all, Hopper/Cutter/Kuna)

Openmorlutoopened 4d ago

Before submitting

  • I searched the open and closed issues and pull requests for a related discussion (#13276, #13277, #13278, #13292).
  • I understand the contribution scope must be reviewed before integration; open questions are welcome here.
  • This discussion does not include credentials, private samples, or sensitive target data.

Decision needed

Should REA establish explicit bounded-execution and summary-count contracts across composed native workflows and long-running native bridges:

  1. Provider-side read_binary_inventory_summary support (or upstream capability integration) for IDA, Hopper, and Kuna so binary_overview stops pulling full procedure and string inventories solely for .length,
  2. Explicit match, reference, depth, node, edge, and deadline budgets (matching trace_native_values and trace_native_ui_action) on trace_feature, get_call_graph, and trace_call_path,
  3. Clear decompile_all resume-with-limit semantics (verified disk state vs journal-indexed skip) and filtered list_procedures pushdown, and
  4. Explicit operation deadlines and paginated/streamed large-reply protocols in Hopper (bridge/hopper_bridge.py / HopperClient.ts) and Cutter (bridge/cutter/rea_bridge.py / CutterBridgeClient.ts), plus removing Kuna's single-string 128 MiB kuna functions --json wall and serial --jobs 1 export bottleneck?

Context and evidence

Source-derived analysis of REA's composed native workflows and provider adapters shows multiple places where large binaries (500k+ functions, 1M+ strings) fail or hang indefinitely due to missing summary/pagination/timeout contracts:

  1. binary_overview (src/application/EnhancedTools.ts:690-732):
    • Attempts read_binary_inventory_summary (currently implemented only by Ghidra).
    • For IDA, Hopper, and Kuna, falls back to Promise.all([list_segments, list_procedures, list_strings]) (lines 705-711) via executeFact, transferring and Zod-validating every procedure and string row solely to read .fact.length (lines 727-728) and discard the arrays.
    • In Hopper, unpaginated single-line list_strings / list_procedures replies can exceed DEFAULT_BRIDGE_MAX_REPLY_BYTES (256 MiB); in IDA, 100-item paging forces thousands of sequential RPCs; in Kuna, kuna functions --json hits the 128 MiB single-string output cap (KunaCommand.ts:61).
  2. trace_feature, get_call_graph, and trace_call_path (src/application/EnhancedLiteralTracing.ts:49-240, src/application/EnhancedTools.ts:525-625, src/application/CallPathTracing.ts:85-136):
    • traceLiteralFeature (EnhancedLiteralTracing.ts:92-118, 138-238) runs sequentially over every string and procedure match (xrefs per match × resolve_containing_procedure per xref source) with no match cap, total-reference cap, or deadline.
    • EnhancedTools.#callGraph (lines 553-623) and traceCallPath (lines 106-133) execute unbounded BFS traversals with no max_depth, max_nodes, max_edges, or deadline.
  3. decompile_all resume + limit (src/application/decompileDirectory/decompileAll.ts:397-438):
    • Always fetches unfiltered list_procedures even when name, namespace, or address_start..address_end filters are specified.
    • On resume with limit, line 437-438 (if (input.limit !== undefined && input.state.attempted >= input.limit) continue;) continues iterating over all remaining procedures and calling existingFile(...) (reading and SHA-256 hashing every already-written output file on disk) even after the attempt budget is exhausted.
  4. Provider timeouts and unpaginated bridge replies:
    • Hopper (src/hopper/HopperProvider.ts, bridge/hopper_bridge.py:690-741, 1190-1205, 1352): list_strings, list_procedures, and list_names emit single-line unpaginated NDJSON replies that can breach the 256 MiB limit; _search_results eagerly runs _string_record FFI decoding for every string on first search; connection.settimeout(None) leaves bridge calls untimed without a caller timeout contract.
    • Cutter (bridge/cutter/rea_bridge.py:172, 819-827, src/cutter/CutterBridgeClient.ts:134): Hardcoded 20s bridge / 25s client timeout permanently poisons the bridge session (self.poisoned = True) on legitimate large commands rather than honoring configurable deadlines.
    • Kuna (src/kuna/): KunaSessionClient buffers kuna functions --json as a single string capped at 128 MiB, falls back to unfiltered kuna strings (pending verification of kuna strings --filter case-folding/regex semantics), and runs serial --jobs 1 whole-binary exports (DEFAULT_KUNA_PROJECT_TIMEOUT_MS).

Expected interaction with targets

  • Read existing files or captured data (local binaries / bridge sessions under existing read-only analysis boundaries).

Boundary details (optional)

  • Bounded traversals (trace_feature, get_call_graph, trace_call_path) must preserve REA's completeness invariant: stopping at a bound or budget must set explicit truncated: true, report the active limit and recovery, and never silently claim a partial graph/reference set is complete.
  • decompile_all resume-with-limit changes must keep counts.skipped vs counts.remaining honest (distinguishing verified disk state from unverified remaining entries).
  • Hopper and Kuna server-side filter/count extensions must match REA's canonical Unicode simple case-folding and symbol identity rules.

Options and tradeoffs

  • Inventory summary pushdown: Implement direct O(count) read_binary_inventory_summary in Hopper and Kuna bridges (and Hex-Rays IDA bridge, plus survey_binary/count support where upstream IDA MCP exposes it).
  • Traversal & search bounds: Align trace_feature, get_call_graph, and trace_call_path with trace_native_values / trace_native_ui_action (max_depth, max_nodes, max_edges, max matches/refs, and whole-operation timeout budgets).
  • Paginated / streamed bridge IPC: Stream kuna functions --json via KunaJsonDocumentReader (eliminating the 128 MiB single-string wall) and add chunked/cursor paging + operation deadlines to Hopper and configurable deadlines to Cutter.

Verification available so far

  • Idea only; I need help defining checks

Success criteria and open questions

  • Which summary/pagination/bound parameters (max_matches, max_references, max_depth, max_nodes, limit) belong in the public CLI/MCP contracts for trace_feature, get_call_graph, and trace_call_path?
  • When decompile_all stops at limit during resume, should unexamined trailing entries be counted as unverified/remaining rather than re-hashing every previously written file on disk?
  • Can Kuna CLI --filter semantics (exact regex/Unicode rules) and non-single-threaded project export be verified and adopted without altering string-matching parity?

References

  • Related issues: #13276, #13277, #13278, #13292
  • src/application/EnhancedTools.ts:525-625, 690-732
  • src/application/EnhancedLiteralTracing.ts:49-240
  • src/application/CallPathTracing.ts:85-136
  • src/application/decompileDirectory/decompileAll.ts:397-438
  • bridge/hopper_bridge.py:690-741, 1190-1205, 1352
  • bridge/cutter/rea_bridge.py:172, 819-827

Activity

0

No activity yet.