API key leak validator — detect and verify leaked credentials across 20+ services from the command line, with concurrent validation and git history scanning.
keyleak takes API keys (from stdin, files, git history, or direct input), automatically identifies the service they belong to, and validates whether they're still active by making safe, read-only API calls.
# Clone the repository
git clone https://github.com/Lappy000/keyleak.git
cd keyleak
# Install in development mode
pip install -e .
# Or install dependencies directly
pip install -r requirements.txt# Single key
echo 'sk-abc123xyz456...' | keyleak
# Multiple keys (one per line)
cat leaked_keys.txt | keyleak
# From clipboard (macOS)
pbpaste | keyleak# Scan a single file
keyleak scan secrets.txt
# Scan multiple files
keyleak scan .env config.yml dump.txt
# Scan with glob patterns
keyleak scan *.env# Auto-detect service type
keyleak check 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# Force a specific service
keyleak check --service stripe 'sk_live_xxxxxx'# Process keys one per line from stdin
cat keys.txt | keyleak batch
# With JSON output
cat keys.txt | keyleak --json batch > results.json# Rich table (default)
keyleak scan dump.txt
# JSON output
keyleak --json scan dump.txt
# Compact one-line format
keyleak --compact scan dump.txt
# Verbose with progress
keyleak -v scan dump.txt# Only check GitHub and AWS keys
keyleak -s github -s aws scan dump.txtkeyleak services# Scan history of the current repo (last 500 commits)
keyleak git-scan .
# Scan a specific repo with more history
keyleak git-scan /path/to/repo --max-commits 2000
# Skip live validation — just list keys found in history
keyleak git-scan . --no-validate
# JSON output for CI integration
keyleak --json git-scan . > history_findings.jsonUse --parallel to validate multiple keys concurrently. Significantly faster when
scanning large files or git histories with many keys.
keyleak --parallel scan dump.txt
keyleak --parallel --workers 16 scan large_dump.txt
keyleak --parallel git-scan /path/to/repo --max-commits 1000| Service | Key Prefix | Validation Method | Endpoint |
|---|---|---|---|
| AWS | AKIA... |
STS GetCallerIdentity | sts.amazonaws.com |
| OpenAI | sk-... |
List models | GET /v1/models |
| Anthropic | sk-ant-... |
Send minimal message | POST /v1/messages |
| GitHub | ghp_ / gho_ / github_pat_ |
Get user | GET /user |
| Stripe | sk_live_ / sk_test_ |
List charges | GET /v1/charges?limit=1 |
| Slack | xoxb- / xoxp- |
Auth test | POST auth.test |
| SendGrid | SG.xxx.xxx |
Get profile | GET /v3/user/profile |
| Twilio | SK... (34 chars) |
List accounts | GET /2010-04-01/Accounts |
| Telegram | <digits>:<hash> |
Get bot info | GET /bot<token>/getMe |
| DigitalOcean | dop_v1_... |
Get account | GET /v2/account |
| Mailgun | key-... |
List domains | GET /v3/domains |
| Hugging Face | hf_... |
Who am I | GET /api/whoami-v2 |
| Vercel | vercel_... |
Get user | GET /v2/user |
| Google Cloud | AIza... / ya29... |
Token info / Maps probe | Google APIs |
| Cloudflare | 40-character token | Verify token | GET /client/v4/user/tokens/verify |
| Supabase | JWT (eyJ...) |
Decode claims | Local JWT structure check |
| Datadog | 32-character hex | Validate key | GET /api/v1/validate |
| Resend | re_... |
List domains | GET /domains |
| Notion | secret_... / ntn_... |
Get bot user | GET /v1/users/me |
| Linear | lin_api_... |
Viewer query | POST /graphql |
- Create a new file in
keyleak/validators/:
# keyleak/validators/myservice_key.py
"""MyService key validator."""
import time
import httpx
from keyleak.validators import KeyStatus, ValidationResult
def validate(key: str) -> ValidationResult:
"""Validate a MyService API key."""
start_time = time.time()
# Make a safe API call
headers = {"Authorization": f"Bearer {key}"}
try:
with httpx.Client(timeout=15.0) as client:
response = client.get("https://api.myservice.com/verify", headers=headers)
elapsed = (time.time() - start_time) * 1000
if response.status_code == 200:
return ValidationResult(
key_value=key,
service="myservice",
status=KeyStatus.VALID,
message="key is valid",
http_status=200,
response_time_ms=round(elapsed, 2),
)
# ... handle other status codes
except Exception as exc:
elapsed = (time.time() - start_time) * 1000
return ValidationResult(
key_value=key,
service="myservice",
status=KeyStatus.ERROR,
message=f"Error: {exc}",
response_time_ms=round(elapsed, 2),
)- Add a pattern to
keyleak/detector.py:
KeyPattern(
service="myservice",
pattern=re.compile(r"ms_[A-Za-z0-9]{32}"),
description="MyService API Key",
validator_module="keyleak.validators.myservice_key",
prefix_hint="ms_",
min_length=35,
max_length=35,
),- Register in
keyleak/validators/__init__.py:
_VALIDATOR_MODULES = {
...
"myservice": "keyleak.validators.myservice_key",
}This tool is designed for security professionals and authorized leak validation only. Do not use it to exploit leaked credentials. If you find valid keys, report them responsibly to the key owner.
keyleak/
├── keyleak/
│ ├── __init__.py # Package metadata
│ ├── cli.py # Click-based CLI with subcommands
│ ├── detector.py # Regex-based key type detection
│ ├── output.py # Rich table + JSON formatters
│ └── validators/
│ ├── __init__.py # Base classes + dynamic loader
│ ├── aws.py # AWS STS validation
│ ├── openai_key.py # OpenAI /v1/models
│ ├── anthropic_key.py # Anthropic /v1/messages
│ ├── github_key.py # GitHub /user
│ ├── stripe_key.py # Stripe /v1/charges
│ ├── slack_key.py # Slack auth.test
│ ├── sendgrid_key.py # SendGrid /v3/user/profile
│ ├── twilio_key.py # Twilio /2010-04-01/Accounts
│ ├── telegram_key.py # Telegram /getMe
│ ├── digitalocean_key.py # DO /v2/account
│ ├── mailgun_key.py # Mailgun /v3/domains
│ ├── huggingface_key.py # HF /api/whoami-v2
│ ├── vercel_key.py # Vercel /v2/user
│ ├── google_cloud_key.py # Google token and API-key checks
│ ├── cloudflare_key.py # Cloudflare token verification
│ ├── supabase_key.py # Supabase JWT claim inspection
│ ├── datadog_key.py # Datadog /api/v1/validate
│ ├── resend_key.py # Resend /domains
│ ├── notion_key.py # Notion /v1/users/me
│ └── linear_key.py # Linear GraphQL viewer
├── README.md
├── pyproject.toml
├── requirements.txt
├── .gitignore
└── LICENSE
MIT — see LICENSE for details.