# Research browser

Each vault can have a browser of its own for testing: a Chrome, Chromium
or Edge already on your machine, started by Phantom with a dedicated
profile and its traffic sent through Phantom's proxy. Nothing to
configure in the browser and no CA to install in the system.

## Opening it

1. On the Proxy page, start capturing into the vault.
2. **Browser** in the Proxy header → **Open research browser**.

The browser opens on `http://phantom/`, where the CA check shows that it
accepts Phantom's certificates. Everything it loads goes through the
proxy into the vault's history, including `localhost` and `127.0.0.1`
labs (Chrome's usual proxy bypass for loopback is turned off), so the
vault's scope, capture filter, intercept and the emergency stop apply as
to any other traffic.

**Close research browser** ends it; **Delete its profile** removes the
profile directory (cookies, history, cache) once it is closed. Phantom
closes every browser it opened when it stops.

## What makes it different from your everyday browser

| | |
|---|---|
| Profile | One directory per vault under `~/.phantom/browser` (`PHANTOM_BROWSER_DIR`), never your everyday profile; two vaults never share cookies |
| Proxy | `--proxy-server` points at Phantom's listener, loopback included |
| Certificates | Phantom's per-host certificates share one key; the browser accepts exactly that key (`--ignore-certificate-errors-spki-list`), nothing else. Upstream certificates are still checked by the proxy |
| DevTools | Bound to `127.0.0.1` on a port picked at launch, never reported by the API |
| Background traffic | Sync, component updates, field trials and similar are off, so the history holds what you did |

The browser behaves as itself: Phantom does not disguise it or change
its fingerprint (see `design/browser-audit`).

## Which browser

Phantom uses, in order: `PHANTOM_BROWSER` (a path), a Chrome, Chromium
or Edge on the PATH or in its usual install location, then a Chromium
that Playwright downloaded. On Linux a desktop display is needed
(`DISPLAY` or `WAYLAND_DISPLAY`); `BROWSER_HEADLESS=true` runs without a
window, for servers and tests.

## Tabs, screenshots and evidence

While the browser is open, the **Browser** menu in the Proxy header lists
its tabs: each with its title, its host and how many exchanges of that
host the vault captured. A tab whose page the proxy captured opens that
request in History. Its submenu also takes a screenshot of what the tab
shows now:

- **Screenshot to Files** stores a PNG named
  `browser-<host>-<time>.png` in the vault's files.
- **Screenshot as evidence of…** stores it the same way, attaches it to
  the finding you pick, and links the page's captured request to that
  finding too, so the picture and the exchange behind it stay together.

The page's request is the latest captured `GET` of exactly the tab's
address; a page not captured yet (opened before capture started, or
served from the browser's cache) is attached without a request.

## Blocking other destinations

Turn on **Block out of scope** in the Intercept toolbar and the proxy
refuses every request to a host outside the vault's scope, so the
browser cannot reach them at all (see
[Intercept](./proxy/protocols.md#intercept)). To review a request with
an external effect before it leaves, add an intercept rule that holds
it.

## REST

| Route | Does |
|---|---|
| `GET /api/v1/browser` | The browser that would be launched, the running research browsers and the vaults with a profile |
| `POST /api/v1/vaults/{id}/browser` | Open the vault's browser (409 unless the proxy captures into this vault) |
| `DELETE /api/v1/vaults/{id}/browser` | Close it |
| `DELETE /api/v1/vaults/{id}/browser/profile` | Delete its profile (409 while it runs) |
| `GET /api/v1/vaults/{id}/browser/pages` | Its open tabs, each with `flow_id` (the latest captured GET of its address) and `host_flows` (409 while it is closed) |
| `POST /api/v1/vaults/{id}/browser/screenshots` | `{page_id, finding_id?, note?}`: screenshot a tab into the vault's files; with `finding_id`, attach it and link the tab's request (404 for a closed tab) |

All of these are the user's: agent tokens are refused.
