✨ New Release: PDF Redactor is live! True redaction & metadata removal with zero server uploads.
PrivateTools
Back to blog

I Almost Leaked My Production Tokens in a HAR File — Here's the Fix (100% Local)

Accidentally sharing HAR files can leak production tokens. Learn how to sanitize and redact sensitive network logs 100% locally in your browser with zero uploads.

I Almost Leaked My Production Tokens in a HAR File — Here's the Fix (100% Local)

The mistake that almost cost me a security incident

Last week a user reported a bug. Classic "can you send me a HAR file?" moment. I opened DevTools, hit the Network tab, right-clicked, Export HAR, and dragged the file into the support ticket.

Then my stomach dropped.

I'd just sent a plain-text file containing:

  • My user's session cookie
  • A live Bearer JWT
  • The password field from a login POST body
  • An x-api-key sitting in a query param

All of it, in cleartext, to a third party. And honestly? I'm not even mad at myself — HAR files are designed to capture everything, including the secrets.

If you've ever exported a HAR for AWS, Zendesk, Stripe, or Shopify support, you've probably done the exact same thing.

What's actually inside a HAR file?

A HAR (HTTP Archive) is just a JSON log of every network request your browser made. Which means it logs every header, every cookie, and every request/response body.

Run this on a HAR you exported and brace yourself:

grep -iE "(authorization|cookie|token|password|api[_-]?key)" my.har

A real HAR file exposing a Bearer token and API key in plain text.

You will find secrets. Guaranteed.

Cloudflare noticed this too — they literally built their own HAR sanitizer after the Okta breach. And vendors like Spectro Cloud now warn in their docs: don't paste your HAR into random online tools — because those tools upload your file to their server, which is the exact leak you're trying to avoid.

The obvious fixes all suck

  1. Manual find-and-replace in VS Code → takes 10 minutes, you miss things, you panic.
  2. A regex / jq one-liner → works, but you need to remember the syntax and it breaks on nested JSON bodies.
  3. "Free online HAR sanitizer" → congratulations, you just uploaded your production secrets to a stranger's server. 🎉

Here's the core logic if you want to DIY it in 30 seconds:

const SENSITIVE = new Set(["authorization", "cookie", "set-cookie", "x-api-key"]);

har.log.entries.forEach(entry => {
  [...entry.request.headers, ...entry.response.headers].forEach(h => {
    if (SENSITIVE.has(h.name.toLowerCase())) h.value = "***REDACTED***";
  });
});

But that only handles headers. It misses JWTs buried in URLs, passwords inside POST bodies, and the 40 other places secrets hide.

So I built the thing I wanted

I made a HAR File Sanitizer that runs 100% inside your browser. No uploads. No server. No "we don't store your data" fine print. You can literally open DevTools → Network tab and watch: 0 bytes sent.

DevTools Network tab proving the file is processed 100% locally with zero server uploads.

It redacts:

  • 🔑 Auth headers (Authorization, X-Api-Key, etc.)
  • 🍪 Cookies (both Cookie and Set-Cookie)
  • 🔗 Secrets in URLs & query params (?token=, ?api_key=)
  • 🧨 Known token shapes — JWTs, AWS keys, Stripe keys, GitHub tokens, PEM private keys

📦 Passwords & PII inside JSON POST bodies and response bodies

And the part I'm most happy with: it shows you a GitHub-style diff of exactly what it redacted, line by line, before you download the file. No blind trust. You see every change.

The interactive diff view lets you verify exactly what is being redacted before you download the safe file.

Try it here: HAR File Sanitizer & Redactor (100% free, runs locally in your browser).

The lesson

Treat every HAR file like a password manager dump. Because it is.

If you've been exporting HARs for support tickets, please sanitize them first. Your users' sessions are in there, even if you didn't mean to send them.