skip to content

In Chrome DevTools, what sensitive data travels with an exported HAR file versus a request copied as cURL or fetch?

level: middleimportance: should knowfreq 33%

answer

  1. sanitized by default, for three headers
  2. what sanitizing does not touch
  3. a setting unlocks the raw export
  4. Copy has no sanitized form
  5. the active filter narrows the export

basics

~20 s

A default HAR export is sanitized: Cookie, Set-Cookie and Authorization headers are removed, yet URLs, bodies and custom token headers stay. Copy as cURL is not sanitized and carries the session cookie and Authorization in clear text.

solid answer

~40 s

A HAR is a JSON archive of the listed requests. The Network panel's default is `Export HAR (sanitized)…`, which leaves out the `Cookie`, `Set-Cookie` and `Authorization` headers; a raw `Export HAR (with sensitive data)…` appears only after enabling **Allow to generate HAR with sensitive data** in Settings. Sanitizing names only those three, so tokens in query strings, custom headers like `X-Api-Key`, and request and response bodies still travel. The copy-as commands have no sanitized form: **Copy as cURL** writes the cookie with `-b` and keeps `Authorization`. **Copy as fetch** drops `Cookie` and sets `credentials: "include"`, but still keeps `Authorization`, while the Node.js variant puts the cookie back in its headers. So I filter down first, send the smallest thing that works, and treat any of them as a credential.

code

javascript · 11 lines
javascript
// Shape of Copy as fetch for a request that had a session cookie and a bearer token
fetch("https://api.example.com/v1/orders/42", {
  "headers": {
    "accept": "application/json",
    "authorization": "Bearer <token>"
  },
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "include"
});

go deeper

for a junior

Recall that a HAR is a file of many requests, that Chrome DevTools sanitizes it by default, and that a copied cURL command can contain your live session.

for a middle

Explain the exact scope: three headers removed from a HAR, and everything else kept. Describe how the three Copy commands differ on Cookie and Authorization, and why browser fetch uses a credentials option.

for a senior

Show the habit of narrowing the filter before exporting, using a throwaway account, reading the JSON before sending, and revoking a session that leaked. Name query strings and bodies as what sanitizing misses.

for a principal

Weigh support convenience against data exposure: a process that asks users for HAR files collects credentials and personal data into ticket systems, so it needs retention rules and a safer default request.

## Two ways to hand over a request When a request fails and someone else has to look at it, the Chrome DevTools Network panel offers two kinds of evidence: - **A HAR file** (HTTP Archive) is a JSON document describing many requests: URLs, headers, timings, and bodies. A colleague can open it in their own Network panel with **Import HAR file…** or by dropping it on the request list. - **A Copy command** is a single request rewritten as something runnable: `Copy as cURL`, `Copy as fetch`, `Copy as fetch (Node.js)` or `Copy as PowerShell`. Both are convenient, and both can carry a logged-in user's credentials. They do not handle secrets the same way, which is why the question gets asked. ## What HAR sanitizing does Current Chrome DevTools sanitizes HAR output by default. The toolbar button is `Export HAR (sanitized)…`, and the Copy submenu offers `Copy all as HAR (sanitized)`. The setting's own description states the scope: generated HAR logs "don’t include `Cookie`, `Set-Cookie`, or `Authorization` HTTP headers". To get the raw form, enable **Allow to generate HAR with sensitive data** in Settings. That adds `Export HAR (with sensitive data)…` and `Copy all as HAR (with sensitive data)`, and it should stay off unless you have a specific reason. The mistake is hearing "sanitized" and assuming "safe to share". Sanitizing is a named list of three headers, and it does not inspect anything else. These all remain: - **URLs and query strings**, including any `?token=` or signed link - **Custom credential headers** such as `X-Api-Key` - **Request bodies**, which may hold passwords from a login form - **Response bodies**, which may hold personal data or tokens returned at login ## What the Copy commands carry The Copy commands are built for reproducing a request, so they keep what is needed to make it work. | Command | `Cookie` | `Authorization` | Notes | |---|---|---|---| | **Copy as cURL** | Written with `-b` | Kept with `-H` | Runs anywhere; the most portable secret | | **Copy as fetch** | Header dropped | Kept in `headers` | Sets `credentials` to `"include"` when the original carried credentials | | **Copy as fetch (Node.js)** | Put in `headers` | Kept in `headers` | Meant to run outside a browser | The browser `fetch` form drops `Cookie` because a page cannot set that header itself; the browser adds cookies from its own store. For a cookie session it therefore works only where that session already exists, such as the same site's Console. **Edit and resend as fetch** goes one step further and pastes the call into the Console with browser-managed headers commented out, ready to change and run. A related control is **Resend**, in the same right-click menu, which replays the request as it is without creating anything you could leak. ## What gets included in a HAR Two details change how much a file exposes: 1. **The active filter applies.** Export uses the requests that pass the current filter, which is why the Copy labels switch to `Copy all listed as HAR` when a filter is on. Older documentation says you cannot filter an export; current DevTools code does. Narrowing to `domain:api.example.com` before exporting removes a lot of unrelated data. 2. **Only finished HTTP requests are written**, with exceptions for a WebSocket that got a response and an EventSource that received messages. A call still pending at export time is left out, so wait for the failure to complete. ## How to share one safely - **Choose the smallest form that answers the question.** One `Copy as cURL` for a backend colleague; a filtered HAR when timing or sequence matters. - **Reproduce with a throwaway account** when you can, so the credentials in the file are worth nothing. - **Read the file before sending it.** It is plain JSON, so search it for tokens, emails and your API key's header. - **Remove your own secrets from a copied command**, or replace them, before posting it in a ticket or a chat channel. - **Log out or revoke the session afterwards** if a raw credential did travel, because a cookie in a cURL command stays valid until the session ends. Nothing here is specific to attackers. A ticket system, a chat history or a shared drive keeps these files for years, and whoever reads them later gets the same access the original user had.

  • Why does Copy as fetch drop the Cookie header but keep Authorization?
    `Cookie` is on the list of headers a page may not set, since the browser manages it from its own cookie store, so the generated call uses `credentials: "include"` instead. `Authorization` is an ordinary header that a page can set, so it stays in `headers` and its value travels with the copied text.
  • When is a HAR the better thing to send than one Copy as cURL command?
    When the question is about sequence or timing across requests. A HAR keeps the timing breakdown and initiators, and it opens in the recipient's Network panel, whereas a cURL command reproduces only one request from the recipient's own network. For a single rejected call, the command is smaller and exposes less.

  • Says a sanitized HAR is safe to post anywhere because the secrets were removed.
  • Believes sanitizing also strips query-string tokens and request bodies.
  • Assumes Copy as cURL hides the cookie the way a sanitized HAR does.
  • Says the raw HAR option is always shown in the export button.
  • Believes a HAR export always ignores the Network panel's active filter.