Skip to content

feat(go): recover bounded Go string literals from (ptr, len) headers - #9206

Merged
morluto merged 6 commits into
morluto:mainfrom
saariuslystoned:feat/go-rodata-string-headers
Nov 8, 2026
Merged

morluto merged 6 commits into
morluto:mainfrom
saariuslystoned:feat/go-rodata-string-headers

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Go compilers pack static string literals contiguously in read-only data sections (.rodata in ELF, __TEXT,__rodata / __TEXT,__const in Mach-O, .rdata in PE) without NUL terminators, causing generic C-string scanners (search_strings) to concatenate adjacent literals into unusable multi-kilobyte runs (for example ListResourceProvidersgenaihttps://example.invalid/v1).

This PR adds opt-in, bounded static (ptr, len) reflect.StringHeader literal recovery to inspect_go_binary (MCP) and inspect-go-binary (CLI) via include_string_literals / --include-string-literals and max_string_literals / --max-string-literals, along with retained go string_literals view projection and filtering.

Problem and expected behavior

When triaging stripped or unstripped Go binaries (ELF, PE, thin Mach-O, and architecture-selected universal Mach-O slices), callers need individual static Go string literals at their exact byte boundaries rather than NUL-delimited runs across packed .rodata blobs.

Expected behavior:

  • Default inspect_go_binary / inspect-go-binary calls ({ path }) remain unchanged in schema output and evidence_id.
  • Passing include_string_literals: true (--include-string-literals, optional max_string_literals / --max-string-literals in 1..10000, default 2000) scans non-executable initialized data and read-only sections in normalized ascending file-offset order (merging overlapping same-phase spans so each physical header is visited at most once) for word-aligned 2-word (ptr, len) pairs (uint32 on 32-bit targets, uint64 on 64-bit targets, honoring container endianness) targeting file-backed read-only spans.
  • Each candidate slice must satisfy 1 <= len <= 4096, stay strictly within a single read-only mapped section/span without crossing section boundaries or zero-fill tails, and decode as printable UTF-8 text (\t, \n, \r, joiners U+200C ZWNJ / U+200D ZWJ, and printable Unicode scalar values; rejecting NUL/control \p{Cc}, other format \p{Cf}, surrogate \p{Cs}, private-use \p{Co}, and unassigned/noncharacter \p{Cn} code points).
  • Identical (offset, bytes) target slices are deduplicated with reference_count and earliest first_header_offset, sorted deterministically by (offset, bytes), and bounded by max_string_literals, 512 KiB aggregate UTF-8 bytes, 64 MiB header scan budget, 100,000 accepted candidates, and a 4,096-entry bounded negative slice cache, setting truncated: true rather than failing when capped.
  • string_literals carries evidence_kind: "inferred" and explicit limitations noting that static (ptr, len) recovery excludes compiler-inlined stack/immediate strings and does not establish runtime reachability.

Change and scope

Follow the contribution scope.

  • Native container section flags (src/native/metadata/): Exposes parsed ELF sh_flags (bigint) and Mach-O section flags (number) on ImageSection alongside existing PE characteristics so GoStringLiterals classifies executable vs read-only vs writable data sections directly from container metadata (with sectionless and unreadable-.shstrtab ELF PT_LOAD fallbacks).
  • Go domain & adapter (src/domain/go/goBinary.ts, src/go/GoStringLiterals.ts, src/go/GoBinaryImage.ts, src/go/GoBinaryProvider.ts): Adds opt-in input controls (include_string_literals, max_string_literals requiring include_string_literals: true), goStringLiteralsSchema (including universal Mach-O selected_slice range invariants for both location and first_header_offset), normalized non-overlapping file-ordered header-span traversal, bounded word-aligned (ptr, len) recovery on both build_info !== null and build_info === null Go/native images, universal slice file-offset rebasing, and epistemic/truncation/chained-fixup limitations.
  • Retained analysis view (src/domain/analysisView/goBinaryView.ts): Extends go summary views with source_coverage.string_literals ("not-requested" | "complete" | "truncated") and summary.string_literals, and adds collection: "string_literals" supporting values, contains, indices, fields, offset, and limit (refusing uncollected queries when include_string_literals was not requested on the parent call).
  • CLI, MCP contract, docs, specs, and real-Go verifier (src/cli/goCommands.ts, src/contracts/go/goToolContracts.ts, docs/guides/native/go-binaries.md, docs/specs/native/go-string-literals/, .agents/skills/reverse-engineer-anything/, scripts/verify-go-binary.mjs): Wires --include-string-literals and --max-string-literals (cliDecimalField), updates owning documentation, feature specification/plan/tasks, and skill references, and extends verify:go:binary (artifactMcpCall) to verify advertised MCP output schemas and contiguous non-NUL-terminated string literal recovery across real compiler-produced ELF, PE, and Mach-O targets.
  • Intentionally excluded: Disassembling code sections to reconstruct instruction-immediate/stack strings, decoding dyld chained-fixup pointer rebases, or recovering Go symbol/type tables (gopclntab / typelink).
  • Maintainer scope decision: Not applicable — extends existing target-free static file inspection within inspect_go_binary without target execution, process attachment, instrumentation, or network access.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/native/metadata/ElfImage.ts and src/native/metadata/MachoImage.ts retain section flags on ImageSection; src/go/GoStringLiterals.ts produces bounded inferred GoStringLiterals inside readGoBinaryImage (src/go/GoBinaryImage.ts), consumed by GoBinaryProvider, goBinaryView, CLI inspect-go-binary, and MCP inspect_go_binary.
  • Contribution scope fit and linked maintainer decision: Not applicable (bounded static read-only inspection inside existing inspect_go_binary boundary).
  • CLI and MCP/tool-catalog contract: Additive optional include_string_literals?: boolean and max_string_literals?: number (1..10000, valid only when include_string_literals: true) on inspect_go_binary / inspect-go-binary (--include-string-literals, --max-string-literals); additive collection: "string_literals" on inspect_analysis_view (kind: "go").
  • Provider, bridge, target-format, or platform compatibility: Built-in Node.js static reader across ELF (32/64-bit, little/big-endian, section-header and sectionless PT_LOAD), PE (PE32 / PE32+), and Mach-O (32/64-bit thin and universal slice-selected); warns explicitly when Mach-O LC_DYLD_CHAINED_FIXUPS / LC_DYLD_CHAINED_FIXUPS_FILESET is present.
  • Evidence, artifact, provenance, or reconstruction contract: Top-level Evidence.confidence remains "observed" for container and runtime/debug build-info spans while normalized_result.string_literals.evidence_kind explicitly marks (ptr, len) string candidates as "inferred", preserving exact file location ({ offset, bytes }) and minimal first_header_offset provenance plus limitations and view unknowns.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Explicit local path only; read-only file access; periodic checkActive cancellation checks during header scanning.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): Authored skill instructions updated in .agents/skills/reverse-engineer-anything/SKILL.md and .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md; npm run metadata:check, npm run mcp-catalog:check, and npm run docs:check pass with no committed build outputs.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • 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/go/GoStringLiterals.test.ts and tests/fixtures/go/rodataStringImage.ts: Synthetic ELF (32/64, little/big-endian, sectionless, corrupted .shstrtab, reversed section-table order + overlapping writable PT_LOAD), PE (PE32 / PE32+), and Mach-O (32/64-bit, LC_DYLD_CHAINED_FIXUPS) binaries with contiguous non-NUL-terminated .rodata / .rdata / __rodata strings ("ListResourceProviders", "genai", "https://example.invalid/v1"), verifying exact slice recovery, U+200C (ZWNJ) and U+200D (ZWJ) preservation, deduplicated single-visit reference_count and minimal first_header_offset, rejection of cross-section ptr + len, BSS/unbacked tails, executable .text targets, NUL/control/other format (\p{Cf}: U+200B, U+202E, U+FEFF, U+00AD)/non-UTF-8 bytes, unaligned pairs, bounded negative-cache behavior across thousands of distinct NUL slices, count and 512 KiB aggregate byte caps (truncated: true), and cancellation.
    • src/domain/analysisView/goBinaryView.test.ts and tests/boundary/mcp/goBinaryViews.test.ts: Domain and MCP boundary coverage for source_coverage.string_literals, summary.string_literals, collection: "string_literals" filtering/paging (values, contains, indices, fields), truncation unknowns, and refusal when string_literals was not requested on the parent Evidence.
    • src/application/go/GoBinaryService.test.ts, tests/boundary/go/goBinaryProvider.test.ts, tests/boundary/cli/cliIntegerArguments.test.ts, tests/acceptance/goBinaryCli.test.ts: Service option forwarding, universal Mach-O slice file-offset adjustment and schema invariants, CLI --max-string-literals integer/coupling validation, and end-to-end CLI --include-string-literals output.
    • scripts/verify-go-binary.mjs: Real Go compiler conformance across 15 stripped/unstripped/PIE/sectionless binaries (linux/amd64, linux/386, linux/arm64, linux/ppc64, linux/mips, windows/amd64, windows/386, darwin/amd64, darwin/arm64), verifying CLI/MCP parity and exact file-slice recovery of "ListResourceProviders", "genai", and "https://example.invalid/v1".
  • Base reproduction or other evidence: Executed unit, boundary, acceptance, and real Go 1.24 compiler checks. Without (ptr, len) header recovery, contiguous Go .rodata literals lack NUL separators and coalesce into a single run under C-string scanning.
  • User-visible CLI/MCP output (if applicable):
    {
      "string_literals": {
        "evidence_kind": "inferred",
        "discovered_count": 3,
        "aggregate_bytes": 52,
        "max_items": 2000,
        "truncated": false,
        "items": [
          {
            "value": "ListResourceProviders",
            "location": { "offset": 4096, "bytes": 21 },
            "first_header_offset": 8192,
            "reference_count": 2
          },
          {
            "value": "genai",
            "location": { "offset": 4117, "bytes": 5 },
            "first_header_offset": 8208,
            "reference_count": 1
          },
          {
            "value": "https://example.invalid/v1",
            "location": { "offset": 4122, "bytes": 26 },
            "first_header_offset": 8224,
            "reference_count": 1
          }
        ]
      }
    }
  • Remaining proof gaps: Static (ptr, len) header scanning intentionally does not decode Mach-O LC_DYLD_CHAINED_FIXUPS encoded pointer slots or compiler-inlined stack/instruction-immediate strings; both limitations are surfaced explicitly in Evidence.limitations.

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/go/GoStringLiterals.test.ts src/go/GoBinaryImage.mapping.test.ts src/go/GoMachoImage.alignment.test.ts src/domain/analysisView/goBinaryView.test.ts src/domain/absoluteAnalysisInputPaths.test.ts src/application/go/GoBinaryService.test.ts tests/boundary/go/goBinaryProvider.test.ts tests/boundary/rust/rustBinaryImage.test.ts tests/boundary/mcp/goBinaryViews.test.ts tests/boundary/mcp/goBinaryMcp.test.ts tests/boundary/mcp/lateAbortApplicationEvidenceMcp.test.ts tests/boundary/cli/cliIntegerArguments.test.ts tests/acceptance/goBinaryCli.test.ts — passed (13 passed, 272 passed)
  • npm run check:fast — passed (typecheck and lint / module boundaries passed with 0 errors)
  • npx oxfmt . && npx oxfmt --check . — passed (All matched files use the correct format across 7121 files)
  • npm run verify:architecture-guards && npm run verify:test-discovery && npm run scan:todos && npm run jscpd && npm run knip && npm run knip:production && npm run lint:typed && npm run metadata:check — passed (2520 source files guard-clean, 3158 test files discovered once, 0 tech-debt markers, Knip 0 issues, typed lint 0 errors, metadata check clean)
  • npm run mcp-catalog:check && npm run docs:check — passed (mcp-catalog:check:built, docs:check:built, licenses:check, and tests/conformance/readmeConsistency.test.ts 9 passed)
  • REA_VERIFY_GO_COMMAND=/path/to/go1.24.0/bin/go npm run verify:go:binary — passed (status: "passed", go1.24.0 darwin/arm64, 15 cross-compiled ELF/PE/Mach-O binaries, 30/30 public CLI + artifactMcpCall cases verified for both default build_info and --include-string-literals / include_string_literals: true)
  • Trial merge with main (08637b0c2) + multi-Node matrix (v22.23.4, v24.22.2, v26.13.0): clean merge (0 conflicts), npm run check:fast passed, and all 7 changed test files (221/221 tests, including the 25,000-section Mach-O case in 111-136 ms) passed across Node v22.23.4, v24.22.2, and v26.13.0.
  • Real darwin/arm64 Mach-O Go 1.24.0 binaries (CGO_ENABLED=0 unstripped, -ldflags="-s -w" stripped, and CGO_ENABLED=1 -ldflags="-linkmode=external"): verified identical default evidence_id vs main (08637b0c2) on all 3 binaries, 1,139 recovered literals (25,086 bytes, preserving U+200C/U+200D and rejecting U+202E) on both unstripped and -s -w stripped LC_DYLD_INFO_ONLY Mach-O builds, CLI/MCP --detail summary parity (full and --max-string-literals 50), and 0 false positives with explicit LC_DYLD_CHAINED_FIXUPS limitation reporting on external Apple ld builds.

