Inspiration

Every week, developers, QA engineers, and enterprise customers are asked to attach a .har (HTTP Archive) capture when reporting an API bug or opening a vendor support ticket. Yet raw .har files capture an entire browser session: live session cookies, OAuth access_token and refresh_token strings inside JSON responses, form-encoded passwords, GraphQL variables, and AWS presigned S3 URLs (X-Amz-Signature).

While researching existing tools, we audited the source code and open issue trackers of current HAR scrubbers and found three critical gaps:

  1. Chrome 130+ Built-in HAR Sanitizer only scrubs top-level Cookie, Set-Cookie, and Authorization headers (20.0% recall on our 12-file benchmark), leaving 100% of JSON request/response bodies and signed URLs exposed.
  2. Cloudflare's open-source har-sanitizer runs regular expressions over raw HAR text (26.7% recall). As documented in its GitHub issues, this approach misses application/x-www-form-urlencoded POST fields without trailing delimiters (Issue #17), corrupts valid HAR JSON when headers contain escaped quotes (Issue #22), ignores OAuth tokens inside JSON response bodies (Issue #27), and fails to scrub X-Amz-Signature parameters at the end of URLs inside JSON strings (Issue #44).
  3. Destruction of Auth Debugging: Naive scrubbers overwrite every credential with identical [REDACTED] text. When diagnosing a 401 Unauthorized bug caused by a token rotation race condition, replacing both the old token and the new token with [REDACTED] destroys the causal proof.

We built HARshield Workbench to take this problem off the workbench: a 100% client-side, structure-preserving HAR 1.2 AST sanitizer and minimal reproduction bundler.

