rea/docs
Lluís Ariño 85e124253a
feat(server): frame analysis-target content as untrusted data (#1908)
* feat(server): frame analysis-target content as untrusted data

Strings, decompiled code, page text, scripts, captures and logs returned
by REA originate from the analysed target, which can embed text aimed at
the agent. Nothing marked that content, so a prompt injection inside a
binary or page could steer the agent toward tools that run code.

- Server instructions now state that target-derived tool output is data,
  never instructions, and that any request in it to run, install,
  download or send something is a prompt-injection attempt to report.
- Tool contracts declare returnsTargetContent. It is on by default; only
  seven tools whose results hold REA session state or caller-supplied
  values (binary_session, close_binary, export_evidence_bundle,
  record_unknown, update_unknown, inspect_adb_client,
  inspect_apktool_client) are audited exceptions, so new tools start
  marked.
- Successful results of marked tools carry
  _meta.provenance = { untrusted_content: true, source: "analysis_target" }.
  content and structuredContent are unchanged, and the response budget
  accounts for the fixed marker bytes.

Tests cover the encoding and budget accounting, the audited exception
list against the contract catalog, and an in-memory MCP client that sees
the instructions and the marker on a marked tool but not on
binary_session.

* fix(server): mark failed target-content results as untrusted too

The untrusted provenance marker was attached only on the success branch
of ToolResultDelivery, but failures can carry target-derived text as
well: error messages, captured output, and partial observations such as
the terminal frames a failed capture_process_scenario retains in
partial_observation. A host gating later process or device actions on the
marker would have treated an adversarial error payload as trusted.

Every error path in src/server now carries the failing tool's provenance:
- toErrorToolResult and toRecordedPartialErrorToolResult take the tool's
  target-content flag explicitly, so each caller is audited by the type
  checker; toCallToolResult, toEvidenceToolResult (recording failure), the
  response-budget error that replaces an oversized success, and the
  Electron partial-evidence path pass contract.returnsTargetContent.
- Admission failures in runAdmittedToolOperation resolve the flag from the
  tool name through the new toolReturnsTargetContent, the same predicate
  the contract metadata uses; unknown names stay marked.
- The transport's oversized-error replacement keeps the original's marker
  and counts it in its budget check, matching the projected error.
- Errors the MCP SDK builds itself (input validation, thrown handlers) are
  marked in the transport for target-content tools only.

Error encoding accounts for the marker bytes exactly as success encoding
does. docs/mcp-contracts.md now states that error results carry the
marker. Tests cover marked and unmarked error results, the
capture_process_scenario partial-observation errors in-process and over
the SDK transport, the recorded partial-evidence path, the budget
replacement, the oversized-error replacement, and SDK validation errors
for a marked and a content-free tool.

* fix(contracts): mark session status, close and client probes as target content

The content-free exception set was audited against successful results
only. Now that failures carry the marker too, every exception was
re-audited against its error paths with one question: can the result
include text produced by an external process, provider or device, or
stored content REA did not author?

Removed from TARGET_CONTENT_FREE_TOOLS:
- close_binary: a failed provider cleanup (GhidraClient cleanup error via
  createGhidraDiagnostics) projects the launcher's captured stdout and
  stderr, which can contain target-derived log text.
- binary_session: capability status reports runtime unavailability as the
  provider error message (ProviderAdapterError and similar), and the
  provider candidate and Android availability diagnostics include probe
  output such as the apktool stderr excerpt.
- inspect_adb_client: the success result carries the version and
  installed path parsed from `adb version` stdout, and a failed probe
  keeps a stderr_excerpt.
- inspect_apktool_client: the success result carries the first line of
  the launcher's `--version` output, and a failed probe keeps a
  stderr_excerpt.
- update_unknown: the new revision carries forward the stored question
  and domain, which an imported evidence bundle can supply; list_unknowns
  and get_evidence_bundle already return that data marked.

The set now holds only export_evidence_bundle (path, byte and record
counts; failures are filesystem, cancellation, or a fixed integrity
message) and record_unknown (the caller's input plus REA-computed ids
and digests; registry errors project only a reason code).

The conformance test pins the reduced set and asserts each removed tool
is marked. Tests that used binary_session as the unmarked example now use
record_unknown. docs/mcp-contracts.md lists the remaining exceptions and
why the removed tools stay marked.

* fix(contracts): include target-content policy in the catalog identity

createToolCatalog() and CATALOG_IDENTITY.tools projected every
client-visible contract field except returnsTargetContent. Because the
untrusted-content framing left schemas, effects, prompts, CLI names and
the package version unchanged, a same-version MCP process started before
the update digested equal to the new server and binary_session reported
it aligned although it never emits _meta.provenance.

Project the flag as returns_target_content in both the digested tool
catalog and CATALOG_IDENTITY.tools, and export createCatalogDigests so a
boundary test proves that toggling the flag on one tool changes the
tools and combined digests.
2026-10-13 06:06:02 +09:00
..
.vitepress feat(signals): decode recordings with bounded sigrok output (#2339) 2026-10-12 20:59:02 +00:00
assets docs: keep license sections text-only 2026-10-10 00:09:46 +08:00
releases chore(main): release rea-agents 6.4.0 (#1399) 2026-10-11 11:57:29 +08:00
adb-device-analysis.md fix(adb): preserve existing bugreport archives (#2221) 2026-10-13 00:25:17 +08:00
android-analysis.md fix(android): preserve decoded values and duplicate class inventories 2026-10-12 06:29:13 +08:00
apktool-resource-analysis.md fix(apktool): run Windows batch launchers through cmd.exe (#1777) 2026-10-11 17:16:48 +08:00
apple-application-analysis.md fix(mobile): bound framework conventions to path segments (#1506) 2026-10-10 21:42:03 +08:00
architecture.mermaid refactor(evm): bind offline analysis through a static descriptor 2026-10-13 01:26:43 +08:00
binary-diagnostics.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
browser-observation.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
browser-scenario-contract.md fix(browser): report mismatched event family selection as unknown in capture comparison (#2239) 2026-10-13 02:36:45 +08:00
cli.md fix(reference): report sloppy scripts, PHP, C# and enclosing Git facts (#1770) 2026-10-13 05:52:27 +09:00
client-configuration.md feat(clients): register Qoder CLI during setup (#1572) 2026-10-12 22:55:55 +08:00
client-verification.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
electron-observation.md fix(electron): support packaged app.asar pages and rewritten unpacked companions (#1400) 2026-10-10 23:01:54 +08:00
error-contract.schema.json feat(evm): inspect offline bytecode interfaces through EVMole (#1051) 2026-10-08 15:32:05 +08:00
evm-bytecode.md feat(evm): add retained interface summary delivery (#2308) 2026-10-13 03:09:32 +08:00
firmware-analysis.md feat(ghidra): admit RISC-V ELF analysis through a pinned generic lane (#2151) 2026-10-13 00:11:35 +08:00
flutter-analysis.md feat(flutter): identify Dart snapshot builds and inspect AOT payloads by pure APK parsing (#1582) 2026-10-12 22:35:55 +08:00
frida-instrumentation.md feat: add Frida instrumentation support (#1359) 2026-10-12 22:01:58 +08:00
ghidra-dos.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
ghidra-mips.md test(ghidra): require pending multi-HI16 coverage in the real MIPS relocatable lane (#1974) 2026-10-12 08:42:08 +08:00
ghidra-nativeaot.md feat(ghidra): inspect NativeAOT PE metadata read-only 2026-10-11 10:31:49 +08:00
ghidra-provider.md feat(ghidra): inspect NativeAOT PE metadata read-only 2026-10-11 10:31:49 +08:00
ghidra-psp.md feat(ghidra): admit bounded PSP ELF through installed Allegrex (#1599) 2026-10-11 19:47:33 +08:00
ghidra-riscv.md feat(ghidra): admit RISC-V ELF analysis through a pinned generic lane (#2151) 2026-10-13 00:11:35 +08:00
go-binaries.md feat(go): inspect embedded binary build metadata (#1363) 2026-10-12 11:34:02 +08:00
harmony-analysis.md feat(harmony): project HarmonyOS package inventory evidence (#1447) 2026-10-11 20:09:21 +08:00
ida-provider.md feat(ida): support optional native IDA Free MCP in attached mode (#1544) 2026-10-13 03:10:21 +08:00
index.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
installation.md docs(ghidra): verified macOS arm64 native decompiler build recipe (#2112) 2026-10-13 05:58:28 +09:00
javascript-application-graph.md docs(contracts)!: explain canonical URL and skill metadata ownership 2026-10-10 02:49:46 +08:00
javascript-application-workflows.md docs: correct stale logging, Ghidra host, and example path statements (#1420) 2026-10-10 21:29:31 +08:00
javascript-artifact-reconstruction.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
javascript-recovery.md feat(javascript): recover code-split bundles from multiple inputs (#1686) 2026-10-11 18:39:49 +08:00
javascript-runtime-observation.md fix(runtime)!: preserve unknown debugger attachment state 2026-10-12 12:37:00 +08:00
javascript-runtime-reconciliation.md fix(tools)!: simplify direct invocation and harden boundary contracts (#555) 2026-10-05 20:16:44 +08:00
jeb-analysis.md feat(jeb): add JEB engine provider over its MCP interface (#1536) 2026-10-10 23:03:27 +08:00
managed-code-analysis.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
mcp-contracts.md feat(server): frame analysis-target content as untrusted data (#1908) 2026-10-13 06:06:02 +09:00
mcp-prompts.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
migration-6.2.md docs: correct MCP error and capture import guidance 2026-10-10 05:41:52 +08:00
native-investigation.md docs: preserve the native guide title anchor (#2224) 2026-10-12 23:09:11 +08:00
packet-captures.md feat(captures): inspect recorded packets with bounded TShark delivery (#2318) 2026-10-12 19:35:35 +00:00
process-capture.md fix(process): add an opt-in Swift module cache (#2252) 2026-10-13 02:26:16 +08:00
raw-binary.md feat(ghidra): apply validated analyzer overrides before analysis 2026-10-12 03:49:31 +08:00
reconstruction-obligation-ledgers.md refactor: return complete analysis results inline 2026-09-29 08:07:24 +08:00
reconstruction-readiness.md docs(readiness): align required stage identifier and checks with evaluator (#2200) 2026-10-13 00:15:54 +08:00
recorded-crashes.md feat(native): inspect recorded crashes through pwntools and pwndbg (#1054) 2026-10-08 16:50:31 +08:00
releasing.md fix(release): avoid duplicated contributor thanks 2026-10-11 11:49:49 +08:00
roadmap.md docs: remove retired architecture and migration artifacts 2026-10-10 05:41:45 +08:00
signal-recordings.md feat(signals): decode recordings with bounded sigrok output (#2339) 2026-10-12 20:59:02 +00:00
sqlite-databases.md feat(sqlite): inspect offline snapshots with selective evidence (#2271) 2026-10-12 18:33:23 +00:00
testing.md feat(ida): support optional native IDA Free MCP in attached mode (#1544) 2026-10-13 03:10:21 +08:00
tool-design.md docs: define performance priorities for analysis workflows (#2245) 2026-10-13 00:42:06 +08:00
user-visible-errors.csv fix(scripts, install): honor test:fast "without build" promise and orient Node.js engine mismatches (#2026) 2026-10-12 13:54:57 +08:00
wasm-artifacts.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00
web-network-captures.md test: strengthen public input and module lookup controls 2026-10-12 11:59:23 +08:00
web-runtime.md fix(browser): treat module-import initiator positions as script positions 2026-10-08 16:44:25 +00:00
web-source-location.md fix(bun): report the real runtime and enforce worker memory budgets on Windows (#1730) 2026-10-11 19:20:00 +08:00
website-module-trace.md feat(browser): trace captured website module imports (#879) 2026-10-07 14:59:52 +08:00
website-script-export.md fix(browser): preserve body API provenance through script export 2026-10-12 14:12:19 +08:00
windows-ghidra-p0.md docs: correct drift and reorganize English guides (#2207) 2026-10-12 22:14:25 +08:00