Compatibility, safety, and release

  • Breaking changes or migration steps: None. Default inspect_go_binary / inspect-go-binary calls omit string_literals and preserve existing GoBinary payloads and evidence_id digests.
  • Real Hopper/Ghidra, browser, or OS coverage: Verified on macOS (darwin/arm64) across Node v22.23.4, v24.22.2, and v26.13.0 with real go1.24.0 cross-compilation (linux/{amd64,386,arm64,ppc64,mips}, windows/{amd64,386}, darwin/{amd64,arm64}) via npm run verify:go:binary plus unstripped, -s -w stripped, and -linkmode=external Mach-O arm64 CLI/MCP probes. Hopper/Ghidra/browser providers are not touched.
  • Package or release metadata impact: Minor feature addition on existing inspect_go_binary / inspect-go-binary and inspect_analysis_view (kind: "go"). No new runtime dependencies or package file-list changes.
  • Security, privacy, process, or containment review: Read-only bounded buffer inspection with strict per-string (4096 bytes), item count (max_string_literals <= 10000, default 2000), aggregate UTF-8 output (512 KiB), accepted candidate (100,000), negative slice cache (4,096), and section-scan (64 MiB) budgets plus periodic cancellation checks; no target execution or external process spawning.

Author readiness

Human owner: @saariuslystoned

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

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

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds opt-in recovery of bounded Go string literals from static (ptr, len) headers across ELF, PE, and Mach-O files.

  • Go inspection can recover packed static string literals.
  • Retained Go views can filter and page recovered string literals.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI or MCP request] --> B[Read selected image]
  B --> C[Parse native mappings and section flags]
  C --> D{String literals requested?}
  D -->|No| E[Existing build information]
  D -->|Yes| F[Bounded static header scan]
  F --> G[Inferred strings with file ranges and limits]
  E --> H[Complete Evidence]
  G --> H
  H --> I[Summary or retained string pages]
