# Incident runbook

What to do when something goes wrong, and how to check in advance that
recovery works.

## Stop testing at once

**Emergency stop** (**Stop all active work** in the command palette,
Ctrl K, or `POST /api/v1/system/halt`) cancels running and queued scans, pauses
Intruder attacks and refuses every new active request until you resume.
Capture of your own browser traffic goes on. Agents cannot stop or
resume.

## Revoke access

| Situation | Do |
|---|---|
| An agent token may be exposed | Settings › AI & Agents › Access: revoke the token; its running attacks pause and its scans are cancelled |
| A model provider key may be exposed | rotate it at the provider, then replace it in Settings › AI & Agents |
| The access token may be exposed | set a new `PHANTOM_ACCESS_TOKEN` and restart Phantom (every session signs in again) |
| A webhook secret may be exposed | Settings › Integrations: New secret |
| A plugin misbehaves | Settings › Plugins: Disable, then Uninstall |
| The configuration key may be exposed | rotate every stored secret above; the key protects them |

Then check the [audit trail](./audit.md): what the token or agent did,
and **Verify now** to confirm the trail itself was not changed.

## Back up and verify

- `run.py` (SQLite): `python -m scripts.backup create` and
  `python -m scripts.backup verify <archive>` ([Backup](./backup.md)).
- Docker Compose (PostgreSQL): `pg_dump` of the database, with the
  `files` and `keys` volumes copied alongside it.

Copy archives off the machine; an archive holds the configuration key,
so store it as carefully as the key itself.

## Recovery drill

Run this every few months, and after changing how you run Phantom:

1. Take a backup and verify it (`python -m scripts.backup verify`).
2. On a spare machine (or a local VM), set Phantom up as in
   [Getting started](../getting-started.md) without starting it.
3. Copy the archive over, `python -m scripts.backup restore` it, then
   start Phantom.
4. Open the interface.
5. Check: vault count and names, the newest finding, a note, a report
   export, that a stored provider key still works (it needs the restored
   configuration key), and **Verify now** on the audit trail.
6. Write down how long it took and anything that was missing, then
   remove the spare machine's copy.

A drill that cannot complete step 5 is the incident you want to find
before a real one.
