Skip to content

Access token ​

Phantom is a workstation: by default the API, the interface and the proxy listen on 127.0.0.1 only, and nothing asks you to sign in. When you deliberately make it reachable from other machines (a lab VM, a second laptop), set an access token first. Without one, anyone who can reach the address could drive the workstation: read captured traffic, send requests, start scans.

Turning it on ​

Set PHANTOM_ACCESS_TOKEN to a long random secret before starting Phantom. The launcher refuses a non-loopback --host without it:

PHANTOM_ACCESS_TOKEN=<a long random secret> python run.py --host 0.0.0.0

With a token set, every request to the REST API and the realtime socket must prove it knows the token. The interface shows a sign-in screen; after a correct token the backend sets a session cookie (HttpOnly, SameSite=Strict, Secure over HTTPS) and the page reloads into Phantom. Scripts send Authorization: Bearer <token> instead.

  • The cookie holds an HMAC of the token, not the token, and changing the token signs every browser out.
  • Ten failed sign-ins from one address within ten minutes are refused with 429 until the window passes.
  • The health check (/api/v1/system/health) and the sign-in routes stay open. /mcp keeps its own authentication: agents use their personal access tokens as before.
  • A refused request answers 401 with the code login_required; a refused socket closes with 4401. The interface returns to the sign-in screen when its session ends.

Routes ​

RouteDoes
GET /api/v1/access/session{required, signed_in}: whether a token is configured and this browser holds a session
POST /api/v1/access/session{"token": "..."}: sign in and set the session cookie; 401 invalid_token, 429 too_many_attempts
DELETE /api/v1/access/sessionForget this browser's session cookie

What it is not ​

The token is one shared secret for the workstation, not user accounts: everyone who knows it has the same full access. Serve Phantom over HTTPS (a reverse proxy) when the network between you and it is not trusted, since the token and the cookie would otherwise travel in the clear. The intercepting proxy has its own password for exposed addresses (guides/proxy/protocols).