Loading

Reviews (8) · Last reviewed commit: "test(go): cover Mach-O region-index canc..." · Reviewed by Greptile

Comment thread src/go/GoStringLiterals.ts Resolved
Comment thread src/go/GoStringLiterals.ts Resolved
Comment thread src/go/GoStringLiterals.ts Resolved
@saariuslystoned
saariuslystoned marked this pull request as ready for review November 7, 2026 01:03
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T01:03:28.356020Z
We couldn’t complete this review. Comment @codex review to try again.
578114c Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CassieFox23 CassieFox23 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: This is a code read. I ran nothing from the PR, and CI has not run on this head yet. Default calls stay the same and the scan has firm limits. I have one small point about which characters the text filter drops.

Edit (7 Nov): I ran the tests for this PR in a VM, at head 21636ae, which adds the author's ZWJ and ZWNJ change. Results here.

I read the PR head 578114c against its merge base 48f5f30. Main is now 99db80a, and none of main's new commits touch these files.

Nit

  • The filter also drops joiners. DISALLOWED_GO_STRING_CODE_POINT rejects all of \p{Cf} (GoStringLiterals.ts lines 28 and 29). That keeps bidi controls like U+202E and the BOM out, which is good. But U+200C and U+200D are Cf too. Emoji sequences use U+200D, and Persian or Hindi text often uses U+200C. Go strings with those would be dropped. Allowing those two and still rejecting the rest of Cf would keep that text.