What it does

  • Zero-Egress Local V8 Airlock: Parses and sanitizes .har files 100% inside browser memory (0 B network egress, self-hosted fonts, zero external API calls).
  • Recursive MIME & Double-JSON AST Sanitization: Instead of running destructive regexes over raw file strings, HARshield parses the HAR 1.2 JSON tree and recursively unwraps application/json, stringified JSON-in-JSON envelopes, application/x-www-form-urlencoded bodies, encoding: "base64" JSON responses, JWT payload claims, inline key=value headers, and embedded presigned URLs. It then recalculates bodySize and content.size so exported .har files pass JSON.parse() 100% of the time.
  • Referential Token Lineage (JWT_TOKEN_#1 vs JWT_TOKEN_#2): Normalizes credential cores (Bearer <token> and raw <token> in a login JSON response resolve to the exact same token identity) and hashes them with an in-memory FNV-1a session salt. Engineers can click JWT_TOKEN_#1 in the Referential Token Lineage Ribbon to trace every request and response where that exact token was ISSUED, USED, or REJECTED_401.
  • One-Click Noise Stripping & Minimal Repro Bundler: Strips static font/CSS/image and analytics beacon noise and exports a guaranteed-valid .sanitized.har, a redacted curl script (.sh), an executable @playwright/test API specification (.spec.ts), or a Markdown Incident Report.
  • Truncated HAR Stream Auto-Repair: Large browser .har exports often cut off mid-entry when saved while background connections are open. HARshield pinpoints the exact Line : Col syntax error and salvages all complete HTTP entries in one click.

How we built it

  • Core AST & Lineage Engine (src/engine/): Written in strict TypeScript with zero cloud dependencies:
    • harParser.ts: Validates HAR 1.2 schemas, computes line/column diagnostics on malformed inputs, and implements a character-level state-machine scanner (attemptRepairCorruptedHar) to recover complete entries from truncated streams.
    • recursiveSanitizer.ts: Traverses headers, cookies, query strings, and nested MIME payloads, plus runs a live Competitor Gap Audit comparing HARshield against Chrome 131's header scrubber and Cloudflare's regex rules on the user's loaded trace.
    • pseudonymizer.ts: Decodes Base64URL JWT headers/claims locally and maintains a session-salted alias ledger (JWT_TOKEN_#1, OAUTH_TOKEN_#1, PRESIGNED_SIG_#1) across structured and unstructured payloads.
    • reproExporter.ts: Compiles sanitized traces into shell-escaped curl pipelines, Playwright API tests, and Markdown bug reports.
  • Forensic Protocol Workbench UI (src/App.tsx): Built with React 18, Vite, and Tailwind CSS using a high-density dark analyzer aesthetic (Space Grotesk + JetBrains Mono) with a Synchronized Dual-AST Diff view (Raw Exposure in Crimson vs Sanitized Output in Emerald) and a responsive 3-station 390px mobile layout.

Challenges we ran into

During our real-world validation against external .har captures from open-source repositories (mitmproxy/mitmproxy, Netflix/pollyjs, cloudflare/har-sanitizer, and sitespeedio/coach-core), our initial engine passed 8/12 files (74.1% secret recall) and exposed five real-world edge cases that we subsequently fixed:

  1. Non-Standard Array Header Values in Polly.JS: Netflix/pollyjs v1.4.1 serializes set-cookie header values as a JSON string array (["__cfduid=..."]) rather than a string, which initially threw a TypeError during cookie splitting. Normalizing array header values fixed this completely.
  2. Echoed Credentials in Binary-Text Protobuf Payloads: In mitmproxy's diff_data.har, a client_id parameter from the URL query string was also echoed inside an application/vnd.google.octet-stream-compressible request body alongside a raw email and Google API key. Adding cross-layer propagation (scrubKnownSecretsInUnstructuredText) ensured any secret discovered in structured headers/queries is also scrubbed when echoed in unstructured bodies.
  3. Unquoted Inline Header Key-Value Pairs: Supporting both quoted key="val" (Cloudflare Issue #22) and unquoted X-Custom-Auth: client_secret=mysupersecret&client_id=app123 without regex boundary corruption.
  4. Base64-Encoded & Double-Encoded JSON Payloads: Decoding encoding: "base64" JSON response bodies and recursively unwrapping stringified JSON objects ("{\"password\":\"...\"}") inside outer JSON envelopes.
  5. Zero-Egress Font Loading in Headless Firefox: Our Playwright Firefox QA suite caught downloadable font: download failed console errors when Google Fonts requests were interrupted on reload. Switching to self-hosted @fontsource WOFF2 packages eliminated all third-party network calls and fixed the console error.

Accomplishments that we're proud of

  • 100.0% Recall (30/30 Secrets) Across 12 Real-World & Benchmark HAR Files: After fixing the edge cases discovered in Stage 3.5, HARshield passed 12/12 validation datasets (100.0% secret recall, 0 false positives on clean negative traces, and 78.4 ms processing time on a 768 KB 50-entry browser capture), compared to 26.7% recall for Cloudflare's regex engine and 20.0% for Chrome's header scrubber.
  • Preserving Debugging Signal Without Leaking Secrets: Proving visually and mathematically that JWT_TOKEN_#1 vs JWT_TOKEN_#2 referential aliasing lets engineers spot a 401 Unauthorized token rotation race condition in seconds.
  • 24/24 Real-Browser E2E QA Pass: Verified across Desktop (1440x900) and Mobile (390x844) viewports on both local and deployed builds using headless Firefox with 0 console errors, 0 page errors, and 0 unlabeled controls.

What we learned

  • Never Use Raw-Text Regexes on Container Formats: A .har file is a JSON document whose string fields (postData.text, content.text) contain nested JSON documents, URL-encoded forms, and URLs. Regexes over the outer file text inevitably either miss nested properties or consume escaping quotes and corrupt the container.
  • Real External Data Beats Synthetic Happy Paths: Testing against real recordings from mitmproxy and Netflix/pollyjs immediately revealed schema dialects (such as array-typed header values and float millisecond timings) that synthetic unit tests alone would never catch.

What's next for HARshield Workbench

  • In-Browser Gunzip for Polly.JS _isBinary: true Hex Arrays: Supporting automatic DecompressionStream('gzip') unpacking for Node.js Polly.JS recordings that store compressed hex chunks inside response.content.text.
  • WebSocket Frame (_webSocketMessages) Inspection: Extending recursive JSON and token lineage sanitization to HAR WebSocket message frames.
  • Browser DevTools Extension Packaging: Packaging the HARshield AST engine as a zero-permission Chrome/Firefox DevTools panel extension.

Built With

Share this project:

Updates

Submission history