# Threat model

What Phantom protects, from whom, and what it does not try to protect
against. Reporting a problem: see `SECURITY.md` at the repository root.

## The supported deployment

One researcher on their own machine. The backend and the interface run
locally (`run.py`) or in Docker, bound to loopback by default. The
researcher uses the interface in their browser, points a separate
browser profile at the proxy, and may connect AI agents through MCP or
the Agent Bridge, or let Phantom call a model provider.

Not supported: several people sharing one installation, an API reachable
from a network, or Phantom running on a machine the researcher does not
control.

## What is worth protecting

- **Captured secrets.** Cookies, tokens and credentials in requests,
  responses, notes and files.
- **Research data.** Vaults, findings, reports, files and notes, and the
  separation between vaults (often different clients or programs).
- **Authority.** The ability to send traffic to targets, which must stay
  inside each vault's scope.
- **Tokens and keys.** Agent tokens, provider API keys, the interception
  CA key.

## Who can reach Phantom, and the guarantees

| Actor | Can | Guarantees |
|---|---|---|
| The researcher, in the interface | Everything | None needed; the interface is the user |
| A web page in the same browser | Make the browser send requests to loopback | Unsafe requests from another origin, or marked cross-site, are refused; Host headers outside the allowed list are refused (DNS rebinding); CORS keeps responses unreadable |
| A connected agent (MCP or Bridge) | Call tools with its token | Each call is checked against the token's grants and vaults in the service; secrets are masked under the MCP redaction policy unless the user allows revealing them and the token holds `sensitive.read`; user-only actions (policies, purges, finalising reports, setup, diagnostics) are refused; requests the agent chooses stay in scope and never reach Phantom's own API or MCP endpoint on this machine |
| A model provider Phantom calls | Receive what is shared with it, return text and tool calls | Only the references the user shares are sent, redacted; tool calls go through the same grants, with approval for destructive and open-world ones |
| Targets and captured traffic | Put any bytes in responses, files and notes | Content is data, never instructions; it is shown escaped or sandboxed, never served as active markup from Phantom's origin; executables are quarantined |
| A file or note | Carry text that looks like instructions | Wrapped as untrusted reference material for agents; cannot grant or widen access |
| A network peer of the proxy | Connect to the proxy port | The proxy binds loopback by default and answers requests aimed at itself instead of forwarding them |

## What Phantom does not protect against

- **Code running as the user on the same machine.** The REST API has no
  login: on loopback it trusts every local process, which could also read
  the database and the CA key directly. Agents connect through their
  own tokens and are bound by grants, but a local process does not have
  to use them.
- **An API exposed to a network.** Docker publishes the interface on
  loopback only, and the launcher refuses another address unless an
  access token is set ([Access token](./access.md)). The token is one
  shared secret, not user accounts: everyone who knows it has the user's
  full authority, and without HTTPS it travels in the clear. Starting the
  API another way (uvicorn directly) on an open address without a token
  is not guarded. Phantom is not meant to be deployed on a server.
- **A compromised browser profile.** Use a separate profile for traffic
  under test, as the proxy guides say.
- **Secrets the user chose to reveal.** Revealing to agents and exports
  that keep secrets are explicit user decisions.

## Where the guarantees are checked

- Origin, Sec-Fetch-Site and Host guards: `app/api/security.py`,
  `app/api/trusted_hosts.py`.
- Agent grants and vaults: `app/core/agents/`, enforced in services
  through `require(...)`; tests in `test_agent_permissions.py` and the
  per-module `test_*_isolation.py` suites.
- Agent request guard: `app/mcp/guards.py`; tests in
  `test_mcp_capture.py`, `test_flow_delete.py`, `test_mcp_intruder.py`.
- Redaction: `app/core/redaction/`; tests in `test_redaction*.py` and
  `test_mcp_redaction.py`.
- File storage: `app/core/files/`; tests in `test_files_safety.py`.
- Scope: `app/core/scope.py` and `scope_patterns.py`, checked on every send; tests in
  `test_scope.py`, `test_scope_patterns.py`, `test_rescope.py`.
