Repository navigation
fix(evidence): reject NUL bytes in subject and snapshot paths - #1873
Merged
Merged
Conversation
Evidence subject local_path and analysis-snapshot subject path accepted any string, so a caller-supplied inline Evidence record could carry a NUL byte into the observation and bundle output even though every other selected-path boundary already refuses it. Both fields now use the shared NUL-free local-path schema: the snapshot path keeps its nonempty rule, and the Evidence local_path stays free to be empty because network capture Evidence uses an empty path as a deliberate sentinel. localPath.ts now exports the NUL-free base schema separately so the nonempty rule is composed rather than duplicated; the advertised pattern and minLength for existing localPathStringSchema consumers are unchanged. Validation: new unit cases reject a NUL local_path and snapshot path while admitting an empty Evidence path and an ordinary path; domain suite 126 files / 1704 tests pass, evidence bundle and retained-evidence MCP boundaries pass, localToolContracts NUL harness passes, toolSchemaValidity passes with a regenerated catalog, typecheck, oxlint, oxfmt.
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. |
3 tasks done
6 of 7 tasks
Owner
|
A small boundary gap with real provenance consequences—thanks for closing it, @DeryFerd. Reusing the NUL-free path schema blocks invalid local paths before they enter Evidence or snapshots, while preserving the intentionally empty network-capture path. That edge case is especially well handled. |
7 of 22 tasks
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
Evidence subject
local_pathand the analysis-snapshot subjectpathwere plain strings, so an inline Evidence record supplied through a tool input could carry a NUL byte into the observation, the persisted snapshot, and any bundle written from it. Every other selected-path boundary in the repository already refuses NUL through the shared local-path schema, and a harness that exercises the real advertised MCP contracts asserts exactly that; the two Evidence subject schemas were the remaining gap. This PR routes both fields through the shared NUL-free schema, keeping the snapshot's nonempty rule and leaving the Evidencelocal_pathfree to be empty because network capture Evidence uses an empty path as a deliberate sentinel.Problem and expected behavior
Smallest trigger: parse an Evidence record whose subject is
{ "local_path": "a\u0000b", ... }, for example through an inlinesource: { kind: "inline", evidence: ... }input oninspect_analysis_viewor an imported bundle. Prior behavior: the schema accepted it, and the value flowed intosubject.local_pathon the observation and into any serialized snapshot or bundle. 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 rather than propagated as display data. Expected behavior:evidenceSchemaand the snapshot subject schema reject a NULlocal_path/path, an ordinary absolute or relative path is still accepted, and an empty Evidencelocal_pathstays accepted because existing producers depend on it.Change and scope
The NUL-free pattern now lives in
src/domain/localPath.tsasnulFreeStringSchema, andlocalPathStringSchemais composed from it asnulFreeStringSchema.min(1)so the nonempty rule is expressed once instead of duplicated.src/domain/evidence.tsusesnulFreeStringSchemaforsubject.local_pathbecause that field is legitimately empty for network capture Evidence, andsrc/domain/analysisSnapshot.tsuseslocalPathStringSchemaforsubject.path, which preserves the exact previous nonempty behavior while adding the NUL refusal. Intentionally not included: no change tosubject.name, no change to any other string field, no new advertised contract shape, and no attempt to reinterpret the empty network-capture path as an error.Contract and boundary impact
src/domain/evidence.tsandsrc/domain/analysisSnapshot.ts, parsed at the tool-input and snapshot-import boundaries before any observation or bundle is built.localPathStringSchemaconsumers is unchanged (the emittedpatternandminLength: 1are byte-identical); the two Evidence subject fields gain the same NUL-rejectingpatternalready used on every other path field, which is a validation tightening consistent with the existing boundary contracts.local_pathwas already excluded from the semantic identity, so no existingev_/snapshot identity changes, and the tightening only rejects inputs that were never valid.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; the catalog digest moves only because the Evidence subject schema moved.Evidence and regression coverage
src/domain/evidence.test.tsassertsevidenceSchemaaccepts an ordinary path and an empty path and rejects a NULlocal_path; a unit case insrc/domain/analysisSnapshot.test.tsasserts the snapshot schema rejects a NUL subjectpath.For evidence-bearing changes:
Validation performed
npx vitest run src/domain/— 126 files, 1704 tests passed, including the new Evidence and snapshot cases.npx vitest run tests/boundary/mcp/evidenceBundleInline.test.ts tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts— passed.npx vitest run tests/acceptance/tools/localToolContracts.test.ts— passed, including the existing OS-invalid-local-input harness that rejects NUL through the real advertised MCP contracts.npx vitest run tests/boundary/mcp/toolSchemaValidity.test.ts— 8 passed afternpm run mcp-catalog:generate.npm run typecheck— exit 0 after rebasing ontobcd350c36.npx oxlinton the five changed files — 0 errors (theno-control-regexandmax-lineswarnings are pre-existing on the base);oxfmt --checkon the committed (LF) form — clean.Compatibility, safety, and release
Review checklist
type(scope): outcome.