[PR #3975] [MERGED] fix(browser): reject empty capture containers beyond the 64-level nesting budget #5976

Closed
opened 2026-10-31 01:10:53 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3975
Author: @Anurag-5ingh
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/capture-nesting-limit


📝 Commits (1)

  • df9a2b3 fix(browser): reject empty capture containers beyond the 64-level nesting budget

📊 Changes

3 files changed (+45 additions, -5 deletions)

View changed files

📝 src/browser/history/CaptureJson.ts (+7 -5)
📝 src/browser/history/HarCapture.test.ts (+19 -0)
📝 src/browser/history/QlogCapture.test.ts (+19 -0)

📄 Description

Summary

Fixes #3960.

inspect-web-network-capture documents a 64-level nesting budget for complete evidence, but the shared HAR/qlog JSON parser accepted an empty array or object at container level 65, while [0] at the same level was rejected. The documented limit now holds no matter what the deepest container holds.

Problem and expected behavior

Smallest trigger: a HAR whose log._extension chain reaches container level 65 with an empty innermost [] or {} (root = level 1). It decodes successfully. The same chain ending in [0] fails with input-limit.

Cause: parseCaptureJson checked depth before pushing a container with frames.length > 64. That admitted the 65th container. Over-deep scalars were rejected only because onLiteralValue ran the same check one frame deeper.

Expected:

  • Containers up to level 64 are accepted.
  • Every container at level 65 or deeper is rejected with the existing input-limit failure, whether it is empty or holds values.

Change and scope

  • src/browser/history/CaptureJson.ts owns JSON structure for both decoders (HarCapture.ts, QlogCapture.ts).
  • onObjectBegin and onArrayBegin now admit a container only while its own level stays within the budget (frames.length >= 64 rejects).
  • The literal-value check is removed. A value inside an admitted container adds no level, so empty and scalar-bearing containers share one boundary.

Not included:

  • The HAR visitor's own depth guard is unchanged.
  • The SAZ/XML depth checks (SazProjection.ts, SazMetadata.ts) are a separate path and unchanged.

Follow the contribution scope: this is an ordinary fix within existing boundaries, so a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: parseCaptureJson in src/browser/history/CaptureJson.ts.
  • Contribution scope fit and linked maintainer decision: in scope; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. Captures with empty containers at level 65 now return the documented input-limit failure instead of a decoded capture.
  • Provider, bridge, target-format, or platform compatibility: HAR and qlog JSON only; platform-independent.
  • Evidence, artifact, provenance, or reconstruction contract: no shape change. The error message and pointer are unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added in src/browser/history/HarCapture.test.ts and src/browser/history/QlogCapture.test.ts. Each decoder gets a parameterized boundary table using the issue's fixture shapes (HAR log._extension, qlog trace ext):

    Container level Innermost Result
    64 [], {}, [0] accepted
    65 [], {}, [0] nesting budget
    66 [] nesting budget
  • Base reproduction (source-derived): on the base revision, the level-65 [] and {} cases decode instead of throwing, matching the issue's report. The existing deeper-nesting tests are unchanged.

  • User-visible CLI/MCP output: an affected capture now fails with HAR exceeds the 64-level complete-evidence nesting budget. (or qlog …) instead of returning a decoded capture.

  • Remaining proof gaps: none known beyond CI results, which are pending.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • oxfmt --check on the changed files — passed.
  • Full test, lint and typecheck validation relies on this PR's CI. A local npm ci is not available in my environment because the registry it uses blocks some of the locked package versions.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Captures with an empty container at level 65 were already outside the documented budget and are now rejected consistently.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (offline capture parsing).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: this tightens an input resource bound; no other change.

Author readiness

Human owner: @Anurag-5ingh

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3975 **Author:** [@Anurag-5ingh](https://github.com/Anurag-5ingh) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/capture-nesting-limit` --- ### 📝 Commits (1) - [`df9a2b3`](https://github.com/morluto/rea/commit/df9a2b35251bb32a8c7c00fd35593b9da512e072) fix(browser): reject empty capture containers beyond the 64-level nesting budget ### 📊 Changes **3 files changed** (+45 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/history/CaptureJson.ts` (+7 -5) 📝 `src/browser/history/HarCapture.test.ts` (+19 -0) 📝 `src/browser/history/QlogCapture.test.ts` (+19 -0) </details> ### 📄 Description ## Summary Fixes #3960. `inspect-web-network-capture` documents a 64-level nesting budget for complete evidence, but the shared HAR/qlog JSON parser accepted an empty array or object at container level 65, while `[0]` at the same level was rejected. The documented limit now holds no matter what the deepest container holds. ## Problem and expected behavior Smallest trigger: a HAR whose `log._extension` chain reaches container level 65 with an empty innermost `[]` or `{}` (root = level 1). It decodes successfully. The same chain ending in `[0]` fails with `input-limit`. Cause: `parseCaptureJson` checked depth before pushing a container with `frames.length > 64`. That admitted the 65th container. Over-deep scalars were rejected only because `onLiteralValue` ran the same check one frame deeper. Expected: - Containers up to level 64 are accepted. - Every container at level 65 or deeper is rejected with the existing `input-limit` failure, whether it is empty or holds values. ## Change and scope - `src/browser/history/CaptureJson.ts` owns JSON structure for both decoders (`HarCapture.ts`, `QlogCapture.ts`). - `onObjectBegin` and `onArrayBegin` now admit a container only while its own level stays within the budget (`frames.length >= 64` rejects). - The literal-value check is removed. A value inside an admitted container adds no level, so empty and scalar-bearing containers share one boundary. Not included: - The HAR visitor's own depth guard is unchanged. - The SAZ/XML depth checks (`SazProjection.ts`, `SazMetadata.ts`) are a separate path and unchanged. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope): this is an ordinary fix within existing boundaries, so a maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `parseCaptureJson` in `src/browser/history/CaptureJson.ts`. - Contribution scope fit and linked maintainer decision: in scope; not applicable. - CLI and MCP/tool-catalog contract: no schema change. Captures with empty containers at level 65 now return the documented `input-limit` failure instead of a decoded capture. - Provider, bridge, target-format, or platform compatibility: HAR and qlog JSON only; platform-independent. - Evidence, artifact, provenance, or reconstruction contract: no shape change. The error message and pointer are unchanged. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added in `src/browser/history/HarCapture.test.ts` and `src/browser/history/QlogCapture.test.ts`. Each decoder gets a parameterized boundary table using the issue's fixture shapes (HAR `log._extension`, qlog trace `ext`): | Container level | Innermost | Result | | --- | --- | --- | | 64 | `[]`, `{}`, `[0]` | accepted | | 65 | `[]`, `{}`, `[0]` | `nesting budget` | | 66 | `[]` | `nesting budget` | - Base reproduction (source-derived): on the base revision, the level-65 `[]` and `{}` cases decode instead of throwing, matching the issue's report. The existing deeper-nesting tests are unchanged. - User-visible CLI/MCP output: an affected capture now fails with `HAR exceeds the 64-level complete-evidence nesting budget.` (or `qlog …`) instead of returning a decoded capture. - Remaining proof gaps: none known beyond CI results, which are pending. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `oxfmt --check` on the changed files — passed. - Full test, lint and typecheck validation relies on this PR's CI. A local `npm ci` is not available in my environment because the registry it uses blocks some of the locked package versions. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Captures with an empty container at level 65 were already outside the documented budget and are now rejected consistently. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (offline capture parsing). - Package or release metadata impact: none. - Security, privacy, process, or containment review: this tightens an input resource bound; no other change. ## Author readiness Human owner: @Anurag-5ingh - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5976
No description provided.