Skip to content

fix(browser): admit browser-serialized HAR request URLs - #2044

Closed
Hyped01 wants to merge 1 commit into
morluto:mainfrom
Hyped01:fix/har-request-url-query-characters
Closed

Hyped01 wants to merge 1 commit into
morluto:mainfrom
Hyped01:fix/har-request-url-query-characters

Conversation

@Hyped01

@Hyped01 Hyped01 commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

inspect_web_network_capture validates each HAR request.url with ajv-formats' strict RFC 3986 uri format. Browsers serialize request URLs per WHATWG URL and leave several characters unescaped: [ ] { } | ^ and backtick, a % that starts no escape, and a backslash in the query or fragment. A HAR that Chrome itself exports for such a page is therefore rejected whole as a format error.

Problem and expected behavior

On main, decodeHarCapture rejects every one of these browser serializations with HAR schema validation failed: format.:

  • https://example.test/?q=[1]|{x}
  • /search?q=100%
  • /x?cb=%%CACHEBUSTER%%
  • /collect?e={%22k%22:%22a\%22b%22}

They should decode. Spellings that browsers never produce stay rejected, for example http:\\user:pass@host/ and a tab inside the scheme.

Change and scope

  • A request URL is admitted when the pinned RFC 3986 check accepts it either as written or after percent-encoding only these characters:
    • each [ ] { } | ^ and backtick;
    • each % not followed by two hex digits;
    • each backslash after the first ? or #.
  • A backslash before the first ? or #, and a tab, stay rejected.
  • The original spelling is kept in the decoded output.
  • The transport-credential header set moves unchanged from history/CaptureRedaction.ts to src/browser/network/TransportCredentials.ts. capture_browser_scenario's network headers use it instead of a private copy, and the session HAR recorder (feat(browser): record observe_web_session traffic as HAR #2045) uses the same set. URL userinfo stays with src/domain/recordedTransportUrl.ts.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/browser/history/HarSchema.ts.
  • CLI and MCP/tool-catalog contract: none. More HAR files are accepted, and none that were accepted before is rejected.
  • Provider, bridge, target-format, or platform compatibility: HAR 1.2 input only.
  • Evidence, artifact, provenance, or reconstruction contract: none. Request URLs are reported as written.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/browser/historicalCaptureDecoder.test.ts runs the real decodeHarCapture.
    • Admitted: an RFC-only URL (http://example.com:99999/), every browser serialization above, a % followed by one hex digit and a non-hex character (?status=100%Done), and a fragment backslash. Each case also checks that the URL is its own WHATWG serialization and that the reported URL keeps its spelling.
    • Still rejected: backslash and tab credential spellings, each checked to carry a WHATWG password; a path backslash; and a non-URL.
    • PlaywrightScenarioNetwork.test.ts pins every member of the shared credential header set.
  • Base reproduction: on main every admitted browser serialization above fails with format.
  • Mutation checks: each of these fails a test.
    • Dropping the lone-% rule.
    • Dropping the backslash rule.
    • Encoding every backslash.
    • Ignoring #.
    • Encoding backslashes before ?.
    • Reverting to the strict check alone.
  • Remaining proof gaps: none known for the listed spellings.

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

Host: macOS 27.0.1, Node 24.20.0.

  • turbo run typecheck lint format:check knip metadata:check docs:check:built mcp-catalog:check:built, npm run verify:architecture-guards, npm run verify:test-discovery and npx jscpd src/ tests/ all pass.
  • npx vitest run on 10 browser, CLI, MCP and process boundary files: 58 passed, 2 skipped.
  • exposes CLI-equivalent Evidence results and session tools, an existing MCP test, times out only under heavy machine load. It fails the same way on unmodified main.
  • Cold review with adversarial verification: the final round reported no findings.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the widening is limited to characters that never end a URL authority, and recordedTransportUrl still excludes userinfo from every admitted URL.

This PR stands on its own on main. The session HAR PRs (#2045 onward) build on it.

🤖 Generated with Claude Code

inspect_web_network_capture validates request.url with ajv-formats' RFC 3986
`uri` format. Browsers serialize request URLs per WHATWG URL and leave
[ ] { } | ^ and backtick, a `%` that starts no escape, and a backslash in the
query or fragment unescaped, so a HAR that Chrome itself exports for such a
page was rejected whole as a format error.

- A request URL is admitted when the pinned RFC 3986 check accepts it as
  written or with only those characters percent-encoded: each [ ] { } | ^ and
  backtick, each `%` not followed by two hex digits, and each backslash after
  the first `?` or `#`. Spellings that only WHATWG parsing accepts, such as a
  backslash before the first `?` or `#` or a tab, stay rejected: browsers
  never serialize them, and WHATWG alone reads an authority through them.
- The transport-credential header set moves unchanged from CaptureRedaction
  to src/browser/network/TransportCredentials.ts; capture_browser_scenario's
  network headers now use it instead of a private copy, and the session
  HAR recorder in the next change applies the same set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T04:18:31.544194Z 6b912ce PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b912ce5b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +34 to +35
value.replace(
/[[\]{}|^`\\]|%(?![0-9A-Fa-f]{2})/gu,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require fallback URLs to be browser serializations

When a listed character appears in a component where browsers do not preserve it, this component-blind replacement converts malformed input into valid RFC syntax. For example, https://example.test/a{b} is neither RFC-valid nor its own WHATWG serialization (new URL(...).href contains %7B/%7D), but this code rewrites it for validation and admits the HAR. Limit the compatibility escaping to URL components where browsers actually retain these characters, or gate it with a format-aware serialization check.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

@Hyped01 Hyped01 closed this Oct 12, 2026
@Hyped01
Hyped01 deleted the fix/har-request-url-query-characters branch October 12, 2026 04:36
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants