Repository navigation
fix(browser)!: preserve storage value code units - #6341
Conversation
Keep ordinary UTF-8 digests and secret redaction, separate malformed UTF-16 preimages, and record storage fingerprint provenance. Compare legacy hashed snapshots as unknown without treating encoding metadata as a target change. Cover producer boundaries and real owned-browser CLI/MCP workflows. BREAKING CHANGE: legacy hashed browser storage remains readable but comparisons return unknown until both sides are recaptured.
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. |
[Medium impact] The reviewed changes appear safe to merge, with no actionable issue found. SummaryPreserves storage value code units when strings contain unpaired UTF-16 surrogates.
Acknowledgment: Review limits: Tests and the browser verifier were not run during this review. Whether this PR has been superseded could not be checked because GitHub access required authentication. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Storage value] --> B{Contains a declared secret?}
B -->|Yes| C[Redacted; no hash]
B -->|No| D{Contains an unpaired surrogate?}
D -->|No| E[Hash UTF-8 bytes]
D -->|Yes| F[Hash FF prefix and UTF-16LE bytes]
E --> G[Snapshot version 2]
F --> G
H[Compare storage snapshots] --> I{Either side has legacy hashed values?}
I -->|Yes| J[Unknown; recapture both sides]
I -->|No| K[Compare content without version metadata]
Reviews (1) · Last reviewed commit: "fix(browser)!: preserve storage value co..." · Reviewed by Greptile |
Summary
Fixes #6289. Preserve JavaScript storage value identity when strings contain unpaired UTF-16 surrogates; do not turn irreversible legacy information loss or encoding metadata into a website change.
Problem and expected behavior
On base
3d472bde23b70f9aa7bcf0d28a0cd10e469545e9, real owned Chromium plus public CLI capture/comparison returnedunchangedfor separately captured\ud800and\ud801local/session storage. Both values had SHA-25683d544ccc223c057d2bf80d3f2a32982c32c3c0db8e2674820da5064783fb097: UTF-8 replaced the distinct code units before hashing.New captures report these pairs, and
\ud800versus\ufffd, aschanged. Independently recaptured identical values remainunchanged.Change and scope
BrowserScenarioSecrets.fingerprintowner: ordinary strings keep their existing UTF-8 digest; unpaired code units use raw0xfffollowed by exact UTF-16LE. The byte domains are disjoint. Declared secrets still returnredacted-secret/ null before hashing; no extra secret or legacy digest.fingerprint_version: 2. Absence means legacy, not v2. The comparison boundary checks provenance before normalization and excludes the version from content projection.unknown, even old-to-old and when a difference could otherwise be proven. This intentionally trades legacy comparison coverage for soundness; recapture both sides. Empty/all-secret-redacted storage retains its existing semantics. No legacy Evidence is rewritten. This compatibility policy remains subject to maintainer review.Contract and boundary impact
Evidence and regression coverage
Producer cases cover ordinary UTF-8, paired/unpaired units, an exact v2 byte golden, declared-secret redaction and a cross-encoding alias that defeats bare UTF-16LE fallback. Comparison cases cover all three storage collections, both legacy sides, different legacy digests, normalization order, and metadata-only changes.
The real-browser helper runs four independent captures through each public adapter (8 total), checks changed/unchanged controls, ordinary cookie/local/session digests, secret redaction, version-less imported results as
unknown, CLI/MCP parity, full retained MCP records, server liveness and owned-profile cleanup. It is wired into the existing real-browser verifier.Validation performed
On macOS arm64, pinned Node 24.18.0 / npm 11.16.0; base
2127095e3b4a377abbc124ca83af46b98a2a557b, tested head8d46743eb64167eba7a0062a754d18ffb9316e8e:npm run test:focused -- src/browser/BrowserScenario.test.ts src/browser/PlaywrightScenarioEvents.test.ts src/browser/PlaywrightScenarioArtifacts.test.ts src/browser/PlaywrightScenarioStorage.test.ts src/domain/browserScenarioCapture.test.ts src/domain/browserScenarioDiff.test.ts tests/boundary/mcp/browserScenarioMcp.test.ts— 86 tests passed.verifyScenarioStorageFingerprintswith the existing owned loopback verifier fixture and installed Chromium 155.0.8059.85 — passed: 8 independent captures, both adapters, imported version-less comparisons, retention and cleanup; 49.421 s including loopback-site setup/teardown (not a before/after performance benchmark).npm run check:fast— typecheck/lint passed.npm run docs:check— generated facts/catalog checks and 9 conformance tests passed.npm run verify:test-discovery— all 2051 test files discovered exactly once.git diff --check— passed. Independent read-only review found no blocking issue; its suggested codec/legacy regressions are included.Compatibility, safety, and release
Breaking comparison behavior: previously accepted legacy captures still parse, but hashed legacy storage comparisons now return
unknown; recapture both sides for sound value comparison. Already lost code units cannot be reconstructed. New ordinary-string digests remain compatible, without inferring that an unversioned capture was lossless.Not run: the complete real-browser verifier, full test/CI suite, Windows/Linux, attached/passive-browser workflows or other providers. No performance claim; token usage, CPU and peak process-family memory were not measured. Local validation does not establish CI success, maintainer approval or merge permission.
Author readiness
Human owner: @gongfpp
AI-assisted contribution; the human owner confirmed review and requested initial maintainer review.
Before merge