# Bug bounty programs

The Programs page (**G B**) connects your researcher account on a bug
bounty platform and lists the programs that account can see. You can
read a program's rules and scope, follow how the scope changes, and
create a vault from it. Phantom only reads through the platform's
official researcher API. It never writes to the platform and never
submits a report.

A program listing is not permission to test. What you may test is set
by the program's rules and by the vault's scope, and you confirm that
you read the rules before a vault is created.

## Accounts

**Connect an account** asks for the platform, a label and its
credentials:

- **HackerOne**: your API username and an API token (HackerOne
  settings, API Token).
- **Bugcrowd**: a Hacker API token's username and password, created on
  bugcrowd.com/settings/api_credentials. Give it `read:engagement_list`
  and `read:submissions` only; Phantom never asks for a write scope.
  Bugcrowd requires a verified identity for the Hacker API. Bugcrowd
  engagements are listed as programs, their target groups become the
  scope (a group's in-scope state applies to its targets, and a target
  whose state Bugcrowd does not give is kept as not in scope), and your
  submissions sync with Bugcrowd's own states.

Phantom checks the credentials with the platform first and does not
keep a token that is refused. A token that is kept is encrypted with the
configuration key and is never returned by the API or shown again. Each
account shows its status: **Connected**, **Token refused**, **Token
expired**, **Token revoked**, **API disabled for the account**,
**Identity not verified**, **Token lacks a scope**, **Access denied**,
**Unreachable** or **Not checked**. When a call is refused, the
account's status changes to match.

Right click an account (or press Shift+F10) to sync its programs, check
its access, replace its token (the new token is checked first), or
remove it. Removing an account removes its token, programs and
snapshots. Vaults created from its programs stay. You can connect
several accounts, and each keeps its own programs and snapshots.

## Private engagements

A client test, or a program on a platform Phantom cannot read, is kept
by hand: **Add a private engagement** records its name, a link to its
source (contract, ticket or program page), who authorized the testing
with a reference and the dates, its rules as Markdown, and its scope,
typed or read from a file:

- one asset per line, where `#` starts a comment and a line starting
  with `-` (or `out:`) is an exclusion;
- CSV with an `identifier` column, and optionally `in_scope`,
  `asset_type` and `instruction`;
- JSON, a list of assets or of objects with `identifier`, `in_scope`,
  `asset_type`, `bounty` and `instruction`.

The asset type is guessed when not given (wildcard, CIDR range, IP
address, URL or domain). Private engagements live under one local
account, **Private engagements**, and are never sent anywhere. They work
like any program: the scope is a snapshot with differences, the rules
keep their versions, and a vault made from one takes the authorization's
dates as its engagement window. **Edit engagement** in the program
changes any of it; a narrowing scope edit reaches the vault at once, a
widening one waits for **Adopt**.

## Directory

**Sync** reads the programs the account can see, following pages. A
page that is rate limited is retried after the platform's `Retry-After`
(up to three times). When a later page fails, the programs already read
are kept and the sync ends **partial**: nothing is marked no longer
listed, because the list is incomplete. An answer that no longer has the
shape Phantom reads fails with `api_changed`, and values the platform
sends that Phantom does not know (a new program state, say) are noted,
since both are signs that its API changed. **Sync record…** in an
account's menu lists every program sync, scope refresh and report sync
with how it ended, what it found and whether the schedule started it. A program the account no longer lists is kept and
marked **no longer listed**, because closed or lost access must not look
like an empty scope.

Each program keeps its platform identifier, handle, link, raw fields and
fetch time. Its states are kept separate and never folded into one yes
or no:

| State | Values |
|---|---|
| Submissions | open, paused, closed, unknown |
| Visibility | public, private, invited, unknown |
| Rewards | bounty, no bounty, unknown |

The directory is a table, read a page at a time (25, 50 or 100 rows).
Its columns are the program and handle, submissions, rewards, the year
it started accepting reports, your reports (valid of all), what you
earned, the size of its latest scope snapshot, the platform's badges and
the linked vault. Click **Program**, **Since**, **Reports**, **Earned**
or **Scope** to sort, and click again to reverse. Programs without a
value sort last.

| Badge | Meaning |
|---|---|
| SH | Gold standard safe harbor |
| FP | Fast payments |
| OS | Open scope: reports on assets outside the listed scope are considered |
| TR | Triage by the platform is active |

