# If a key leaks

Provenance keys carry a checksum so secret scanners can match them. A leaked live API key is revoked at once, a leaked webhook secret is rotated with a 24-hour overlap, and anyone can report a key.

Keys leak the way all keys do: committed to a public repository, pasted into a ticket, printed in a log. Provenance acts on a leaked key as soon as it's reported, and tells you where it was found and what it did.

**Availability:** every plan, at no charge.

**Before you begin:** nothing to set up. Choose what a leaked live key does under **Settings → Agents → Takeover protection** (revoke at once by default, or tell you only).

## 1. Know the key formats

New keys end in a 6-character checksum, so a scanner can tell a Provenance key from random text with almost no false matches:

| Key | Format |
| --- | --- |
| Live API key | `prv_live_` + 32 random characters + a 6-character checksum |
| Sandbox API key | `prv_test_` + 32 random characters + a 6-character checksum |
| Webhook signing secret | `whsec_` + 32 random characters + a 6-character checksum |

The checksum is the CRC32 of everything before it (prefix included), written as 6 base62 characters. Keys made before the checksum keep working. The console marks them under **Developers → API keys**: rotate them so scanners can match them too.

## 2. See what happens to a leaked key

| What leaked | What Provenance does |
| --- | --- |
| A live API key | Revokes it at once (or only tells you, if you chose that). |
| A sandbox API key | Tells you. It keeps working, so rotate it, or [revoke it](https://provenanceauth.com/docs/get-started/authentication.md#revoke-a-key) if nothing should use it. |
| A webhook signing secret | Rotates it. Deliveries carry a signature from the new secret and, for 24 hours, from the old one, so your receiver can switch without dropping events. |
| An agent signing key's private part | Revokes the signing key and opens a [takeover check](https://provenanceauth.com/docs/mandate/guides/protect-agents-from-takeover.md) for the agent with the reason `key_leaked`. |

Provenance never holds an agent's private key; a report counts only when its private part matches a registered public key.

Owners and admins get an email, a console task and the `api_key.leaked` webhook, with where the key was found (the URL from the report), what was done, and a link to make a new key. [`GET /v1/leaked_key_reports`](https://provenanceauth.com/docs/api/leaked-keys.md#get-v1-leaked-key-reports) lists your reports.

## 3. Report a key you found

Anyone can report a Provenance key, without an account. Send the whole key and, if you have it, where you found it:

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/public/leaked_keys \
  -H "Content-Type: application/json" \
  -d '{ "key": "prv_live_notarealkeyatall000000000000000", "url": "https://github.com/example/repo/blob/main/.env" }'
```

**Node**

```ts
await fetch(`${process.env.PROVENANCE_API}/v1/public/leaked_keys`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ key: foundKey, url: "https://github.com/example/repo/blob/main/.env" }),
});
```

**Python**

```python
httpx.post(f"{api}/v1/public/leaked_keys", json={"key": found_key, "url": "https://github.com/example/repo/blob/main/.env"})
```

```json
{
  "object": "leaked_key_report_receipt",
  "received": true
}
```

The answer is always `202` with the same body, whether the key is valid, unknown or already revoked, so the route can't be used to test keys. Each address can report 10 keys an hour.

## 4. GitHub secret scanning

Provenance receives GitHub's secret scanning reports at `POST /v1/public/secret_scanning/github`, in GitHub's partner format. It checks GitHub's ECDSA P-256 signature against the keys GitHub publishes before it acts on a report, and answers each match with GitHub's `true_positive` or `false_positive` label. A report whose signature doesn't verify changes nothing.

**Availability:** the endpoint answers `503` [`secret_scanning_not_configured`](https://provenanceauth.com/docs/platform/errors.md#secret_scanning_not_configured) until GitHub enables scanning for Provenance keys. Until then, report keys with the route in step 3.

## Errors you might see

| Code | What to do |
| --- | --- |
| `rate_limit_exceeded` | Wait for the hour's window to reset, then report again. |
| `secret_scanning_not_configured` | Report the key with `POST /v1/public/leaked_keys`. |
| `secret_scanning_signature_invalid` | Send the report exactly as GitHub signed it. |
| `secret_scanning_keys_unavailable` | The report was held, not trusted. GitHub retries it. |

## See also

- [Prevent agent takeover](https://provenanceauth.com/docs/mandate/guides/protect-agents-from-takeover.md)
- [Authentication](https://provenanceauth.com/docs/get-started/authentication.md)
- [Webhooks](https://provenanceauth.com/docs/integrate/webhooks.md)
