fix(web): reject NUL bytes in web tool local path inputs
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.
This commit is contained in:
@@ -91,6 +91,42 @@ const pathRequests: readonly [string, Record<string, unknown>][] = [
|
||||
),
|
||||
["capture_electron_scenario", { ...electron, args: ["a\0b"] }],
|
||||
["demangle_swift", { symbols: ["abc\0def"] }],
|
||||
["inspect_web_network_capture", { capture_path: nul, format: "har" }],
|
||||
[
|
||||
"export_web_scripts",
|
||||
{ capture_path: nul, output_directory: "/tmp/exported-scripts" },
|
||||
],
|
||||
[
|
||||
"export_web_scripts",
|
||||
{ capture_path: "/tmp/capture.json", output_directory: nul },
|
||||
],
|
||||
[
|
||||
"trace_web_source_location",
|
||||
{
|
||||
manifest_path: nul,
|
||||
script_index: 0,
|
||||
source_map: { path: "/tmp/source.map", url: "http://127.0.0.1/a" },
|
||||
generated_position: { line: 1, column: 0 },
|
||||
},
|
||||
],
|
||||
[
|
||||
"trace_web_source_location",
|
||||
{
|
||||
manifest_path: "/tmp/manifest.json",
|
||||
script_index: 0,
|
||||
source_map: { path: nul, url: "http://127.0.0.1/a" },
|
||||
generated_position: { line: 1, column: 0 },
|
||||
},
|
||||
],
|
||||
["trace_web_module_imports", { manifest_path: nul, script_index: 0 }],
|
||||
[
|
||||
"trace_web_module_imports",
|
||||
{
|
||||
manifest_path: "/tmp/manifest.json",
|
||||
script_index: 0,
|
||||
import_map: { path: nul, base_url: "http://127.0.0.1/a" },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
it("rejects OS-invalid local inputs through the real advertised MCP contracts", async () => {
|
||||
|
||||
Reference in New Issue
Block a user