Skip to content

fix(domain): preserve prototype-named JSON members through Evidence boundaries - #1049

Merged
N0zoM1z0 merged 7 commits into
morluto:mainfrom
sx4im:fix/jsonvalue-prototype-named-members
Oct 8, 2026
Merged

N0zoM1z0 merged 7 commits into
morluto:mainfrom
sx4im:fix/jsonvalue-prototype-named-members

Conversation

@sx4im

@sx4im sx4im commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

JSON parsing silently dropped prototype-named members, changing retained Evidence and its semantic identity. JSON boundaries now validate every own member before cloning with safe data-property construction, preserving __proto__, constructor, escaped names, and nested values. Invalid JSON hidden under those names is rejected; the existing 1,000-edge depth guard and nonrecursive advertised schemas remain enforced.

Evidence parameter maps use the same preserving object boundary. HAR and native mitmproxy captures retain these members through CLI/MCP output; the native bridge’s obsolete refusal is removed. The real capture verifier checks retained producer fields and unchanged capture files for both formats.

Validation:

  • Focused JSON/Evidence/HAR, CLI/MCP, identity, schema, and contract-presentation tests pass.
  • npm run check, generated-document regeneration/checks, and Python syntax validation pass.
  • All 11 reviewed source files remain identical after main integration; SDK schema and capture tests pass on the integrated tree.
  • Local native mitmproxy verification is unavailable because mitmdump is not installed; the corresponding real-tool CI lane is required before merge.

Real Hopper/Ghidra verification was not performed.

Fixes #1036.

sx4im and others added 7 commits October 8, 2026 10:49
…oundaries

Zod's z.json() record projection drops own __proto__ members as a
prototype-pollution guard, so provider replies carrying them lost evidence
before hashing/serialization and CLI/MCP output. The shared schema now
validates with z.json() as before, then rebuilds the value keeping
prototype-named own members as ordinary data properties (__proto__ via
Object.defineProperty, so the prototype is never mutated).

parseHarJson no longer rejects __proto__ members; the explicit unsupported
case from morluto#992 is replaced with a preservation regression, and the
inspect_web_network_capture contract text is updated to match.

Fixes morluto#1036
…aries

jsonValueSchema re-walked hostile input through z.json()'s recursive core, so a deeply nested payload from an MCP tool argument, inline evidence, provider result, or keyed archive threw RangeError: Maximum call stack size exceeded instead of a validation issue. The schema now runs an iterative depth guard first and keeps z.json() for full JSON semantics behind it, which also turns cyclic values into validation errors. The 1000-edge limit stays far below the range where the recursive core overflows its stack (measured between 2000 and 3000 on Node 24) while leaving room for legitimately deep target-derived trees such as compiled NIB view hierarchies, and the guard narrows with a typed record check instead of any or unchecked casts. The non-recursive JSON Schema advertisement stays intact on both the public and standard projection paths. Two payload sizes get explicit budgets tied to their producer constraints: web text artifacts reject beyond the 16 MiB source budget the web tooling already advertises, and native UI screenshot base64 beyond the 64 MiB helper output budget. Regenerated product catalog, skill catalog digest, and completion-ledger manifest follow the schema-boundary change.
# Conflicts:
#	docs/product-catalog.json
#	docs/verification/managed-conformance-manifest.json
#	skills/reverse-engineer-anything/SKILL.md
#	src/domain/evidence.test.ts
#	src/domain/jsonValue.test.ts
#	src/domain/jsonValue.ts

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added maintainer fixes to validate every own JSON member, preserve Evidence parameter identity, and remove the native bridge’s obsolete refusal. Focused JSON/HAR/CLI/MCP tests, SDK schema validation, static checks, and generated-document checks pass. Real web capture CI now passes with retained-member assertions for both formats; waiting for the remaining platform checks before merge.

@N0zoM1z0
N0zoM1z0 merged commit 40e18b2 into morluto:main Oct 8, 2026
26 checks passed
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…oundaries (morluto#1049)

* fix(domain): preserve prototype-named JSON members through Evidence boundaries

Zod's z.json() record projection drops own __proto__ members as a
prototype-pollution guard, so provider replies carrying them lost evidence
before hashing/serialization and CLI/MCP output. The shared schema now
validates with z.json() as before, then rebuilds the value keeping
prototype-named own members as ordinary data properties (__proto__ via
Object.defineProperty, so the prototype is never mutated).

parseHarJson no longer rejects __proto__ members; the explicit unsupported
case from morluto#992 is replaced with a preservation regression, and the
inspect_web_network_capture contract text is updated to match.

Fixes morluto#1036

* fix(domain): bound JSON depth and oversized payloads at parsing boundaries

jsonValueSchema re-walked hostile input through z.json()'s recursive core, so a deeply nested payload from an MCP tool argument, inline evidence, provider result, or keyed archive threw RangeError: Maximum call stack size exceeded instead of a validation issue. The schema now runs an iterative depth guard first and keeps z.json() for full JSON semantics behind it, which also turns cyclic values into validation errors. The 1000-edge limit stays far below the range where the recursive core overflows its stack (measured between 2000 and 3000 on Node 24) while leaving room for legitimately deep target-derived trees such as compiled NIB view hierarchies, and the guard narrows with a typed record check instead of any or unchecked casts. The non-recursive JSON Schema advertisement stays intact on both the public and standard projection paths. Two payload sizes get explicit budgets tied to their producer constraints: web text artifacts reject beyond the 16 MiB source budget the web tooling already advertises, and native UI screenshot base64 beyond the 64 MiB helper output budget. Regenerated product catalog, skill catalog digest, and completion-ledger manifest follow the schema-boundary change.

* fix(validation): preserve depth diagnostics across process inputs

---------

Co-authored-by: DeryFerd <[email protected]>
Co-authored-by: N0zoM1z0 <[email protected]>
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the area: domain Domain logic, errors, and pure functions label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Preserve prototype-named JSON members through Evidence boundaries

4 participants