# M2 — Research utilities & browser integration

### UTIL — Message and data utilities [P1]

- [x] Decoder: common encodings, text/binary transformations, format detection and reversible transformation history. — Proxy → Decoder, offline in the browser: URL, Base64/Base64url, Base32, hex, HTML entities, Unicode escapes, quoted-printable, gzip/zlib/raw deflate, JSON, text and hash steps on bytes; suggested next steps; undo/redo; memory only (`c065479`, `docs/guides/decoder.md`, `decoderCodecs.spec.ts`, `decoderChain.spec.ts`).
- [x] Comparer: text, bytes, headers and structured JSON differences with side-by-side and unified views. — *Progress:* side-by-side text diff with inline character changes, ignored headers, whitespace option, JSON formatting and folding (`bc6787a`, `5a51ca1`, `src/utils/__tests__/diff.spec.ts`); unified view (`-` before `+` per change, hunk headers, folded context, inline marks) and Bytes view (hex + ASCII, 16 bytes a row, differing bytes highlighted, virtualized, credential bytes masked), comparisons kept by the backend (`docs/guides/comparer.md`) (`edfb9b9`). Byte comparison is positional.
- [x] Token Inspector: offline JWT structure inspection, expiry and claim visualization; no secret guessing or automatic credential acquisition. — Token tab of the Decoder: live validity countdown, registered claims explained, header and unverified signature, notes for `alg: none`, HS* and key references (never fetched), JWE header only (`c065479`, `decoderJwt.spec.ts`).
- [x] Randomness Analyzer (Sequencer-style): statistical evaluation of authorized sample sets, confidence and clear interpretation limitations. — Sequencer tool in Proxy: tokens from a cookie, a response header or a body pattern over the flows a history search finds (vault-scoped, `http_evidence.read` for agents) or pasted; effective bits by position capped by sample size, duplicates, FIPS 140-2 tests where the alphabet encodes whole bits, a verdict that never exceeds what the sample supports, and stated limitations; statistics only, never the tokens (`app/core/sequencer/`, `test_sequencer_stats.py`, `test_sequencer_api.py`, `docs/guides/sequencer.md`).
- [x] HTTP Logger: distinguish tool-generated requests, browser traffic and scan activity by source. — Every flow records its source and history filters on it (`source:browser`, `source:repeater`, `source:intruder`, `source:import`, `source:scan`, `test_history_search.py`); scans can keep the requests they send in history with source `scan` (`http.record_history`, up to 5,000 per scan, blocked requests left in the scan log; migration `d7a2b9c5e4f6`, `test_scan_history.py`).
- [x] Request collections: organize, name, export and import reusable authorized request definitions. — Collections tool in Proxy: vault-owned collections of request definitions (raw request, target, send settings, note) saved from a Repeater tab and opened as new Repeater tabs, so every send passes scope, the engagement rules and the emergency stop; rename, reorder, remove with row menus; `phantom.collection/1` JSON export and import that always creates a new collection; agents read masked and add definitions, masked text refused (migration `d4f8b2c6e1a7`, `test_collections.py`, `docs/guides/collections.md`).
- [x] Payload library: reusable payload collections shared by Intruder, Repeater, signatures and every message viewer. — *Progress (`5e60241`):* backend done: global and vault collections with create, rename, duplicate, archive, delete, categories, tags and search (`test_payload_api.py`); import preview and TXT/CSV/JSON import with configurable and escaped separators, encoding detection and explicit trim, drop-empty and dedupe options (`test_payload_parsing.py`, `test_payload_transfer.py`); per-item provenance including flow selections, batch edit, bulk delete by ids and ranges, cursor pages over 20,000 items, resource limits and vault isolation (`test_payload_isolation.py`); TXT/JSON/CSV export; MCP tools with redaction (`test_mcp_payloads.py`). Interface (`65054d0`): library page, list editor, import panel and "Add to payloads" in every message viewer. Shared use: Intruder payload sets read collections; editable messages (the Repeater request) replace a selection with a payload; signatures refer to `collection:<id>`, resolved per scan to the vault's own and global collections and skipped when unreachable (`test_signature_payload_refs.py`). Collection tags stay a string list: the shared Tag model is per vault, and global collections belong to none.
- [x] Intruder workspace: review existing bounded parameter-test capability, results presentation, pause/cancel, resource quotas and authorization controls; enable only after policy and rate-limit tests pass. — *Progress (`b17a509`):* backend done (`docs/guides/intruder.md`): vault-owned attacks from a template or a history flow with `§` positions, escaping and auto-mark suggestions (`test_intruder_template.py`); sniper, battering ram, pitchfork and cluster bomb as lazy generators with exact totals (`test_intruder_strategies.py`); collection, inline, number and null sources with processing steps and bounded-regex matchers (`test_intruder_processing.py`, `test_intruder_payloads.py`); executor with bounded concurrency, token-bucket rate limits (per attack and global), jitter, timeouts, retries on network errors only, per-request scope and Host checks, the upstream TLS policy and capture body limits (`test_intruder_executor.py` against a local server); pause, resume, cancel, quotas, restart leaves attacks paused (`test_intruder_control.py`); keyset result pages with sort and filters, detail, save to history, CSV/JSON lines export under the export policy (`test_intruder_results.py`); vault isolation (`test_intruder_isolation.py`); 8 MCP tools with agent quotas, the user-only `intruder.agents` preview mode, the workstation guard and redaction (`test_mcp_intruder.py`). Interface (`f6748ac`): Intruder workspace in Proxy with the template editor and § marking, payload sets, processing, matchers, options, live estimate, results table with filters and detail, pause, resume and cancel.

