rea/src
Omisakin Joshua 8823c55b0c
feat(ghidra): decode Swift String literals in function dossiers (#2049)
* feat(ghidra): decode Swift String literals in function dossiers

Swift passes a String as two words. Small literals keep their UTF-8 bytes
inside those words, and immortal large literals keep a count plus a pointer
to their bytes biased by 32. Ghidra creates no data reference for either, so
analyze_function reported no strings for Swift code.

On AArch64 programs that contain Swift metadata, the Ghidra bridge now runs
constant propagation over the function and decodes register pairs where
Swift consumes a String: consecutive argument registers at calls and tail
calls, x0 and x1 at returns, and both registers of one STP. Large literals
must resolve to terminated bytes inside one initialized block that is not
executable. A pair whose registers both come from conditional selects is
skipped, because Ghidra forks each select without correlating the
condition and could otherwise pair words from different cases.

Decoded values are a derivation from the ABI layout rather than observed
references, so they appear in a new optional swift_string_literals field
with their source instruction, registers and raw words, and in a matching
inspect_analysis_view facet. referenced_strings is unchanged.

Refs #2030

* fix(ghidra): bound Swift literal reads and compare decoded strings

Large immortal literals are measured against the remaining heap before
allocation, and a failed fit stays visible as a limitation. The canonical
empty string is kept. Small and large literals now require matching
address nullability, and function comparison treats decoded literals as
string evidence without equating a missing record to an empty one.

* fix(ghidra): budget Swift literal decoding and tighten use sites

Large literals now draw on one heap budget per dossier, measured once
before decoding, instead of a separate check per literal. A literal that
does not fit is listed in a new swift_string_literal_omissions field
with its address, byte length and reason, so consumers read omissions
from structured data rather than from limitation text.

strings_names comparison checks referenced strings and names first and
reports a change there even when Swift literal coverage differs; it
returns unknown only when those facts match and literal coverage is
absent on one side or partial.

A computed jump counts as a tail call only when it has no resolved
target inside the function, so jump tables no longer qualify, and a
return requires a RETURN p-code operation, so traps no longer qualify.

Decoded literals keep control characters, which Swift strings may
contain and JSON escapes. The Swift verifier builds the literal fixture
for arm64 on any Mac host and now also covers the empty string and a
literal containing a tab.

* fix(ghidra): charge escaped JSON and follow copied selects

The Swift literal budget now charges the worst case per UTF-8 byte: UTF-16
text, six escaped JSON characters held in Gson's growing buffer and in the
returned String, and the UTF-8 bytes written to the socket. Literals made
of control characters can no longer exceed the reserved heap.

A jump counts as a tail call only when every resolved target lies outside
the function. The conditional select check follows register copies back
to their definition, so selects copied into argument registers are
recognized like selects written there directly.

strings_names reports a change when both dossiers decoded different
literals at the same use site, even when either side has omissions; it
returns unknown only when no such use site disagrees.

* fix(ghidra): bound literal records and trace selects across branches

Every Swift literal record now pays a fixed cost against the dossier
budget in addition to its text, so many empty or small literals are
bounded as well. The first record that does not fit is kept as an
omission and decoding stops there, which keeps the omission record
itself bounded; omissions now describe small or large literals.

The conditional select check searches every predecessor path for the
reaching definitions, following register copies, so selects made
before a branch into the use block are recognized.

A dossier records Swift literals and their omissions together. Coverage
reads omissions first, and strings_names compares every use site that
neither side omitted: a decoded literal is known where it was recorded,
and an absence is known only in a dossier whose decoding examined every
use site.

* fix(ghidra): stop every flow at the literal budget and route omissions

Ending one flow from the evaluator leaves other queued flows running, so
the budget now records a shared stop that every flow checks before it
examines another instruction. A record that exceeds the budget is routed
by that capacity result rather than by whether text was decoded, so a
small literal over budget becomes an omission instead of a literal.

When coverage is partial, the per site comparison keeps each literal's
representation as well as its value, matching the full strings_names
projection.

* fix(ghidra): keep unresolved Swift tail-call sites unknown

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-13 20:41:10 +08:00
..
adb fix(adb): count requested permissions that the device marks restricted (#2359) 2026-10-13 14:52:48 +08:00
android fix(android): reject malformed UTF-8 at the JADX protocol boundary 2026-10-13 14:56:04 +08:00
apktool fix(filesystem): enforce symlink and decoded-text admission 2026-10-13 13:39:57 +08:00
application fix(reference): preserve directory intent when resolving source imports (#2770) 2026-10-13 20:06:19 +08:00
artifacts fix(artifacts): distinguish JVM classes from universal Mach-O files (#2327) 2026-10-13 20:27:38 +08:00
browser fix(captures): name the violated HAR schema constraint (#2708) 2026-10-13 16:22:24 +08:00
captures feat(captures): discover installed protocol and field definitions (#2496) 2026-10-13 15:55:25 +09:00
cli fix(ghidra): resolve file offsets in decompile (#2101) 2026-10-13 18:23:17 +08:00
composition fix(javascript): retain compiler-dependent module resolution facts 2026-10-13 15:58:25 +08:00
config fix(config): reject NUL bytes in Hopper loader arguments (#2474) 2026-10-13 14:51:29 +08:00
contracts fix(ghidra): resolve file offsets in decompile (#2101) 2026-10-13 18:23:17 +08:00
domain feat(ghidra): decode Swift String literals in function dossiers (#2049) 2026-10-13 20:41:10 +08:00
dotnet fix(managed): preserve negative zero in CIL operands (#2437) 2026-10-13 18:19:44 +08:00
evaluation fix(evaluation): share completed transcript facts across graders 2026-10-13 13:12:12 +08:00
evm fix(artifacts): retain read cleanup ownership through CLI and MCP shutdown 2026-10-13 16:08:41 +08:00
filesystem fix(filesystem): enforce symlink and decoded-text admission 2026-10-13 13:39:57 +08:00
firmware fix(artifacts): honor cancellation at the output publication boundary 2026-10-13 15:12:17 +08:00
flutter fix(pcap): order evidence ties by code point instead of host locale (#2509) 2026-10-13 14:44:09 +08:00
frida perf(frida): evict captured messages without copying the whole queue (#2628) 2026-10-13 00:11:38 -07:00
ghidra feat(ghidra): decode Swift String literals in function dossiers (#2049) 2026-10-13 20:41:10 +08:00
go fix(artifacts): retain read cleanup ownership through CLI and MCP shutdown 2026-10-13 16:08:41 +08:00
hopper fix(hopper): stop Linux demo children when the REA owner exits (#2499) 2026-10-13 12:59:22 +08:00
ida fix(ci): align FAT fixtures and consolidate duplicated workflow helpers 2026-10-13 16:16:31 +08:00
inspector fix: honor empty URL query and fragment markers (#2091) 2026-10-13 06:05:29 +09:00
javascript fix(javascript): retain compiler-dependent module resolution facts 2026-10-13 15:58:25 +08:00
jeb fix: honor empty URL query and fragment markers (#2091) 2026-10-13 06:05:29 +09:00
main feat(sqlite): inspect offline snapshots with selective evidence (#2271) 2026-10-12 18:33:23 +00:00
native fix: preserve process identities in pwntools cleanup errors (#2284) 2026-10-13 20:28:31 +08:00
pcap fix(pcap): order evidence ties by code point instead of host locale (#2509) 2026-10-13 14:44:09 +08:00
process fix: preserve process identities in pwntools cleanup errors (#2284) 2026-10-13 20:28:31 +08:00
reference fix(reference): verify symlink identity around target reads 2026-10-12 04:33:47 +08:00
server fix(artifacts): retain read cleanup ownership through CLI and MCP shutdown 2026-10-13 16:08:41 +08:00
signals feat(signals): discover installed decoders and option help (#2487) 2026-10-13 15:58:19 +09:00
sqlite feat(sqlite): inspect offline snapshots with selective evidence (#2271) 2026-10-12 18:33:23 +00:00
wasm fix(artifacts): retain read cleanup ownership through CLI and MCP shutdown 2026-10-13 16:08:41 +08:00
windows fix(windows): preserve transient runtime admission failures (#2467) 2026-10-13 11:42:54 +08:00
catalogIdentity.ts feat(server): frame analysis-target content as untrusted data (#1908) 2026-10-13 06:06:02 +09:00
cli.ts feat(pcap): add bounded capture summaries through CLI and MCP 2026-10-13 04:53:03 +00:00
cliBrowserContext.ts fix(mcp): isolate optional observation adapter failures (#838) 2026-10-07 11:45:17 +08:00
cliBrowserScenarioCommands.ts fix(cli): await browser scenario cleanup on interrupts 2026-10-11 17:33:57 +08:00
cliCommandNames.ts feat(signals): discover installed decoders and option help (#2487) 2026-10-13 15:58:19 +09:00
cliEvidenceCommands.ts perf(mcp): keep Playwright and type-only imports off MCP startup (#1691) 2026-10-10 21:04:05 -07:00
cliHostInputs.test.ts refactor: remove forwarding exports and redundant aliases 2026-10-09 22:46:09 +08:00
cliJavaScriptRuntimeCommands.ts fix(cli): retain browser and Inspector input correction details (#2230) 2026-10-13 02:29:07 +08:00
cliJsonInput.ts fix(filesystem): bound and verify admitted file and JSON reads 2026-10-11 00:28:24 +08:00
cliJsonPaths.test.ts fix(cli): preserve blank JSON paths for input validation (#1068) 2026-10-08 20:57:54 +08:00
cliLogging.test.ts feat(update): update Bun global installations (#1735) 2026-10-11 17:56:05 +08:00
cliLogging.ts fix(cli): preserve failure semantics across full-output formats 2026-10-13 03:33:27 +08:00
cliObservationOptions.ts fix(javascript): trace wrapped Electron IPC paths in large bundles (#1874) 2026-10-12 09:28:59 +08:00
cliOutput.ts fix(cli): reject unterminated output filter slices (#2315) 2026-10-13 20:04:33 +08:00
config.test.ts fix(config): reject NUL bytes in Hopper loader arguments (#2474) 2026-10-13 14:51:29 +08:00
doctorRuntime.ts refactor!: enforce canonical evidence and provider boundaries 2026-10-09 20:18:52 +08:00
generatedPackageMetadata.ts feat(fiddler): inspect native SAZ captures 2026-10-13 02:51:14 +00:00
homeDirectory.test.ts fix(setup): ignore empty home directory selections 2026-10-13 04:11:55 +08:00
identity.ts feat: streamline agent integration and MCP routing 2026-07-20 17:11:06 +08:00
logger.ts fix(cli): report an invalid REA_LOG_LEVEL as configuration (#2140) 2026-10-12 06:07:37 -07:00
main.ts fix(mcp): keep shared optional providers open across discarded probes (#2205) 2026-10-12 06:56:45 -07:00
mcpDoctor.ts fix(mcp): join owned doctor shutdown without signaling saved PIDs 2026-10-13 15:12:08 +08:00
mcpStartupPolicy.ts perf(mcp): reduce cold-start work 2026-07-26 15:02:58 +00:00
serverIdentity.ts refactor: return complete analysis results inline 2026-09-29 08:07:24 +08:00
setupEnvironment.test.ts fix(setup): register a stable launcher when run through bunx (#1731) 2026-10-11 19:17:15 +08:00