Looks good

  • Default calls don't change. Both new inputs are exactOptional with no default (goBinary.ts lines 83 to 93). The service puts the parsed input straight into Evidence parameters (GoBinaryService.ts line 76). So an option you leave out stays out. The CLI only forwards each option when it is set (goCommands.ts lines 67 and 73), and --max-string-literals already uses cliDecimalField. The report's string_literals is exactOptional too (goBinary.ts line 142).
  • The scan is bounded. It has a 64 MiB header scan budget, a 4,096-byte cap per string and a 512 KiB cap on total output (goBinary.ts lines 23 to 25). It tracks at most 100,000 candidates (GoStringLiterals.ts line 19) and checks the cancel signal every 65,536 steps (line 97).
  • No overflow. Pointer and length are BigInt until the length passes the 4,096 check (lines 103 to 115). So 64-bit addresses above 2^53 can't lose precision, and a slice can't run past the end of its section.
  • Chained fixups are named. A Mach-O with LC_DYLD_CHAINED_FIXUPS gets a limitation saying the scan can miss headers there.

Not run

  • No build, no typecheck, no tests. Each point comes from reading the code.
  • I did not run it on a real Go binary, so I can't say how many literals it finds or how often it misses.
  • I did not check how PE sections whose virtual size is larger than their raw size are handled.

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

