#13301
[Design] Shared-memory RegexMatcher, Frida RPC deadlines and filtering, faceted Pwntools/Pwndbg, and Android/SQLite pagination
Before submitting
- I searched the open and closed issues and pull requests for a related discussion (#13283, #13284).
- 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 redesign four cross-cutting resource/contract bottlenecks that hit hard limits on large inputs:
- Streaming / zero-copy
SharedArrayBufferRegexMatcher(src/process/RegexMatcher.ts) so matching 1M+ strings (IDA/Hopper/Kuna) does not clone the fullstring[]inventory viaworkerDatainto a 128 MiB worker heap and fail withERR_WORKER_OUT_OF_MEMORY, - Per-RPC timeouts, abort teardown, and process filtering in Frida (
src/frida/FridaInstrumentationManager.ts,src/contracts/fridaToolContracts.ts) so hungenumerateDevices/enumerateProcesses/addRemoteDevice/attach/spawn/script.load()calls cannot stall indefinitely holding#sessionQueueslocks, - Faceted/paginated
inspect_binary_layoutand boundedinspect_recorded_crashin Pwntools/Pwndbg (bridge/pwntools/layout_impl.py,recorded_crash_impl.py,bridge/pwndbg/core_context.py) so large ELFs do not dump 100k+ symbols/relocations + Unicorn PLT emulation unconditionally, and - Pagination (
offset/limit) and cursor-based reads for Android JADX (search_android_classes,trace_android_references, scopedinspect_android_jni_bindings) and SQLite keyset paging + session reuse?
Context and evidence
- Regex Worker OOM (
src/process/RegexMatcher.ts:635-645):- Every regex search spawns a cold Worker with default
maxOldGenerationSizeMb: 128and passes the entirevalues: readonly string[]inventory via structured-clonedworkerData. At 1M+ strings (typical on Windows Unreal Engine or large macOS/Linux binaries), structured-cloning into a 128 MiB V8 old-gen heap fails withERR_WORKER_OUT_OF_MEMORYbefore testing the regex, and callers cannot push downoffset/limit.
- Every regex search spawns a cold Worker with default
- Frida untimed RPCs & lock contention (
src/frida/FridaInstrumentationManager.ts:190, 256, 341, 347, 356):- Calls such as
manager.enumerateDevices(),device.enumerateProcesses(),device.getProcessByPid(),device.spawn(),device.attach(),createScript(), andscript.load()await Frida promises without timeouts or abort races, andlist_frida_processeslacksquery/offset/limitfilters. A stalled attach or script load blocks#sessionQueues, preventing close/unload cleanup.
- Calls such as
- Pwntools / Pwndbg unbounded dumps & Unicorn PLT emulation (
bridge/pwntools/layout_impl.py:240-332):inspect_binary_layoutunconditionally emits everySHT_SYMTAB/SHT_DYNSYMsymbol (with base64 names), everySHT_REL/SHT_RELA/SHT_RELRrelocation, and unconditionally evaluatesimage.got/image.plt(triggering Unicorn emulation across PLT stubs), exceedingoutput_bytes/RLIMIT_ASon large ELFs. Similarly,inspect_recorded_crashembeds raw base64 note descriptor blobs unconditionally andbridge/pwndbg/core_context.pyreturns unpagedvmmapentries.
- SQLite
OFFSETO(N²) paging (src/sqlite/SqliteDatabaseInspection.ts:1002-1044) & Android JADX unpaged class/ref dumps:readRowsin SQLite runsNOT INDEXED ... LIMIT ? OFFSET ?, causingO(offset)scans on every page alongside per-page up-to-256 MiB snapshot copying (SqliteDatabaseSnapshot.ts).search_android_classesandtrace_android_referenceslackoffset/limitpushdown (fetching all pages /limit: 2_147_483_647), andinspect_android_jni_bindingsmaterializes all declarations/candidates even when filtered to a single class/method.
Expected interaction with targets
- Read existing files or captured data (static inspection of binaries/APKs/SQLite/core dumps; note Frida attaches/spawns target processes under existing Frida tool scope).
Boundary details (optional)
RegexMatchermust keep exact worker isolation (crash/timeout/OOM containment) and deterministic index ordering (indices), while cleanly aborting in-flight matches on timeout orAbortSignal.- Any Frida timeout/cancellation wrapper must clean up or detach half-opened remote/device/session handles explicitly without leaking orphan locks in
#sessionQueues. - Any faceted/paged contracts in Pwntools/Android/SQLite must report explicit completeness/truncation (
status: "partial",truncated: true, next cursor/offset).
Options and tradeoffs
RegexMatcher: Reuse a warm worker (respawned on timeout/OOM/error) paired with chunked message streaming or a singleSharedArrayBufferUTF-8 string arena +Uint32Arrayoffset table, plusoffset/limitearly-stop support.- Frida: Add configurable operation deadline +
AbortSignalracing around device/spawn/attach/load RPCs with explicit session detach recovery, plusquery/offset/limitonlist_frida_processes. - Pwntools / Android / SQLite: Add opt-in/paged facets (
symbols,relocations,include_plt_emulation) oninspect_binary_layout, addoffset/limitonsearch_android_classes&trace_android_references, and add keyset pagination (WHERE rowid > ?) + short-lived verified snapshot reuse across SQLite pages.
Verification available so far
- Idea only; I need help defining checks
Success criteria and open questions
- Should
inspect_binary_layoutomit unboundedsymbols/relocationsand Unicorn PLT emulation by default behind explicit facets/limits, or keep full defaults with pagination parameters? - For
RegexMatcher, is chunked IPC streaming or aSharedArrayBufferstring arena preferred under Node'sworker_threadsresource limits? - What default RPC timeout best fits interactive
attach/spawn/enumerateProcessesinFridaInstrumentationManager?
References
Activity
0No activity yet.