# Research browser: Botonomus audit

Before any of Botonomus is reused for Phantom's research browser
(roadmap M2, BROWSER), this audit records what the code is, under which
terms it can be used, and which parts fit a browser whose job is to let
the user test, with their authorization, the applications in a vault's
scope.

Audited: Botonomus 0.4.1 (`3f0cbe9`, "Keep the Client browser profile
between runs"), about 13,600 lines of Python in `src/botonomus`.

## Licence

- MIT, copyright "Botonomus contributors"; the project is maintained by
  Phantom's owner.
- MIT allows copying and changing the code inside Phantom under its own
  licence, on one condition: the MIT notice travels with any substantial
  part that is copied. Vendored files keep their header and the notice
  goes into `THIRD_PARTY_NOTICES.md`.
- Runtime dependencies: `filelock`, `psutil` and, on Windows, `tzdata`,
  all permissively licensed and already common in Python tooling.
  Optional: `playwright`, `patchright` (Apache-2.0) and `curl_cffi`
  (MIT). None is needed for the parts recommended below.

## What it contains

| Package | Lines | What it does | For Phantom |
|---|---:|---|---|
| `browser` | ~2,000 | Finds or installs a Chrome build, builds the command line (`--user-data-dir`, `--remote-debugging-port` on `127.0.0.1` with a free port, `--proxy-server`), starts and watches the process | **Adapt.** Launching a dedicated profile with Phantom's proxy and a loopback-only debugging port is what M2 needs. The installer of Botonomus's own patched Chromium is left out (see below). |
| `cdp` | ~1,800 | A native Chrome DevTools Protocol client over a WebSocket that refuses anything but loopback, with page, input and locator helpers | **Adopt.** Observing navigation and network events and taking screenshots for evidence needs exactly this, without Playwright. |
| `profiles` | ~500 | Profile directories, a lease so two runs never share one, preferences; `warmup` browses popular sites so a profile looks used | **Adapt** the store and lease (one profile per vault, owned and deletable). **Leave out** warm-up: it visits third-party sites the vault does not cover. |
| `network` | ~1,000 | A loopback SOCKS5 forwarder that adds upstream proxy credentials, tunnels, GeoIP lookup of a proxy's exit | **Not needed.** Phantom's browser talks to Phantom's own proxy on loopback; the forwarder's credential handling is sound but has no use here, and GeoIP calls an outside service. |
| `fingerprint` | ~900 | Persona switches (`--bn-seed`, time zone, hardware concurrency, device memory, GPU strings) read by a patched Chromium to present a chosen device | **Leave out.** |
| `human` | ~1,400 | Human-like mouse paths, typing rhythm and dwell times | **Leave out.** |
| `client` | ~1,600 | An httpx-like client that fetches through the browser | **Not needed.** Phantom sends requests through Repeater, Intruder and replay. |
| `diagnostics` | ~2,700 | Pages that probe what a site can learn about the browser | **Not needed.** |
| `cli`, `config`, `core`, `drivers` | ~2,800 | Command line, settings, shared types, Playwright and Patchright drivers | **Not needed**; the settings validation is a useful reference only. |

## Why the stealth parts stay out

Botonomus is built to look like an ordinary person on an ordinary
device: patched Chromium personas, human input timing, profile warm-up.
Phantom's browser has the opposite purpose. It is the researcher's own,
visible instrument against applications they are authorized to test,
and it should behave predictably and be recognisable in the program's
logs, not disguise itself or defeat the program's bot detection. The
roadmap also asks the browser not to touch unrelated profiles or
destinations; warm-up visits exactly those. So `fingerprint`, `human`,
`profiles/warmup` and the patched-Chromium installer are not carried
over, and nothing in Phantom will depend on the patched build.

## Security notes for the parts that are reused

- The debugging port binds `127.0.0.1` with a port picked free at
  launch, and the CDP client refuses non-loopback URLs. Keep both: any
  process that reaches the port controls the browser. Phantom should
  additionally keep the port out of any API response and agent output.
- Launch with a dedicated `--user-data-dir` under Phantom's data
  directory, per vault, never the user's everyday profile; deleting the
  vault's browser deletes that directory.
- Point `--proxy-server` at Phantom's proxy on loopback, so every request
  is scope-checked, captured and stopped by the emergency stop like any
  other traffic. The proxy CA is trusted by that profile only.
- Treat page content read over CDP as untrusted data (titles, DOM text,
  console messages) wherever it reaches an agent.

## Plan

1. Vendor `cdp` with its MIT header and add the notice to
   `THIRD_PARTY_NOTICES.md`.
2. Write Phantom's launcher from `browser/arguments.py` and
   `browser/process.py`: system Chrome or Chromium, dedicated profile per
   vault, Phantom's proxy, loopback debugging port.
3. Build the profile store on `profiles/store.py` and `lease.py`.
4. Link navigation, network events and screenshots to the vault
   (M2 BROWSER items 4 to 8).
