Repository navigation
fix(contracts): reject NUL bytes in objdump and rizin local path inputs - #3600
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] This PR appears safe to merge. SummaryBoth tools now use the shared local-path check to reject NUL bytes.
Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
rahul05ranjan
left a comment
There was a problem hiding this comment.
The failure mode checks out: both objdumpCommand (src/objdump/ObjdumpCommand.ts:23) and rizinCommand (src/rizin/RizinCommand.ts:14) pass resolve(input.path) into the execFile argv, so before this change a \\0 path sailed past z.string().min(1) and surfaced as ERR_INVALID_ARG_VALUE inside child_process instead of a contract validation error. Reusing localPathStringSchema puts the rejection at the right layer — these two exported schemas are the advertised boundary, and both entry points (the safeParse in the MCP registration in registerReverseEngineeringTools.ts and ReverseEngineeringService.inspectWithObjdump/executeRizinCommand) re-parse through them, so the fix covers each path without ad-hoc call-site checks. The pathless architectures variant is unaffected since only objdumpArtifactInputSchema narrows path, and command on the rizin side already had its own NUL/CRLF refine, so I don't see a remaining gap.
I verified against the exported schemas on the PR branch: \\0 in either path is rejected with the "Local filesystem paths cannot contain NUL" message, while a valid artifact path and the pathless architectures input still parse. I could not exercise the actual objdump/rizin providers — those binaries aren't installed on my host — so the spawn side of the claim is static (argv construction above) rather than runtime.
One gap: the PR body lists tests/acceptance/tools/localToolContracts.test.ts under tests, but the diff only touches src/domain/reverseEngineering.ts. The shared pathRequests table in that file enumerates NUL rows for sibling contracts (open_binary, start_rizin_debug_session, inspect_managed_artifact, ...) but has no rows for inspect_with_objdump or execute_rizin_command. Adding two entries there would keep this hardening locked in if the schema ever reverts to z.string().min(1), and it matches the pattern the neighboring contracts already follow.
|
Thanks for the thorough review and verification @rahul05ranjan! Great catch on the PR description discrepancy — the diff intentionally focuses strictly on the production schema boundary in |
baron
left a comment
There was a problem hiding this comment.
HOLD / requesting changes on e869468385b7f5a02d1132716b04784386cee706.
No new inline findings. The existing regression-coverage finding remains unaddressed; please resolve it before merge. The passing existing NUL acceptance case does not call either changed tool. Reuse that public-MCP table rather than adding another schema-only test layer.
The production change itself is clear: localPathStringSchema owns the nonempty/NUL-free invariant, both named contracts and the application service consume it, and the pathless architectures branch remains separate. No additional downstream sanitizer or wrapper is needed. The service also already catches digest/filesystem failures and returns AnalysisInputError before provider execution; the PR's pre-fix “unhandled runtime error” narrative is not established by the source or my head-only runtime checks. Please qualify that claim or supply an actual base reproduction.
Verification in an isolated temporary clone, Node 24.18.0 / npm 11.16.0:
- Locked dependency installation and
npm run check:fastpassed. - A targeted review-only probe passed for both tools: canonical parsing, SDK-advertised Draft 2020-12 schemas validated/compiled with Ajv, and real compiled stdio MCP calls reject NUL paths with the descriptive NUL error. Direct service calls reject them before filesystem access. Relative/whitespace/newline-containing valid paths are preserved; empty paths and the pathless variant's extra path remain rejected.
npm run test:focused -- tests/acceptance/tools/localToolContracts.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/reverseEngineeringPartialMcp.test.ts tests/boundary/cli/reverseEngineeringCommands.test.ts: 32 passed, 6 failed. CLI and reverse-engineering MCP suites passed. Failures were three PTYspawn EPERMcases and three timeouts (two whole-catalog schema checks, one process-choice test). I did not establish baseline attribution for these failures; this is not a clean local acceptance run.
Immediately before submission, the head was unchanged, existing reviews/comments were rechecked, all repository Actions workflows (including CI required, readiness, and title) were successful, and no checks were pending/failing/canceled. Sixteen conditional jobs were skipped, not real-provider verification. No base runtime reproduction, real objdump/Rizin execution, or Windows/Linux host verification was performed. No shared-checkout edits, merges, labels, or committed test changes.
e869468 to
84e2090
Compare
|
@baron @rahul05ranjan Updated head with commit
|
|
TL;DR: The current head adds the two test rows that the review asked for. On Linux, those rows fail on main and pass on the head. Main already rejects a NUL path, but with a generic message, not the NUL message. Edit: I retested this PR on its new head f976d14 (a merge of main) on Node 22, 24 and 26; the new result is here. This checks whether head 84e2090 answers the review on e869468. That review asked for two things. Review ask 1: regression coverage for the two toolsHead 84e2090 adds
One case fails. It is the one that checks OS-invalid inputs through the real MCP contract. It expects "NUL" in the reply. Main replies with a generic message instead, for both tools:
Review ask 2: qualify the "unhandled runtime error" claimThat output is a base reproduction. On main, a NUL path is already rejected as an error. It is not an unhandled crash. The head changes the message to the canonical NUL one. The current PR body says the NUL path fails later, as State on GitHub
Not run
Thanks, qorvr, for the quick follow-up. Commands# main c7f6b8ba extracted to /tmp/t25-1015/w, then:
npm ci && npm run build && npm run test:prepare
# before: only the PR's test hunk applied to main
git apply --include='tests/*' 3600.diff
npm run test:focused -- tests/acceptance/tools/localToolContracts.test.ts
# after: the PR's source hunk applied too (tree matches head 84e20905)
git apply --include='src/*' 3600.diff
npm run test:focused -- tests/acceptance/tools/localToolContracts.test.tsTo reach the Rizin row on main, I removed the objdump row from my copy of the test file. The first failure stops that loop. The PR file was not changed. The head run used the unedited file. The file runs a real MCP server over stdio on the local machine. It makes no network calls. I grepped the file for doctor first. The only hits are Test setup🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
# Conflicts: # src/domain/reverseEngineering.ts
|
CI-track update: I merged latest |
|
TL;DR: I retested head f976d14 on Node 22, 24 and 26. The two new NUL rows pass on the head. They fail on all three Node versions when I take out the PR's source change. The PR's own change is the same as the one I tested on 15 Oct. baron's two asks look met in the code, and his hold is still shown. This reruns my 15 Oct checks (my earlier result, head 84e2090). The head moved when kaoru0822-kitauji merged main in (comment). Results (Linux)
Is the PR's own change the same?Yes. The changed lines are identical at 84e2090 and f976d14. Only the surrounding context moved. They are What baron asked forbaron's review is on e869468, not on this head. It asked for two things.
The review is still the latest one, and the PR still shows changes requested. No one has reviewed the new head yet. Not run
Thanks to kaoru0822-kitauji for keeping the branch up to date. State on GitHub
Commands# head f976d1431 extracted to /tmp/rt-3600-r2/head, HOME=/tmp/rt-3600-r2/home, Node 24 for the install and build:
npm ci --ignore-scripts && npm run build && npm run test:prepare
# on Node 22, 24 and 26, each under timeout 1800:
npm run test:focused -- tests/acceptance/tools/localToolContracts.test.ts
# without the fix: the PR's source hunk reverted in the same tree, then the same command on 22, 24, 26
patch -R -p1 < pr-src.diff
# Rizin-only probe on Node 24: the objdump row removed from the test file in the build tree
# restore: patch -p1 < pr-src.diff, test file copied back; both files cmp-identical to the headThe file runs a real MCP server over stdio on the local machine. I grepped it for Test setup
🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
baron
left a comment
There was a problem hiding this comment.
Re-reviewed this exact head; the previous regression-coverage request is addressed. Both tools now have NUL-path cases in the public MCP acceptance table, and the original thread is resolved.
The change reuses the canonical path schema without rewriting valid caller-selected paths. On Node 24.22.1/npm 11.16.0, the focused compiled-stdio MCP acceptance case and canonical/service/SDK JSON Schema probes passed at this head and after integration with recorded main d361c53c504590b5ec90e9c690b5a2d6ae67cc38. Main's timeout controls and shared Rizin admission resolver remain intact; invalid requests never reach the provider/filesystem boundary in the targeted probe.
Required CI is green and the author's readiness declaration is present. No real objdump/Rizin execution, Linux/Windows host verification, or full local suite was performed. Those are not established by this validation-only change. Approval is a review verdict, not merge permission.
Summary
Ensures advertised local tool contracts for
inspect_with_objdumpandexecute_rizin_commandreject NUL bytes in path inputs, aligning with established local tool contract boundaries.Problem and expected behavior
src/domain/reverseEngineering.ts,objdumpArtifactInputSchema.pathandrizinInputSchema.pathusedz.string().min(1)instead oflocalPathStringSchema.\0), input passes schema validation and reachesReverseEngineeringService, propagating until downstream filesystem checks fail (surfacing asAnalysisInputErrororERR_INVALID_ARG_VALUE) instead of being admitted/rejected cleanly at the advertised schema/contract boundary with the canonical NUL error message.Change and scope
path: z.string().min(1)withpath: localPathStringSchemainobjdumpArtifactInputSchemaandrizinInputSchema.tests/acceptance/tools/localToolContracts.test.tsby addinginspect_with_objdumpandexecute_rizin_commandwith NUL path inputs to the sharedpathRequestsacceptance test table.Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
objdumpInputSchema,rizinInputSchemainsrc/domain/reverseEngineering.ts.inspect_with_objdumpandexecute_rizin_commandlocal path input validation.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:
Evidence and regression coverage
tests/acceptance/tools/localToolContracts.test.ts(addedinspect_with_objdumpandexecute_rizin_commandwith NUL path inputs to the sharedpathRequeststest table, asserting early rejection with the descriptive NUL message through public MCP).\0toinspect_with_objdumporexecute_rizin_commandbypassed schema validation (z.string().min(1)).For evidence-bearing changes:
Validation performed
npx oxfmt --check .— all matched files passed formatting check.npm run typecheck— 0 errors.npm run check:fast— turbo typecheck, lint passed cleanly.npm test -- tests/acceptance/tools/localToolContracts.test.ts— 5/5 passed (100%).Compatibility, safety, and release
Author readiness
Human owner: @qorvr
Before merge
type(scope): outcome.