CassieFox23 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I tested head 21636ae, which adds the author's ZWJ and ZWNJ change after my code read. All 7 changed test files pass on Node 22, 24 and 26, and the change keeps both joiners and still drops U+202E. On a real Go binary the new flags work, and a call without them matches REA 6.8.0 apart from one field that main added since.

Edit (7 Nov): I ran this PR at head 95c5da6 in a VM, and the results are here.

This is the run results only. My code read above was of the older head 578114c. I ran it all in a Fedora 44 VM: 210 tests in the 7 changed test files, and one real Go binary. That binary is fzf 0.74.5 (MIT), Fedora's package build. REA only read fzf. I never ran it.

The joiner fix works

I wrote a scratch test (not PR code) with the PR's own fixture builder. It feeds four strings through includeStringLiterals. The author's new test in GoStringLiterals.test.ts already covers the same kinds, so this only repeats it with my strings.

String Result
plain ASCII kept
emoji ZWJ sequence, U+1F469 U+200D U+1F4BB kept
Persian text with ZWNJ, U+200C kept
text with U+202E (right-to-left override) dropped

Real Go binary

fzf is an ELF amd64 file of 5,062,184 bytes. Each run exited 0.

Flags Time Literals
none 1.58 s no string_literals in the result
--include-string-literals 1.78 s 957 found, 957 returned, truncated: false, max_items: 2000
--include-string-literals --max-string-literals 50 1.64 s 957 found, 50 returned, truncated: true, max_items: 50
  • Coverage is stated. The result is marked evidence_kind: "inferred". A new limitation says the strings come from (ptr, len) pairs. It also says strings that are inlined or built on the stack are missed. The resource-guard line now lists the 64 MiB scan, the 512 KiB total and 4,096 bytes per string.
  • Quality on this file is modest. Only 3 of the 957 look specific to fzf: __FZF_INTERNAL_TMUX_LABEL_PANE, __FZF_INTERNAL_ZELLIJ_LABEL_PANE and a border label name. None start with --, so no option names came back. Most are Go runtime and library text, like multiple Read calls return no data or error, cannot marshal DNS message and bus error. 45 are one or two characters long. I did not check why the option names are missing.
  • Default calls match 6.8.0. With no new flags, the Evidence id, parameters and every result field are the same as REA 6.8.0 on the same file. One top-level field, caller_input_path, is in this tree and not in 6.8.0. The PR's diff has no line about it. Main's Go command already passes it at the merge base. It came in with 419a211 (fix(cli): preserve caller paths in format inspections #7855), after the 6.8.0 release. So main moving on explains it.

Still not run

  • --detail summary with the new flags, and the MCP route by hand. The PR's own MCP test passed.
  • PE and Mach-O real Go binaries. Only the ELF fzf, and the PR's fixtures for the others.
  • PE sections whose virtual size is larger than their raw size.
  • The repo's own CI for this head. It waits for maintainer approval.
  • Memory and CPU time. I timed single runs only.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB), Linux 7.2.11, on a Nobara 44 host
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads (host)
  • RAM: 32 GB (host)
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 21636ae / 48f5f30
  • Other: REA 6.8.0 release build for the comparison; fzf 0.74.5 (MIT), Fedora's package build, sha256 b3fc1d67bd84b71ea81d935f0ec683c3274ff47bb6c3dadcb327bb925ba5a0da