### BROWSER — Botonomus integration [P1]

- [x] Audit the current Botonomus code and licensing before reusing it. — `docs/design/browser-audit.md`: Botonomus 0.4.1 (`3f0cbe9`) is MIT with permissive runtime dependencies; the CDP client is adopted and the launcher and profile store adapted, while the stealth parts (patched-Chromium personas, human input timing, profile warm-up) and the patched-Chromium installer stay out, with the security conditions for what is reused.
- [x] Define a browser adapter with explicit user-granted sessions and permitted origins. — The research browser is opened, closed and deleted by the user only (agent tokens refused) and only while the proxy captures into its vault; strict scope (`block_out_of_scope`) keeps it, and any client, to the vault's permitted origins by refusing every other host at the proxy (`app/runtime/browser.py`, `test_research_browser.py`, `test_proxy_strict_scope.py`).
- [x] Launch a dedicated research browser profile with the selected Phantom proxy configuration. — A system Chrome, Chromium or Edge with a profile of its own, `--proxy-server` at Phantom's listener (loopback included), Phantom's certificates accepted by their key pin, DevTools on loopback and Chrome's background traffic off; a real launch is tested to land its page load in the vault's history (`app/core/browser/launch.py`, `test_research_browser.py`, `docs/guides/research-browser.md`).
- [x] Provide optional isolated browser contexts per vault and clear session ownership. — One browser and one profile directory per vault, never shared and never the user's everyday profile; the status lists which vault owns each running browser.
- [x] Link observed navigation, network activity, screenshots and user-selected evidence to research records. — The Browser menu lists the open tabs (DevTools on loopback) with the latest captured GET of each address and its host's exchange count, opening that request in History; a screenshot of a tab goes to the vault's files and, picked as evidence of a finding, is attached to it with the tab's captured request linked (`app/core/browser/cdp.py`, `app/services/browser_evidence.py`, `test_browser_evidence.py`).
- [x] Handle disconnect/reconnect, cleanup, profile deletion and certificate lifecycle. — A closed or crashed browser is dropped from the running list and can be opened again; Phantom closes the browsers it opened when it stops; the profile is deleted on request while closed; per-host certificates share one persisted key whose pin the browser trusts, so no CA is installed or left behind (`test_proxy_certs.py`).
- [x] Support manual user interaction and review of browser activity; do not access unrelated profiles by default. — The researcher drives the visible browser; its traffic is reviewed in History like any capture; only the vault's dedicated profile directory is used, and Botonomus's profile warm-up is deliberately not carried over (`docs/design/browser-audit.md`).
- [x] Block unauthorized destinations and require review for actions with external effects. — Strict scope refuses requests, WebSocket upgrades and CONNECT tunnels to hosts outside the capture vault's scope (403, nothing sent or recorded); intercept rules hold chosen requests (for example every `POST`, `PUT` or `DELETE`) for review before they leave (`app/core/proxy/handler/proxy_handler.py`, `test_proxy_strict_scope.py`, `test_proxy_intercept_rules.py`).

### SESSION — Authenticated research [P1]

- [x] Per-vault session profiles, user-provided test accounts and scoped cookie jars. — Test accounts per vault with headers and a cookie jar scoped by domain (host-only or with subdomains) and path, encrypted with the configuration key and never returned (migration `f6b1d4e8a3c5`, `test_session_profiles.py`, `test_session_profile_apply.py`, `docs/guides/session-profiles.md`); Repeater tabs send as an account.
- [x] Session expiry detection and visible authentication health. — Each account has a check request; Check now records Working, Expired (401/403) or Failing with the time, and a Repeater send as an account that meets 401/403 marks it Expired; health shows on the vault page and to agents (`session_profile_check`).
- [x] User-approved login/refresh workflows with secrets stored by reference. — Each account has a login recipe: steps referring to secrets by name (values encrypted, never returned; values typed into a step are turned into references), values taken from answers (header, JSON field, regex), cookies kept in the jar, headers rebuilt from templates; only the user saves or runs it, and a scheduled refresh starts only after the user ran it and pauses when a run fails (`app/services/session_login.py`, `app/services/session_refresh.py`, `test_session_login.py`).
- [x] Multiple authorized test identities with clear isolation and role labels. — Up to 50 accounts per vault, isolated by vault, each with a role label stored on the flows it sends and on proxy traffic captured under a session label (`label:` search, `test_session_label.py`).
- [x] Record reusable session steps without capturing plaintext credentials in project artifacts. — Recipe steps are drafted from captured requests with cookies dropped and credential fields (username, email, password, OTP…) and `Authorization` lifted into the encrypted secrets; every recipe run is recorded in History with each secret value (plain, URL-encoded, JSON-escaped) replaced by its reference before it is written (`app/core/sessions/login.py`, `test_session_login.py`).
- [x] Detect authentication failures and stop or request user intervention instead of retrying indefinitely. — A Repeater send that meets 401/403 marks its account Expired for the user to renew; an Intruder attack pauses with the reason after `auth_failures` answers in a row of 401/407/419/440 (default 20, the rest waits to resume); a scan given a session in its headers stops with the reason after 25 such answers (`app/runtime/intruder/run.py`, `app/engines/http.py`, `test_intruder_executor.py`, `test_scan_session.py`).

**Exit gate:** Manual workflows operate reliably with controlled authenticated test applications; browser and session data never leak across vaults or into external AI services without consent.