The sidebar has quick views: all programs, watched, with a vault, and
the ones you reported to. Above the table, chips filter by submissions,
rewards, visibility, asset type (programs whose latest scope has that
kind of asset: URL, wildcard domain, CIDR range, mobile app, source
code…), scope (changed this week or month, or a widened scope awaiting
review in its vault) and badges (every checked badge must be present);
**Clear** resets them. **Views** saves the current filters, sort and
search under a name, applies a saved view, pins it to the top or
deletes it. Search matches the name
or handle. A page you have already seen shows at once and is read again
in the background after a minute. Syncing, watching or making a vault
reads it fresh.

Tick programs to act on several at once: **Watch**, **Unwatch** or
**Import as vaults…**. Importing asks you once to confirm that you read
the rules of every picked program and may test their scope. It reads
each program's scope when it never was, then makes its vault from that
snapshot. Programs that already have a vault, or whose scope lists no
web destination, are skipped and the reason is shown. Right click a row
(or press Shift+F10) for its own menu.

### Pictures

Each row starts with the program's picture, or its initials when the
platform gives none. The page never loads it from the platform: the
first time it is shown, Phantom downloads it over HTTPS, checks that it
is a PNG, JPEG, WebP or GIF of at most 256 KB, keeps it and serves that
copy from then on. A download that fails is tried again after a week,
and a new address from the platform is downloaded again on the next
sync.

## Scope snapshots

Open a program for its policy, which is the platform's text shown as
data, and its scope. **Refresh scope** fetches the program again. When
the items changed, a new snapshot is stored with its checksum and what
changed since the last one: items added, items removed, and changed
fields (scope, bounty eligibility, instructions, maximum severity).
Snapshots are never edited.

Each item keeps the platform's asset type, identifier, whether
submissions are accepted, whether it is eligible for a bounty (or that
this is not stated), its maximum severity and instructions.

On HackerOne, each refresh also reads the weakness types the program
lists (with their CWE) and the report categories it excludes from
rewards; the program panel shows the exclusions first, since they change
what is worth reporting. **Read from Hacktivity** shows the program's
disclosed reports (only those marked disclosed), read when asked and
not stored. In **Research**, a HackerOne account's earnings, balance
and payouts are read the same way, as HackerOne recorded them.

The policy is kept the same way: each refresh that finds a different
text keeps it as a new version (up to 50), and the picker above the
policy shows any earlier one with the date it was replaced.

**Your notes** on a program (where to sign in, what is off limits in
practice, ideas to try) stay on this workstation and are never sent to
the platform. They save when the field loses focus or on Ctrl/Cmd+S.

## Watching

Watch a program from its row menu. Every ten minutes, Phantom refreshes
the scope of each watched program that is still listed and was last read
more than 12 hours ago. Set the interval with
`PHANTOM_BOUNTY_REFRESH_HOURS`; 0 turns scheduled refresh off. Scheduled
refreshes go through the same path as **Refresh scope**, one program at
a time, and skip accounts whose token is refused or denied.

Every scope change that has not been seen is listed under **Scope
changes** above the directory, from both manual and scheduled
refreshes. Each item shows the program, how many items were added,
removed and changed, and whether a widening change waits for adoption.
**Review** opens the program. **Mark seen** (or **Mark all seen**)
clears the item, but a widening change still waits until you adopt it
(`GET /bounty/inbox`, `POST /bounty/inbox/seen` `{snapshot_ids}`).

## Vaults from programs

**Create vault from this scope** needs you to confirm that you read the
program's rules and may test what its scope lists. The vault takes the
program's name, platform and link, and a primary domain from the first
included web destination. If the scope lists no web destination, create
the vault by hand. Each scope item becomes one scope entry with source
`import:hackerone`, as follows:

- Web assets (hosts, wildcards, URLs, CIDR ranges, IP addresses) become
  network entries.
- Apps and anything else become `app` or `other` entries, which
  authorise no traffic.
- Items that are not accepted for submissions become exclusions.
- Bounty eligibility is copied as stated. When the platform does not
  state it, it stays `unknown`.
- The note keeps the platform's item id, maximum severity and
  instructions.

Missing information is never read as permission.

When a linked program's scope changes, the change reaches the vault in
one of two ways:

- **Narrowing changes** (items removed, items no longer accepted) apply
  to the vault right away.
