Repository navigation
fix(contracts): reject NUL bytes in Frida, Rizin, and GDB local path inputs - #3575
Merged
morluto merged 1 commit intoOct 14, 2026
Merged
Conversation
…inputs Route the caller-selected local path fields in load_frida_script, instrument_with_frida, start_frida_session, start_rizin_debug_session, and start_gdb_session through the shared localPathStringSchema so a NUL byte is refused at the advertised contract boundary instead of reaching the filesystem or a provider subprocess and surfacing as a raw error. Extend the OS-invalid-local-input acceptance harness to the tools that were missing from it.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Contributor
[Medium impact] This PR appears safe to merge; no actionable defects were found. SummarySeven Frida, Rizin, and GDB path fields now use the shared
Reviews (1) · Last reviewed commit: "fix(contracts): reject NUL bytes in Frid..." · Reviewed by Greptile |
Owner
|
Thanks @DeryFerd for spotting the same path-contract gap across Frida, Rizin, and GDB and bringing all seven fields onto the shared schema. Extending the acceptance coverage alongside the fix helps keep these tools consistent as their contracts evolve. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a contract gap where several caller-selected local path inputs on the Frida, Rizin, and GDB tools were typed as plain strings instead of the shared local-path schema, so an embedded NUL byte passed advertised and runtime validation and only failed later inside a provider or a filesystem call.
Every other local-input tool in REA already refuses NUL at the contract boundary through
localPathStringSchemainsrc/domain/localPath.ts. These seven fields were added after the earlier NUL sweeps (#1873, #1899, #1925) and were not included, so they drifted from the rest of the surface. This change routes them through the same shared schema and extends the existing OS-invalid-local-input acceptance harness to the tools that were missing from it.Problem and expected behavior
The smallest trigger is calling
start_frida_sessionwith{"mode":"spawn","device_id":"local","program":"/tmp/selected\u0000filename"}. The advertised JSON Schema only requiredminLength: 1, so the value was accepted, and the NUL was carried into the Frida spawn path where it surfaced as an opaquecapability_unavailableerror rather than a named input constraint. The expected behavior is a typed schema rejection that names the NUL byte, consistent with every other local path tool.The violated invariant is that caller-selected local filesystem paths are validated once at the owning contract boundary. A NUL byte is never a valid path component on any supported platform, so admitting it defers a deterministic, caller-visible mistake to a deeper layer, where it reads as a provider failure instead of a request error. The same gap applied to
load_frida_script.path, bothinstrument_with_fridapath and program fields,start_rizin_debug_session.path,start_rizin_debug_session.inferior_tty, andstart_gdb_session.inferior_tty.Change and scope
start_frida_session.program,load_frida_script.path,instrument_with_frida.program, andinstrument_with_frida.pathinsrc/contracts/fridaToolContracts.tsthroughlocalPathStringSchema.start_rizin_debug_session.pathandstart_rizin_debug_session.inferior_ttyinsrc/contracts/rizinDebugToolContracts.tsthrough the same schema.start_gdb_session.inferior_ttyinsrc/contracts/gdbToolContracts.tsthrough the same schema, keeping its existing description.tests/acceptance/tools/localToolContracts.test.tswith one case per field so the shared harness covers the Frida, Rizin, and GDB tools.The approach reuses the existing schema owner rather than adding a new validation layer, which is how the earlier fixes in this class landed. The
.regex(/^[^\x00]*$/u)pattern onnulFreeStringSchemasurvivesz.toJSONSchema, so the constraint is advertised to clients and enforced at runtime from the same definition. GDB already rejected a NULinferior_ttyat runtime inGdbSessionManager, so its change is contract consistency rather than a behavior change; Frida and Rizin had no service-level NUL check for these fields.Intentionally not included: no changes to the path values themselves, no new absolute-path requirement (that would be a separate, breaking contract change), and no changes to any tool outside the Frida, Rizin, and GDB contracts.
Contract and boundary impact
src/contracts/own input admission; the change moves the earliest NUL rejection to the advertised contract boundary.minLength: 1. The generated MCP tool catalog is regenerated by CI and validated; no committed catalog file changes.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none.Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
tests/acceptance/tools/localToolContracts.test.ts, which drives the real advertised MCP contracts through the built server and asserts each request is rejected with a message containingNUL.start_frida_session, showing the NUL input passed schema validation and reached the provider, where it surfaced ascapability_unavailablewith the messageUnable to find executable at '/tmp/selected'(the value truncated at the NUL). After the change the harness passes and the response is a schema error naming the NUL byte.For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/acceptance/tools/localToolContracts.test.ts— 1 passed (the OS-invalid-local-input matrix now includes the Frida, Rizin, and GDB cases); fails on the base revision for the intended reason.npm run test:focused -- src/contracts/fridaToolContracts.test.ts src/contracts/sessionPathInputs.test.ts src/contracts/advertisedInputExamples.test.ts tests/boundary/mcp/fridaLifecycleMcp.test.ts tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts tests/boundary/mcp/gdbCancellationMcp.test.ts— 49 passed, 5 skipped.npm run test:focused -- src/contracts/compactInputSchema.test.ts src/contracts/toolInputReferences.test.ts src/contracts/toolOutputReferences.test.ts src/contracts/workflowInputContracts.test.ts— 43 passed.npm run typecheck— clean.npx oxlinton the four changed files — 0 warnings, 0 errors.npx oxfmt --checkon the four changed files — clean.npm run verify:module-boundaries— checked 1886 source files, clean.npm run mcp-catalog:check— passed.npm run docs:check— 5 passed.Compatibility, safety, and release
Author readiness
Human owner: @DeryFerd
Before merge
type(scope): outcome.