Commands

All in the VM, exit 0 unless noted. Times are wall clock from the VM.

  • npm ci --offline: 19 s. npm run prepare: 0.3 s. npm run test:prepare: 19 s.
  • npm run test:focused -- src/application/go/GoBinaryService.test.ts src/domain/analysisView/goBinaryView.test.ts src/go/GoStringLiterals.test.ts tests/acceptance/goBinaryCli.test.ts tests/boundary/cli/cliIntegerArguments.test.ts tests/boundary/go/goBinaryProvider.test.ts tests/boundary/mcp/goBinaryViews.test.ts
    • Node 24.22.1: 7 files, 210 tests passed, 53 s.
    • Node 22.23.4: 7 files, 210 tests passed, 58 s.
    • Node 26.12.1: 7 files, 210 tests passed, 48 s. My first Node 26 try failed in under a second because I started it while the Node 22 run held REA's artifacts lock. I reran it alone.
  • No test file touched calls doctor.
  • node scripts/rea.mjs inspect-go-binary ~/samples/fzf --format json, then the same with --include-string-literals, then with --include-string-literals --max-string-literals 50.
  • ~/.local/opt/rea-agents-6.8.0/bin/rea inspect-go-binary ~/samples/fzf --format json for the comparison. The evidence ids match. I then diffed the two JSON files with jq -S, leaving out the id and the environment.
  • Scratch test: node_modules/.bin/tsx zwj-scratch.ts (Node 24), exit 0.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

…ng-headers

# Conflicts:
#	.agents/skills/reverse-engineer-anything/SKILL.md
Comment thread src/go/GoStringLiterals.ts Resolved
Comment thread docs/guides/native/go-binaries.md Resolved
Comment thread scripts/verify-go-binary.mjs Resolved
@CassieFox23

CassieFox23 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran head 95c5da6 in a VM. All 7 changed test files pass on Node 22, 24 and 26 (211 tests), and fzf gives the same numbers as my earlier run. In scratch runs, a data section that spans two touching readable regions is now read. A read-only section that is not fully readable is now skipped.

Edit (8 Nov): I ran the new head, a06b979, in a VM, and the results are here.