- **Widening changes** (items added, items newly accepted) wait. The
  program shows **Review scope**, and the vault keeps its current scope
  until you read the snapshot and choose **Adopt into the vault**.

Entries that came from elsewhere (yours, or other imports) are never
touched.

## Research cockpit

A program's panel opens with its dashboard: the scope version (how many
snapshots it has had) and its latest change, and, when it has a vault,
the engagement rules in force there (active testing, or why it is off,
the window and the daily budget) and the research done (targets,
findings by status, report drafts, last activity).

**Research** at the top of the Programs page lists every program with a
vault, most recent activity first, with its findings by status, report
drafts and the start of your notes; a row opens the program. Above it
are your outcomes from your accounts' own data: reports by the
platform's states, how many were accepted (triaged, resolved or
unresolved) or closed as duplicates, and what the platforms recorded as
earned. Phantom never estimates a reward: an amount is shown only when
the platform reported it.

## Report drafts

Open a finding and choose **Prepare report…** under **Platform
report**. The draft starts from the finding (title, affected URL,
weakness, severity, description and severity rationale) and is for the
vault's program. Checks run as you edit:

| Check | Blocks when |
|---|---|
| Scope | The affected asset is not in the program's latest scope snapshot, or an exclusion names it |
| Submissions | The program is closed to submissions (paused only warns) |
| Evidence | No request is linked and no file is attached |
| Steps, impact | They are missing or too short to follow |
| Severity | None is chosen |
| Credentials | A token, cookie, password or authorization header appears in the text |

A scope item that is not eligible for a bounty only warns. The preview
is the Markdown to paste, with the linked requests and attached files
listed as evidence. **Copy Markdown** and **Open submission page** hand
it to you; Phantom never sends a report. After submitting on the
platform, **I submitted it…** (asked twice) marks the draft handed off,
which records only that you said so: it is not an accepted report. Once
your reports sync, link the finding to its platform report to see the
platform's state. Why Phantom does not write to platforms is in
[Report handoff](../design/report-handoff.md).

## When authorization is withdrawn

Phantom stops testing a vault when the platform no longer confirms you
may test it: its program closes to submissions, stops being listed for
your account, or the account itself is refused. Active testing is then
turned off in the vault's engagement rules, with the reason, so every
new scan, attack, Repeater send and replay is refused and says why;
scans and attacks already running in that vault are stopped; and a
notification links to the program. It happens once per change, and
only you turn active testing back on, in the vault's engagement rules,
after checking the program. A widened scope never applies on its own
either: it waits for **Adopt**.

## Your reports

**Sync my reports** in an account's menu reads your own reports from the
platform. Phantom stores each report's platform id, title, program,
severity rating, report and close times, and link. It also stores the
platform's own state exactly as given (`triaged`,
`pending-program-review`, any state Phantom has never seen) and never
maps it onto finding states. The body of a report is not stored. A
later sync updates states and says how many changed.

**My reports** on the Programs page lists them with a filter per state
and how many findings each is linked to. In a finding's Overview,
**Platform report** links the finding to the report it was submitted
as, shows the report's state and opens it. Phantom never submits,
edits or comments on a report. Submission stays a separate step on the
platform (`POST /bounty/accounts/{id}/reports/sync`,
`GET /bounty/reports`,
`PUT /bounty/findings/{vault_id}/{finding_id}/report` `{report_id}`).

## Platforms and reports

Which platforms Phantom reads, and why others are recorded as private
engagements, is in [Bug bounty platforms](../design/platforms.md). A
report draft follows its platform's sections: HackerOne's Summary,
Steps To Reproduce, Supporting Material/References and Impact;
Bugcrowd's Description, Steps to reproduce, Proof of concept and
Impact. Your reports keep the platform's own state as given; for
counting, each state is read as accepted, duplicate, not accepted,
informative or still open, and a state Phantom does not know counts as
other. **Show its activity** in a report's menu reads its history from
the platform, without storing it.

## Smoke test against a real account

The adapters are tested against stand-ins built from each platform's
documentation. To check one against your own account, run
`python -m scripts.bounty_smoke` from `backend/` with
`PHANTOM_SMOKE_PROVIDER` (`hackerone` or `bugcrowd`),
`PHANTOM_SMOKE_USERNAME` and `PHANTOM_SMOKE_TOKEN` set. It checks the
credentials, reads the first page of programs, one program's details
and scope, and counts your reports, printing names and counts only.
Every request passes a guard that refuses any method but GET before it
leaves the machine, so it cannot create or change anything, and nothing
is stored. Without the variables it does nothing.

