Sub topic 4
The partner program: how providers learn about leaked tokens
This chapter assumes you know what secret scanning alerts and push protection are from earlier chapters. You should also be comfortable reading JSON and short Python. The partner program is a separate path from the alerts you see in your own repository. It matters because it explains why a token you leaked can stop working minutes later, before you have opened any alert.
What the partner program is
The secret scanning partner program is an arrangement between GitHub and service providers such as cloud platforms, payment processors and package registries. A provider registers the format of its tokens and an HTTPS endpoint. When GitHub finds a string that matches that format in a public place, it sends the match to the provider. The provider decides what to do with it.
The provider is the only party that can reliably revoke its own credential. A repository owner can delete a commit, but only the issuer can make a leaked token stop working. The partner program closes the gap between "a token is public" and "the issuer knows".
Three points shape everything else in the chapter:
- Partner scanning applies to public content. GitHub does not send matches from private repositories to providers.
- It works without any setting in your repository. You do not enable it, and you cannot turn it off.
- It is separate from the alerts you manage. Repository alerts, push protection and bypass controls are the owner-facing side. The partner program is the provider-facing side.
The flow from commit to revocation
When someone pushes a commit to a public repository, GitHub scans the content for the token formats that partners have registered. For each match, it builds a payload and posts it to the partner's endpoint. The partner checks that the request is genuinely from GitHub, checks that the token is real, and then acts.
The developer does nothing in this flow. In many cases the token is revoked and an email arrives before the developer notices the mistake.
What GitHub sends
The request body is a JSON array. Each element describes one match. The fields are:
| Field | Meaning |
|---|---|
| `token` | The raw string that matched the provider's pattern. |
| `type` | The identifier of the pattern that matched, as agreed with the provider. |
| `url` | A link to the place where the string was found, for example a commit or file. |
| `source` | The kind of location, such as repository content. |
Check the current GitHub documentation for the exact set of source values, because it can grow.
Two headers carry the proof that the request came from GitHub:
Github-Public-Key-Identifiernames which GitHub signing key was used.Github-Public-Key-Signatureholds an ECDSA signature of the raw request body, base64 encoded.
The provider fetches GitHub's current public keys from https://api.github.com/meta/public_keys/secret_scanning. It uses the identifier to pick the matching key and verifies the signature over the exact bytes it received. Re-serializing the JSON before verifying will break the check.
A minimal provider-side verifier
You will probably never run a partner endpoint. Reading one still makes the trust model concrete. The sketch below verifies a request and returns the matched tokens. It assumes requests and cryptography are installed.
import base64
import json
import requests
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import load_pem_public_key
KEYS_URL = "https://api.github.com/meta/public_keys/secret_scanning"
def verify_and_parse(raw_body: bytes, key_id: str, signature_b64: str) -> list:
"""Return the list of matches if the signature is valid, else raise."""
response = requests.get(
KEYS_URL, headers={"Accept": "application/vnd.github+json"}, timeout=10
)
response.raise_for_status()
keys = response.json()["public_keys"]
match = next((k for k in keys if k["key_identifier"] == key_id), None)
if match is None:
raise ValueError("unknown GitHub key identifier")
public_key = load_pem_public_key(match["key"].encode())
try:
public_key.verify(
base64.b64decode(signature_b64),
raw_body,
ec.ECDSA(hashes.SHA256()),
)
except InvalidSignature:
raise ValueError("signature does not match request body")
return json.loads(raw_body)After this step a real provider would test each token against its own systems. It would revoke or restrict live tokens and notify the account owner. Only then would it respond with HTTP 200. A provider that skipped the signature check would let anyone trigger revocations of other people's tokens by posting fake reports.
Partner notifications and your alerts are separate
A single leaked token can produce two independent outcomes. The following table separates them.
| Row | Partner program | Repository secret scanning alerts |
|---|---|---|
| Audience | The provider that issued the token | The repository owner and admins |
| Scope | Public content | Repositories where the feature is enabled, including private ones where available |
| Configurable by you | No | Yes, including custom patterns and path exclusions |
| Visible to you in GitHub | No | Yes, in the Security tab and through the API |
| Result | The provider may revoke the token and notify its owner | An alert you must triage and close |
Because the two paths are independent, you can see either outcome without the other. The provider may revoke a token automatically, and you will still have an open alert to close. Conversely, a provider that is not in the program, or whose token format is not registered, will never hear about the leak from GitHub. In that case only your own alert and your own response protect you.
The practical consequence for triage is that the alert state does not tell you whether a token is still live. You can check an open alert for context with the API call from the earlier chapter on automation.
gh api 'repos/OWNER/REPO/secret-scanning/alerts?state=open' \
--jq '.[] | {number, secret_type_display_name, validity, push_protection_bypassed}'Use the validity field, where available, together with a check at the provider's console. Do not infer from the partner program that a token was revoked.
Edge cases and limits
Revocation is not guaranteed. Providers choose their own response. Some revoke immediately. Some only email the owner. Some take no automatic action for token types that are low risk or hard to confirm. Treat a partner-driven revocation as a bonus, never as your remediation.
Timing varies. Scanning, delivery and provider processing take time. A token in a public repository can be harvested by automated crawlers within seconds. Rotation must start the moment you learn of the leak, not after you hear from the provider.
Making a repository private afterwards does not undo exposure. Anyone who cloned or crawled the content in the public window still has the secret. The right move is the same as in any leak: revoke, rotate, then clean history.
Pattern coverage is the provider's, not yours. You cannot add your internal token format to the partner program by writing a custom pattern. Custom patterns work only inside your own repository or organization alerts. If your company issues tokens to outside customers and wants leaks reported to it, the company has to apply to become a partner.
Revoked is not the same as resolved. When you close the repository alert, choose a resolution that matches reality. Use "revoked" only after the credential has been invalidated, whether by you or by the provider. If a provider revoked it, confirm that in the provider's console first.
Becoming a partner
A provider that wants to join does this at a high level:
- Defines one or more token formats with a pattern that is specific enough to avoid false positives. An identifiable prefix and a fixed length are typical, for example
acme_[A-Za-z0-9]{32}. - Builds an HTTPS endpoint that verifies GitHub's signature, as in the sketch above.
- Decides the response policy: revoke, restrict, or notify.
- Contacts GitHub to be added to the program and tests with sample matches.
Specific prefixes also help you. They are what make a token easy to detect with low noise, and they are why the same patterns appear in your own scanning and in push protection.
Exercise
A developer pushes an AWS-style access key to a public repository. Within minutes the provider revokes it. The repository's secret scanning alert is still open. What should the repository admin do before closing it, and which resolution is accurate?
Show answer
Confirm in the provider's console that the key is revoked and no longer authenticates, and check that the owner has rotated any systems that used it. Then close the alert with the resolution "revoked". The partner program notified the provider, but it does not update the repository alert, so the admin must verify and close it. The admin should also look for other places the key was used, and clean up history after rotation.
Exercise
Your company issues API keys with the format acme_ followed by 32 alphanumeric characters. You add this as a custom pattern in your organization. Will GitHub now report leaks of these keys found in other people's public repositories to your security team?
Show answer
No. A custom pattern only produces alerts in the repositories or organization where you define it. Reporting leaks from public repositories to an issuer is the job of the partner program, and the company would need to join it as a provider with its own verification endpoint.