This is the run results only. My review above covers the older heads: 578114c (code read) and 21636ae (tests). Since then, 0eacab3 merges main. Then 95c5da6 adds three things. It adds the Mach-O region index and a schema check for the MCP tool. It also adds a test with 25,000 sections. On this head only Greptile Review and Validate author declaration ran in CI. No test workflow ran.

Tests

Node Files Tests
22.23.4 7 passed 211 passed
24.22.1 7 passed 211 passed
26.12.1 7 passed 211 passed

That is 211 tests, one more than the 210 in my last run, because GoStringLiterals.test.ts went from 15 to 16 tests (the 25,000-section test).

The 500 ms limit

The new test fails if the 25,000-section build takes more than 500 ms. Vitest does not print that time. So I rebuilt the same container in a scratch script and timed three calls in a fresh process on each Node. This is a stand-in, not the test's own number.

Node Run 1 Run 2 Run 3
22.23.4 88.3 ms 60.2 ms 51.9 ms
24.22.1 80.7 ms 50.2 ms 61.5 ms
26.12.1 79.6 ms 60.9 ms 52.0 ms

The slowest was 88.3 ms, with nothing else running in the VM. I did not test a busy machine.

Mach-O sections that span two load regions

I built small Mach-O containers by hand. They are not real Mach-O files. I ran each one through the head and through 21636ae. In each one the __data section holds one (ptr, len) header. The results were the same on all three Nodes.

__data section sits in 95c5da6 21636ae
one region literal kept kept
two readable regions that touch kept dropped
two readable regions that overlap kept dropped
two regions with a 4-byte gap dropped dropped
two touching regions, the second not readable dropped dropped

So the merge of touching readable regions works as the code says. One side effect shows up when I do the same for the read-only __rodata section. Say there is a 4-byte gap, or the second region can't be read. Then 95c5da6 drops the literal, where 21636ae kept it. The old code had no readable-region check on that section. I only tried hand-built containers, so I do not know how this plays out on a real Mach-O file.

The cancellation test

The cancellation test never fires inside the region index. I ran the 25,000-section container with a scratch copy of the test's cancel hook. The region index calls the cancel check 49 times. The test's hook ignores all 49, because it throws only after the first section is read. The throw then lands in the section loop in selectTargetSpans, after 1,024 sections. So the test covers cancel in the section loop, not in the region index. Same on all three Nodes.

Real Go binary and MCP

fzf 0.74.5 (MIT), Fedora's package build, same file as before (same sha256). REA only read it. The three CLI runs below exited 0, and the MCP calls give these counts.

  • No flags: no string_literals in the result.
  • --include-string-literals: 957 found, 957 returned, truncated: false, max_items: 2000.
  • Plus --max-string-literals 50: 957 found, 50 returned, truncated: true, max_items: 50.

I also called inspect_go_binary over MCP by hand with a scratch client. The tool lists both new fields, and the three calls above return the same counts as the CLI. A cap without the flag, a cap of 0 and a cap of 10001 each return an invalid_request error.

Still not run

  • --detail summary with the new flags.
  • Real PE and Mach-O Go binaries, and PE sections whose virtual size is larger than the raw size.
  • scripts/verify-go-binary.mjs, which this commit changed.
  • A comparison against the REA 6.8.0 release at this head.
  • The 100,000-candidate scan and a real cancel signal, by hand.
  • Memory and CPU time. Each run was timed once.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB), Linux 7.2.11, on a Nobara 44 host
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 95c5da6 / 015a02d (the main commit its last merge brought in)
  • Other: fzf 0.74.5 (MIT), Fedora's package build, sha256 b3fc1d67bd84b71ea81d935f0ec683c3274ff47bb6c3dadcb327bb925ba5a0da
Commands