## REST

User only: agent calls and requests with `Authorization` or MCP headers
are refused, and there are no MCP tools for this.

| Route | Body / query | Response |
|---|---|---|
| `GET /bounty/accounts` | | `[Account]` without tokens |
| `POST /bounty/accounts` | `{provider, label, username, token}` | `201 Account`, or `422` with `details.code` (`auth_failed`, `forbidden`, `unavailable`) |
| `PATCH /bounty/accounts/{id}` | `{label?, token?}` | `Account` |
| `POST /bounty/accounts/{id}/check` | | `Account` |
| `POST /bounty/accounts/{id}/sync` | | `{account, added, updated, unlisted}` |
| `DELETE /bounty/accounts/{id}` | | `204` |
| `GET /vaults/{vid}/findings/{fid}/report-draft` / `PATCH` | `{title?, asset?, weakness?, severity?, summary?, steps?, impact?}` | `Draft` with `checks`, `ready`, `markdown`, `submit_url`, `status` |
| `POST /vaults/{vid}/findings/{fid}/report-draft/hand-off` | `{confirm: true}` (user only) | `Draft` with `status: handed_off` |
| `GET /bounty/programs/{id}/dashboard` | | scope version and latest change; with a vault, engagement rules and research |
| `GET /bounty/programs/{id}/hacktivity` | | disclosed reports (HackerOne; `409` elsewhere), not stored |
| `GET /bounty/accounts/{id}/earnings` | | `{balance, earnings, payouts, currency}` (HackerOne; `409` elsewhere), not stored |
| `GET /bounty/reports/{id}/activity` | | `{state, severity, activities: [{at, kind, detail}]}` read from the platform, not stored |
| `GET /bounty/overview` | | programs with a vault: activity, findings, drafts, notes |
| `GET /bounty/analytics` | `account_id?` | report counts by state and severity, `accepted`, `duplicates`, `earned` and `earned_totals` as recorded by the platforms |
| `POST /bounty/engagements` | `{name, url?, policy?, scope, authorization: {granted_by, reference?, starts_on?, ends_on?, note?}}` | `201 Program` (provider `manual`) |
| `PATCH /bounty/engagements/{id}` | the same fields, all optional; `scope` keeps a new snapshot | `Program` (`409` for a platform program) |
| `GET /bounty/accounts/{id}/runs` | `limit` (≤ 200) | `[{kind, program_id, trigger, outcome, counts, error_code, error, drift, started_at, finished_at}]` newest first |
| `GET /bounty/programs` | `search`, `submissions`, `bounties`, `watched`, `account_id` | `[Program]` |
| `GET /bounty/directory` | the same, plus `visibility`, `listed`, `vault`, `reported`, `flags` (repeatable), `asset_type`, `changed_days` (1 to 365), `review`, `sort` (`name`, `started`, `reports`, `earned`, `scope`, `synced`), `order`, `limit` (≤ 200), `offset` | `{items: [Program], total}`; each program has `asset_types`, `scope_changed_at` and `has_picture` |
| `GET /bounty/programs/{id}` / `PATCH` | `{watched?, notes?}` (an empty `notes` clears them) | `Program` with `policy`, `raw` and `notes` |
| `GET /bounty/programs/{id}/picture` | | the stored picture (`404` when there is none or it could not be downloaded) |
| `GET /bounty/programs/{id}/policy-history` | | `[{id, text, checksum, fetched_at}]` newest first |
| `GET /bounty/views` / `POST` | `{name, query, pinned?}`; `query` holds the directory parameters above | `[View]` pinned first / `201 View` (`409` for a name in use, at most 50) |
| `PATCH /bounty/views/{id}` / `DELETE` | `{name?, query?, pinned?}` | `View` / `204` |
| `GET /bounty/programs/{id}/snapshots` | | `[Snapshot]` newest first |
| `POST /bounty/programs/{id}/refresh` | | `Snapshot` (the latest, new only when changed) |
| `POST /bounty/programs/{id}/snapshots/{sid}/adopt` | | `Snapshot` (only the latest; needs a linked vault) |
| `POST /bounty/programs/{id}/vault` | `{confirm: true, name?}` | `201 Program` with `vault_id` |

## Not yet

- A documented smoke test against a real account.
