Repository navigation
fix(web): reject NUL bytes in web tool local path inputs - #1899
Merged
Merged
Conversation
Four web tools accepted caller-selected local paths as plain strings, so a NUL byte passed contract validation and reached filesystem calls. The services only checked isAbsolute, and isAbsolute admits a NUL, so the failure surfaced later as a raw ERR_INVALID_ARG_VALUE instead of a named input constraint. Every other local-input tool already refuses NUL through the shared local-path schema, and the existing OS-invalid-local-input harness covers those but not these web tools. inspect_web_network_capture.capture_path, export_web_scripts.capture_path and output_directory, trace_web_source_location.manifest_path and source_map.path, and trace_web_module_imports.manifest_path and import_map.path now use localPathStringSchema. Each field already required a nonempty string, so the advertised pattern and minLength stay the same and only the NUL refusal is added. Validation: a new schema test rejects NUL in all seven fields while accepting ordinary absolute paths; the four tools are added to the OS-invalid-local-input harness and reject NUL through the real advertised MCP contracts; typecheck, oxlint, oxfmt, and toolSchemaValidity with a regenerated catalog. Two webScriptExport boundary cases fail identically with and without this change on this Windows host (symlink EPERM and private-runtime-root authority), so they are environmental.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
abhi-byte62
reviewed
Oct 11, 2026
abhi-byte62
left a comment
There was a problem hiding this comment.
Good consistency fix!
- Standardizing on localPathStringSchema across exportWebScriptsInputSchema, webSourceLocationInputSchema, and webModuleTraceInputSchema ensures web-tool MCP contracts adhere to the same zero-NUL validation as the other local tools.
- Good parameterized test coverage in webToolPathSchemas.test.ts and inclusion in localToolContracts.test.ts.
viniciusdsandrade
added a commit
to viniciusdsandrade/rea
that referenced
this pull request
Oct 11, 2026
Resolve the localToolContracts conflict with 499ac18 (morluto#1899), which applied the same localPathStringSchema change to export_web_scripts. Keep its web tool cases and drop this branch's duplicate export_web_scripts case.
10 tasks done
3 tasks done
7 of 22 tasks
2 tasks done
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
Four web tools accepted caller-selected local paths as plain strings, so a NUL byte passed contract validation and reached the filesystem layer. The owning services only checked
isAbsolute, andisAbsoluteadmits a NUL, so the byte was carried into a file operation and surfaced there as a rawERR_INVALID_ARG_VALUE("path must be a string... without null bytes") rather than as a named input constraint. Every other local-input tool in the repository already refuses NUL through the shared local-path schema, and the existing OS-invalid-local-input harness covers those tools but not these four. This PR routes the seven affected fields through the same shared schema so the refusal happens at the contract boundary, and extends the harness to the tools that were missing from it.Problem and expected behavior
Smallest trigger: call
inspect_web_network_capturewith{"capture_path": "/tmp/selected\u0000filename", "format": "har"}, or any of the six sibling cases listed below. Prior behavior: the input schema accepted the value, the service'sisAbsolutecheck passed, and the file read then threw a raw Node error instead of a typedAnalysisInputError, so the caller saw an internal error string rather than the shared "Local filesystem paths cannot contain NUL" constraint the other tools return. The violated invariant: a value the caller selects as a local filesystem path should be parsed once at the owning boundary, and NUL is never a valid filesystem path byte on any supported host, so it should be refused there. Expected behavior: all seven fields reject a NUL with the shared message, an ordinary absolute path is still accepted, and the accepted/rejected set for every other input is unchanged.Change and scope
The seven caller-facing path fields now use
localPathStringSchemainstead ofz.string().min(1):inspect_web_network_capture.capture_path(src/domain/webNetworkCapture.ts),export_web_scripts.capture_pathandoutput_directory(src/domain/webScriptExport.ts),trace_web_source_location.manifest_path(sharedselectedWebScriptInputSchemainsrc/domain/webScriptArtifacts.ts) andsource_map.path(src/domain/webSourceLocation.ts), andtrace_web_module_imports.manifest_pathandimport_map.path(src/domain/webModuleTrace.ts). Each field already required a nonempty string, solocalPathStringSchemais a drop-in: the emittedpatternandminLengthare identical and only the NUL refusal is added. Intentionally not included: output and derived path fields that REA builds internally from already-validated input are left as-is, no service-levelisAbsolutecheck is removed, no URL field changes, and no tool is added or removed.Contract and boundary impact
minLength: 1and gains the shared NUL-rejectingpatternalready used by every other local-path tool. The catalog digest moves only because the contract moved, and no catalog file is committed.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions inskill-src/and never commit build outputs): none committed..cache/mcp-tool-catalog.jsonis regenerated test metadata and is not part of the repository.Evidence and regression coverage
src/domain/webToolPathSchemas.test.tsrejects a NUL in all seven fields and accepts ordinary absolute paths as a control;tests/acceptance/tools/localToolContracts.test.tsadds the four tools to its OS-invalid-local-input harness so they are exercised through the real advertised MCP contracts.For evidence-bearing changes:
Validation performed
npx vitest run src/domain/webToolPathSchemas.test.ts— 8 passed, including the seven NUL-rejection cases and the accepted-path control.npx vitest run tests/acceptance/tools/localToolContracts.test.ts— passed, including the four newly added tools through the real advertised MCP contracts.npx vitest run tests/boundary/mcp/toolSchemaValidity.test.ts— 8 passed afternpm run mcp-catalog:generate.npx vitest run tests/boundary/filesystem/webScriptExport.test.ts— 2 failures that reproduce identically with this change stashed (a symlinkEPERMand aprivate-runtime-root-authority-unavailablecase on this Windows host), so they are environmental and pre-existing.npm run typecheck— exit 0.npx oxlinton the changed files — 0 warnings, 0 errors;oxfmt --checkon the committed (LF) form — clean.Compatibility, safety, and release
Review checklist
type(scope): outcome.