All in the VM, exit 0 unless noted. Times are wall clock from the VM.

  • npm ci --offline: 14 s. npm run prepare: 0.2 s. npm run test:prepare: 11 s. All on Node 24.
  • npm run test:focused -- src/application/go/GoBinaryService.test.ts src/domain/analysisView/goBinaryView.test.ts src/go/GoStringLiterals.test.ts tests/acceptance/goBinaryCli.test.ts tests/boundary/cli/cliIntegerArguments.test.ts tests/boundary/go/goBinaryProvider.test.ts tests/boundary/mcp/goBinaryViews.test.ts
    • Node 24.22.1: 7 files, 211 tests passed, 33 s.
    • Node 22.23.4: 7 files, 211 tests passed, 47 s.
    • Node 26.12.1: 7 files, 211 tests passed, 31 s.
  • No test file touched calls doctor.
  • node scripts/rea.mjs inspect-go-binary ~/samples/fzf --format json, then the same with --include-string-literals, then with --include-string-literals --max-string-literals 50.
  • Scratch scripts (not PR code), run with the PR tree's tsx on Node 22, 24 and 26: one builds the hand-made Mach-O containers and times the 25,000-section build, one counts the cancel-check calls, and one compares the head with a copy of the 21636ae file. A fourth, run on Node 24, is a small MCP client that starts scripts/rea.mjs mcp and calls inspect_go_binary six times.
  • I copied fzf from the host's installed package file after its sha256 matched my earlier run.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: At a06b979, the PR's 7 changed test files pass on Node 22, 24 and 26 (221 tests). The cancellation test now fires inside the region index, which my review above said it didn't. A new table test also expects the __rodata drop I found, so the drop looks intended.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
The 7 changed test files 221 passed 221 passed 221 passed
  • That is 10 more tests than the 211 at 95c5da6. All 10 come from one new table test, requires contiguous readable Mach-O load_regions for $target ($mode). It tries five region layouts for both __data and __rodata (src/go/GoStringLiterals.test.ts lines 624-636).
  • The renamed test, indexes 25,000 Mach-O load regions and sections without quadratic stalls and honors region and section cancellation, now throws while the region loop runs. It then checks that no section was read yet (observedSections is 0). The section loop gets its own check after that (lines 563-621).
  • My review above found that 95c5da6 drops a __rodata literal in two cases. One is a 4-byte gap, and one is a second region that can't be read. At 21636ae, the code kept it. The new table expects the drop for __rodata, the same as for __data (lines 628-634).
  • For __data, the table's five layouts match the five rows of my scratch table (lines 625-629). The single, the touching and the overlapping layouts all keep the literal. Gap and unreadable-tail drop it.
  • CI on a06b979: CI, CodeQL production, Real Go binary metadata and PR title wait for a maintainer to approve them (action_required). PR readiness, Greptile Review and Validate author declaration passed.
  • The head is 5 commits behind main b81da90. GitHub says the PR is mergeable.

Not run

  • A real Mach-O Go binary, so I don't know whether real files hit the __rodata drop.
  • --detail summary with the new flags, scripts/verify-go-binary.mjs, and the 100,000-candidate scan by hand. I did not run these in my review above either.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: a06b979 / 015a02d (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/application/go/GoBinaryService.test.ts src/domain/analysisView/goBinaryView.test.ts src/go/GoStringLiterals.test.ts tests/acceptance/goBinaryCli.test.ts tests/boundary/cli/cliIntegerArguments.test.ts tests/boundary/go/goBinaryProvider.test.ts tests/boundary/mcp/goBinaryViews.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto
morluto enabled auto-merge (squash) November 8, 2026 19:07
@morluto
morluto merged commit 94182f3 into morluto:main Nov 8, 2026
47 of 48 checks passed
@morluto

morluto commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Welcome to the project, @saariuslystoned! Thanks for adding opt-in recovery of Go string literals from pointer-and-length headers. Exposing individual inferred strings with their limitations gives analysts a useful way to examine packed data.

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Welcome to the project, @saariuslystoned! Thanks for adding opt-in recovery of Go string literals from pointer-and-length headers. Exposing individual inferred strings with their limitations gives analysts a useful way to examine packed data.

Stoked to be here brother; big things coming for us all; i appreciate you and your humbleness;

@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants