WAF Leaked Credentials Detection, Mitigation Rules, and Origin Headers
How WAF leaked credentials detection works, which rule fields and plans apply, and how to mitigate and notify your origin.
This page summarises Cloudflare documentation on leaked credentials detection in the Web Application Firewall (WAF). The feature scans incoming HTTP requests for usernames and passwords that appeared in known data breaches, populates Rules language fields you can use in custom and rate limiting rules, and optionally forwards status to your origin via the Exposed-Credential-Check header. The older exposed credentials check is deprecated; Cloudflare recommends upgrading to leaked credentials detection.
Leaked credentials in your traffic may indicate credential stuffing or a legitimate user reusing an old password. Detection compares extracted credentials against breach data without retaining plaintext passwords at Cloudflare.
Leaked credentials detection: what the WAF checks on login traffic
Section titled “Leaked credentials detection: what the WAF checks on login traffic”Leaked credentials traffic detection scans incoming requests for credentials previously leaked from data breaches.
The leaked credentials traffic detection scans incoming requests for credentials (usernames and passwords) previously leaked from data breaches ↗︎.
— Cloudflare, Leaked credentials detection
When the feature is on, Cloudflare looks for authentication patterns from common web applications and any custom detection locations you configure. Matches populate boolean fields on the request so you can analyse traffic in Security Analytics or act with WAF rules.
The comparison database includes the Have I Been Pwned (HIBP) matched passwords dataset (passwords only), Cloudflare-collected usernames, and leaked username–password pairs. Changelog entries note ongoing additions from HIBP, the RockYou 2024 dataset, and other third-party sources (example).
Cloudflare does not store, log, or retain plaintext end-user passwords when performing leaked credential checks. Passwords are hashed, converted into a cryptographic representation, and then compared against a database of leaked credentials.
— Cloudflare, Leaked credentials detection
How to turn on leaked credentials detection (dashboard, API, Terraform)
Section titled “How to turn on leaked credentials detection (dashboard, API, Terraform)”On Free plans, leaked credentials detection is enabled by default. On paid plans, turn it on in the dashboard under Security Settings (filter by Detection tools), via API, or with Terraform.
API — enable for a zone (requires Zone WAF Write or Account WAF Write):
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "enabled": true }'See Common API calls for disable, status GET, and custom detection location CRUD.
Terraform — use cloudflare_leaked_credential_check as in Terraform configuration examples.
Cloudflare recommends turning off Exposed Credentials Checks after enabling leaked credentials detection and defining mitigation (Get started).
Default scan locations and Authorization Basic credentials
Section titled “Default scan locations and Authorization Basic credentials”By default, detection includes rules for Drupal, Joomla, Ghost, Magento, Plone, WordPress, Microsoft Exchange OWA, plus generic web authentication patterns (Leaked credentials detection).
Leaked credentials detection now also scans the Authorization request header for HTTP Basic Authentication:
Leaked credentials detection now scans the Authorization request header for Basic Authentication credentials. Previously, the detection only inspected request bodies, query strings, and headers for well-known web applications or custom detection locations, which meant credentials sent through HTTP Basic Authentication were not covered by default.
— Cloudflare, Leaked credentials detection now scans Authorization headers
The WAF decodes Authorization: Basic <credentials>, compares username and password against the leaked-credentials database, fills fields such as cf.waf.credential_check.password_leaked, and can trigger the Exposed-Credential-Check managed transform if configured. Zones with detection already enabled received this automatically; no configuration change is required (changelog).
Custom detection locations (Enterprise): non-standard JSON or form fields
Section titled “Custom detection locations (Enterprise): non-standard JSON or form fields”If credentials live in custom JSON keys or forms, Enterprise customers can add custom detection locations with Rules language expressions—for example:
| Request type | Username location | Password location |
|---|---|---|
| JSON body | lookup_json_string(http.request.body.raw, "user") |
lookup_json_string(http.request.body.raw, "secret") |
| URL-encoded form | url_decode(http.request.body.form["user"][0]) |
url_decode(http.request.body.form["secret"][0]) |
| Multipart form | url_decode(http.request.body.multipart["user"][0]) |
url_decode(http.request.body.multipart["secret"][0]) |
Only a username expression is required; password is optional (Leaked credentials detection, Get started). Allowed fields include http.request.body.form, http.request.body.multipart, http.request.body.raw, http.request.headers, http.request.uri.args, and http.request.uri.query; functions include lookup_json_string() and url_decode().
WAF credential check fields: plan limits and rule expressions
Section titled “WAF credential check fields: plan limits and rule expressions”Use these fields in custom rules or rate limiting rules to challenge, block, or throttle compromised logins (Leaked credentials fields):
| Field | Rules language identifier | Plans |
|---|---|---|
| Password Leaked | cf.waf.credential_check.password_leaked |
All |
| User and Password Leaked | cf.waf.credential_check.username_and_password_leaked |
Pro and above |
| Username Leaked | cf.waf.credential_check.username_leaked |
Enterprise |
| Similar Password Leaked | cf.waf.credential_check.username_password_similar |
Enterprise |
| Authentication detected | cf.waf.auth_detected |
Enterprise |
Indicates whether the auth credentials detected in the request (username-password pair) were previously leaked.
Requires a Cloudflare Pro plan or above. You must also enable leaked credentials detection.
— Cloudflare,
cf.waf.credential_check.username_and_password_leaked
On Free plans, build rules on cf.waf.credential_check.password_leaked instead of the username–password pair field (Discover and secure your API endpoints).
Example — challenge leaked username and password (paid):
(cf.waf.credential_check.username_and_password_leaked)
Action: Managed Challenge (Get started, Example mitigation rules).
Example — scope to a login path:
(cf.waf.credential_check.username_and_password_leaked and http.request.uri.path contains "/admin/login.php")
Example — rate limit with account takeover (ATO) context:
Match (any(cf.bot_management.detection_ids[*] eq 201326593) and cf.waf.credential_check.username_and_password_leaked), count per IP, block above 5 requests per minute (Example mitigation rules).
On Free plans, deploy the suggested rate limiting template in Security Security rules (leaked password more than five times per 10 seconds per IP) (Get started).
Exposed-Credential-Check header: origin notification via managed transform
Section titled “Exposed-Credential-Check header: origin notification via managed transform”To let your application force a password reset or start step-up auth, enable Add Leaked Credentials Checks Header managed transform and ensure leaked credentials detection is on (Available Managed Transforms).
Adds an Exposed-Credential-Check request header whenever the WAF detects leaked credentials in the incoming request.
— Cloudflare, Available Managed Transforms
You only receive this header at the origin when WAF leaked-credentials detection is enabled, the managed transform is on, and your plan supports the match type (reference).
| Header value | Meaning | Availability |
|---|---|---|
Exposed-Credential-Check: 1 |
Previously leaked username and password | Pro and above |
Exposed-Credential-Check: 2 |
Previously leaked username | Enterprise |
Exposed-Credential-Check: 3 |
Similar combination of previously leaked username and password | Enterprise |
Exposed-Credential-Check: 4 |
Previously leaked password | All plans |
On Free plans, only password-leak detail is available; Cloudflare may send Exposed-Credential-Check: 4 when only the password was leaked (Available Managed Transforms). The header name matches the deprecated exposed-credentials Rewrite action, but managed-transform values range from 1 to 4 by plan (Get started).
Test credentials: validate detection before blocking traffic
Section titled “Test credentials: validate detection before blocking traffic”Cloudflare provides case-sensitive test credentials (Test your configuration):
| Plan | Username | Password |
|---|---|---|
| Free (also works on paid) | CF_LEAKED_USERNAME_FREE |
CF_LEAKED_PASSWORD |
| Paid (not on Free) | CF_EXPOSED_USERNAME or CF_EXPOSED_USERNAME@example.com |
CF_EXPOSED_PASSWORD |
Use them in test HTTP requests after enabling detection. Validate with Security Analytics, HTTP logs, or an Enterprise Log custom rule before switching to block or challenge (Get started).
Common mistakes when configuring leaked credential checks
Section titled “Common mistakes when configuring leaked credential checks”- Leaving Exposed Credentials Check enabled alongside leaked credentials detection, increasing auth latency (upgrade guide).
- Using
cf.waf.credential_check.username_and_password_leakedon a Free plan instead ofcf.waf.credential_check.password_leaked. - Expecting the origin header without both leaked credentials detection and Add Leaked Credentials Checks Header enabled (Available Managed Transforms).
- Assuming Basic Auth is skipped—it is included in default scanning after the Authorization header update (changelog).
- For non-standard APIs, forgetting Enterprise custom detection locations so credentials in the body are never extracted (Leaked credentials detection).
How to check this on your site
Section titled “How to check this on your site”-
Confirm detection status with a GET to
/zones/$ZONE_ID/leaked-credential-checksor Security Settings → Leaked credential detection (Get started). -
Send a login request using the plan-appropriate test credentials and confirm matches in Security Analytics or HTTP logs (Get started).
-
If you use origin handling, verify the managed transform is on and your origin sees
Exposed-Credential-Checkwith the expected value for your plan (Available Managed Transforms). -
Confirm mitigation rules fire (challenge, block, or rate limit) without affecting normal logins, using Example mitigation rules as a reference.
-
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.