DEV Community

Jason Y. (dev_in_the_fog)
Jason Y. (dev_in_the_fog)

Posted on

Why Chrome's 'Sanitized HAR' Export Still Leaks API Keys, Query Tokens & GraphQL Variables

Starting in Chrome 130, clicking Export HAR (sanitized)... in the DevTools Network panel automatically strips Cookie, Set-Cookie, and Authorization headers. That default saved plenty of engineers from accidentally attaching live session cookies to Jira tickets or vendor support emails.

However, if you open an exported .har file in a text editor before sending it out, four credential surfaces still remain in plain text.

What Chrome's Built-In HAR Sanitizer Misses

HAR 1.2 is a full JSON snapshot of log.entries[]. Chrome's default scrubber only inspects standard auth header names, leaving these intact:

  1. Custom API & CSRF Headers (request.headers)
    Internal services and B2B gateways routinely pass X-API-Key, X-Auth-Token, X-CSRF-Token, or X-Amz-Security-Token. None of those match Authorization or Cookie.

  2. URL Query Strings (request.url & request.queryString)
    Presigned S3 download URLs (?X-Amz-Signature=...), WebSocket handshake tickets (wss://.../realtime?token=...), and OAuth redirect callbacks (?code=...) stay untouched in both request.url and the parsed queryString array.

  3. Request Bodies & GraphQL Variables (request.postData.text)
    If the user logged in, refreshed a token, or submitted a form while recording, postData.text stores the raw JSON string—including password, refresh_token, or client_secret inside GraphQL variables.

  4. Response Payloads (response.content.text)
    When /auth/refresh or /oauth/token responds with 200 OK, the newly issued access_token and id_token sit directly inside response.content.text.

Quick jq Scrub Before Sharing

If you just need a fast terminal one-liner before attaching a capture to an issue:

jq '
  .log.entries[].request.headers |= map(
    if (.name | test("^(cookie|authorization|x-api-key|x-auth-token|x-csrf-token|x-amz-security-token)$"; "i"))
    then .value = "[REDACTED]" else . end
  )
  | .log.entries[].response.headers |= map(
    if (.name | test("^(set-cookie)$"; "i"))
    then .value = "[REDACTED]" else . end
  )
  | .log.entries[].request.cookies = []
  | .log.entries[].response.cookies = []
' session.har > session.clean.har
Enter fullscreen mode Exit fullscreen mode

Notice that jq alone won't parse nested JSON strings inside request.postData.text or rewrite ?token=... inside request.url unless you chain fromjson / tojson.

Zero-Dependency CLI (har-redact) & Browser Waterfall

To scrub all four surfaces (headers, query parameters, nested JSON postData / response.content.text, and embedded JWTs) while keeping timings (dns, ssl, wait, receive) and payload byte sizes intact for latency debugging:

Because a raw HAR file is sensitive by definition, the browser analyzer runs entirely inside tab RAM (FileReader -> local waterfall timeline + redactor) without sending any network request. You can keep DevTools -> Network open while dropping a .har file in to verify zero outbound traffic.

If you also inspect internal data snapshots or query plans under similar zero-upload rules, the same local-only approach powers our Apache Parquet Viewer and PostgreSQL EXPLAIN Flamegraph Visualizer.

Top comments (0)