A production-quality password breach checker that uses the Have I Been Pwned (HIBP) Pwned Passwords API with the k-anonymity model to ensure your passwords are never exposed.
Breach Check Agent checks whether a given password has appeared in known data breaches. It provides:
- CLI tool — Check passwords from the terminal with hidden input
- REST API — FastAPI service with rate limiting and CORS
- Web UI — Clean frontend for non-technical users
- Agent skill —
SKILL.mdfor AI coding/security agents
Traditional password-checking services require sending the full password (or its hash) to a server. This creates a privacy risk: the server operator could potentially record or abuse that data.
Breach Check Agent uses the HIBP k-anonymity model to eliminate this risk:
- Local hashing: Your password is hashed with SHA-1 on your machine. The raw password never leaves your device.
- Partial transmission: Only the first 5 characters of the SHA-1 hash are sent to the HIBP API. This is a tiny, irreversible fragment that cannot be used to reconstruct the password.
- Local matching: HIBP returns ALL password hash suffixes that match those 5 characters (typically 400-600 results). The actual comparison happens locally — the HIBP server never knows which specific suffix you're looking for.
- No storage: Passwords are never stored, logged, or cached anywhere.
Result: Even if someone monitors all network traffic or compromises the HIBP server, they cannot determine which password was checked. The 5-character prefix is shared by hundreds of other passwords.
# Clone the repository
git clone https://github.com/rksharma-owg/breach-check-agent.git
cd breach-check-agent
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# venv\Scripts\activate # Windows
# Install dependencies
pip install -e ".[dev]"# Build and run with Docker Compose
docker compose up --build -d
# The API + frontend is available at http://localhost:8000breach-check password
# Prompts for hidden input — password never appears on screenbreach-check password --json
# Output:
# {
# "pwned": true,
# "count": 57632146,
# "recommendation": "This password appeared 57,632,146 time(s)..."
# }echo "your_password" | breach-check password --stdin --jsonbreach-check password --verbose# From source
uvicorn breach_check_agent.api:app --host 0.0.0.0 --port 8000
# Or with Docker
docker compose upcurl -X POST http://localhost:8000/check-password \
-H "Content-Type: application/json" \
-d '{"password": "your_password_here"}'Response (pwned):
{
"pwned": true,
"count": 57632146,
"recommendation": "This password appeared 57,632,146 time(s) in data breaches. It is one of the most commonly leaked passwords. Change it NOW and use a password manager."
}Response (safe):
{
"pwned": false,
"count": 0,
"recommendation": "This password was NOT found in known data breaches. However, always use a unique, strong password for each account."
}curl http://localhost:8000/health
# {"status": "ok", "version": "1.0.0"}When the server is running, interactive API docs are available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
By default, the API allows 5 requests per 60 seconds per IP address. Configure via environment variables:
export RATE_LIMIT_REQUESTS=10
export RATE_LIMIT_WINDOW=60# Build and start
docker compose up --build -d
# View logs
docker compose logs -f
# Stop
docker compose down
# Rebuild after changes
docker compose up --build -dCopy .env.example to .env and adjust:
cp .env.example .env| Variable | Default | Description |
|---|---|---|
HIBP_API_URL |
https://api.pwnedpasswords.com |
HIBP API base URL |
API_HOST |
0.0.0.0 |
Bind host |
API_PORT |
8000 |
Bind port |
RATE_LIMIT_REQUESTS |
5 |
Max requests per window |
RATE_LIMIT_WINDOW |
60 |
Rate limit window (seconds) |
CORS_ORIGINS |
http://localhost:3000 |
Allowed CORS origins |
LOG_LEVEL |
INFO |
Logging level |
# Install test dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_security.py -vbreach-check-agent/
├── README.md # This file
├── SKILL.md # Agent skill documentation
├── .gitignore # Git ignore rules
├── .env.example # Environment variable template
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Multi-stage Docker build
├── pyproject.toml # Python project configuration
├── src/
│ └── breach_check_agent/
│ ├── __init__.py # Package init
│ ├── security.py # SHA-1 hashing, prefix/suffix, redaction
│ ├── hibp_client.py # HIBP API client (k-anonymity)
│ ├── cli.py # Command-line interface
│ └── api.py # FastAPI REST service
├── frontend/
│ ├── index.html # Web UI
│ ├── style.css # Styles
│ └── app.js # Frontend logic
└── tests/
├── test_security.py # Security module tests
├── test_hibp_client.py # HIBP client tests (mocked)
└── test_api.py # API endpoint tests
-
SHA-1 weaknesses: This tool uses SHA-1 for hashing because that is what the HIBP Pwned Passwords database uses. SHA-1 is cryptographically broken for collision resistance, but preimage resistance remains adequate for this use case (mapping a password to a fixed identifier).
-
Network exposure: While only a 5-character hash prefix is sent, a network observer can see that a breach check was performed. They cannot determine which password was checked.
-
Not a password manager: This tool only checks passwords against known breaches. It does not store, generate, or manage passwords.
-
HIBP API availability: The service depends on the HIBP API being available and accurate. If the API is down, checks will fail gracefully.
-
False negatives: A password that hasn't appeared in a breach YET is not necessarily safe. New breaches are discovered regularly.
-
API endpoint: When using the web UI or API, passwords are sent from the browser to the local backend over HTTP. In production, always use HTTPS (via a reverse proxy like nginx or Caddy).
Do NOT use this tool to collect, log, or store user passwords. The code is designed to prevent password leakage, but the responsibility for ethical use lies with the operator. Deploy only with informed consent from users whose passwords you are checking.
MIT License — see LICENSE for details.