In short
Cloudflare WAF configuration export: the file Cloudflare WAF writes of its own settings, which a configuration review reads setting by setting without connecting to Cloudflare WAF.
How to export the Cloudflare WAF configuration, step by step, what the review checks in the file (24 checks run), and what it does not read.
| The file | JSON, one cloudflare-waf.json per zone (managed_rules, managedRulesets, managedExceptions, customRules and rateLimitRules), with zone-settings.json, bot-management.json and ddos-l7.json as Cloudflare returns them |
|---|---|
| Checks run on it | 24 |
| Highest grade its findings reach | OBSERVED |
| Feeds attack paths | Yes |
| Not read from this export | 1 area, listed below |
Sources: Cloudflare WAF documentation (1); Cloudflare WAF documentation (2); Cloudflare WAF documentation (3); the vendor table.
How to export it
- Who can pull it
- An API token with Zone WAF, Zone Settings, Bot Management and HTTP DDoS Managed Ruleset Read
- Time
- About 10 minutes for one zone, including creating the token and deleting it afterwards; about 2 minutes for each further zone the token covers.
- The file
- JSON, one cloudflare-waf.json per zone (managed_rules, managedRulesets, managedExceptions, customRules and rateLimitRules), with zone-settings.json, bot-management.json and ddos-l7.json as Cloudflare returns them
No console export: This guide gives no dashboard export: Cloudflare documents the Security rules page of the dashboard for viewing and editing these rules, and the Rulesets API calls in the steps for reading them as JSON. The dashboard is used here for the zone ID and the token.
From the command line
Copy the zone ID: in the Cloudflare dashboard select your domain; on its Overview page, in the API section near the bottom, select the copy button next to Zone ID
The vendor's page, checked 2026-11-11Create a token that can read this one zone: My Profile → API Tokens → Create Token. Add a token name, for example waf-export. Start from scratch instead of a template. Create a policy of type Zone, select your domain as the resource the policy applies to, and choose the permission Zone WAF with Read access. In the same policy add three more permissions, each with Read access: Zone Settings, Bot Management and HTTP DDoS Managed Ruleset (Cloudflare lists them as Zone Settings Read, Bot Management Read and HTTP DDoS Managed Ruleset Read). In the Token expiration field set an end date of tomorrow (a Cloudflare token does not expire unless you set an end date; the date means 00:00 UTC on that day). Continue to summary → Create Token, and copy the token (Cloudflare shows the secret one time)
The vendor's page, checked 2026-11-23Keep both for this terminal session (paste your own values in place of <token> and <zone-id>):
The vendor's page, checked 2026-11-11export CLOUDFLARE_API_TOKEN=<token> ZONE_ID=<zone-id>Save the custom rules:
The vendor's page, checked 2026-11-11curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_custom/entrypoint" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" > custom.jsonthe managed rules:
The vendor's page, checked 2026-11-11curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_managed/entrypoint" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" > managed.jsonand the rate limiting rules:
The vendor's page, checked 2026-11-11curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_ratelimit/entrypoint" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" > ratelimit.jsonthe zone settings the review reads, one answer per setting, in one file:
The vendor's page, checked 2026-11-23for s in ssl min_tls_version tls_1_3 always_use_https automatic_https_rewrites security_header security_level browser_check email_obfuscation; do curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/settings/$s" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"; done | jq -s . > zone-settings.jsonthe bot settings:
The vendor's page, checked 2026-11-23curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/bot_management" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" > bot-management.jsonand the HTTP DDoS Attack Protection settings:
The vendor's page, checked 2026-11-23curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/ddos_l7/entrypoint" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" > ddos-l7.json(the next step says what to do when Cloudflare answers 404 Not Found)Check the answers:
The vendor's page, checked 2026-11-23jq .success custom.json managed.json ratelimit.json bot-management.json ddos-l7.jsonandjq ".[].success" zone-settings.json(true means Cloudflare returned what was asked. For a false, read the reason withjq .errors custom.json, using the name of that file, or withjq ".[].errors" zone-settings.json. Cloudflare answers 404 Not Found when a ruleset cannot be found. For custom.json, managed.json or ratelimit.json the zone then has no entry point ruleset for that kind of rule, which is fine, and step 11 writes an empty list for it. For ddos-l7.json it means nobody has changed the HTTP DDoS Attack Protection settings, which Cloudflare turns on for every zone by default: delete ddos-l7.json and do not upload it. Ifjq '.result | has("fight_mode") or has("sbfm_definitely_automated")' bot-management.jsonanswers false, bot-management.json holds neither fight_mode nor sbfm_definitely_automated (Enterprise Bot Management): delete it and do not upload it. For any other reason see the errors below)
The vendor's page, checked 2026-11-11jq -n --slurpfile c custom.json --slurpfile m managed.json --slurpfile r ratelimit.json '([$m[0].result.rules // [] | .[] | select(.action == "execute")]) as $ex | {managed_rules: (if ($ex | length) == 0 then {} else {enabled: ($ex | any(.enabled != false))} end), managedRulesets: [$ex[] | {name: ({"4814384a9e5d4991b9815dcfc25d2f1f": "owasp_core_ruleset", "efb7b8c949ac4650a09736fc376e9aee": "cloudflare_managed_ruleset", "c2e184081120413c86c3ab7e14069605": "exposed_credentials_check"}[.action_parameters.id // ""] // .action_parameters.id), description, enabled: (.enabled != false), action: (.action_parameters.overrides.action // "default"), action_parameters}], managedExceptions: [$m[0].result.rules // [] | .[] | select(.action == "skip") | {description, action, expression, enabled: (.enabled != false), action_parameters}], customRules: [$c[0].result.rules // [] | .[] | {description, action, expression, enabled: (.enabled != false), action_parameters}], rateLimitRules: [$r[0].result.rules // [] | .[] | {description, action, expression, enabled: (.enabled != false)}]}' > cloudflare-waf.jsonAfter the uploads have gone through, delete the token: in the Cloudflare dashboard go to My Profile → API Tokens, find the token by its name, select the three dots next to it → Delete
The vendor's page, checked 2026-11-23
What the file looks like
JSON, one cloudflare-waf.json per zone (managed_rules, managedRulesets, managedExceptions, customRules and rateLimitRules), with zone-settings.json, bot-management.json and ddos-l7.json as Cloudflare returns them. It varies with the number of rules in the zone. The upload takes files up to 10 MB.
What it holds: From one zone: the custom WAF rules, the managed rulesets deployed on it (with Cloudflare's overrides: the ruleset-wide action, and for OWASP the score threshold and paranoia level) and their exceptions, and the rate limiting rules, in one cloudflare-waf.json; nine zone settings (SSL mode, minimum TLS version, TLS 1.3, Always Use HTTPS, Automatic HTTPS Rewrites, HSTS, security level, Browser Integrity Check, email obfuscation) in zone-settings.json; the bot settings in bot-management.json; and the HTTP DDoS Attack Protection overrides, when the zone has any, in ddos-l7.json.
Upload cloudflare-waf.json, the file step 11 writes, and next to it zone-settings.json, bot-management.json and ddos-l7.json as they are (steps 7 to 9 write them; leave out ddos-l7.json when step 10 says so). For cloudflare-waf.json the review reads one JSON file shaped like this: { "managed_rules": { "enabled": true }, "managedRulesets": [{ "name": "owasp_core_ruleset", "enabled": true, "action": "block" }], "managedExceptions": [], "customRules": [{ "description": "…", "action": "block", "expression": "…" }], "rateLimitRules": [{ "description": "…", "action": "block", "expression": "…" }] }. One zone per file: for another zone, set ZONE_ID (the token must include that zone) and repeat steps 4 to 11 before you delete the token. Run these commands in bash (macOS, Linux or WSL): in Windows PowerShell 5.1, > writes UTF-16, which jq and the upload refuse. The rules answers alone do not produce that file: Cloudflare returns custom.json, managed.json and ratelimit.json as { "result": … }, which are not meant for upload on their own.
Afterwards
Delete the token: My Profile → API Tokens, select the three dots next to the token, then Delete. With an end date set, the token also stops working at 00:00 UTC on that date. Close the terminal window or run unset CLOUDFLARE_API_TOKEN ZONE_ID , and delete custom.json, managed.json and ratelimit.json, then cloudflare-waf.json, zone-settings.json, bot-management.json and ddos-l7.json once they are uploaded.
If the export goes wrong
| What you see | The fix |
|---|---|
| jq .success prints false for the files and jq .errors shows an authentication or permission error | Check the token with Cloudflare’s own test: curl "https://api.cloudflare.com/client/v4/user/tokens/verify" --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" must answer "status": "active". If it does not, or the policy of the token does not cover this zone with the four Read permissions of step 2, create a new token as in step 2, run the export CLOUDFLARE_API_TOKEN=… line again in the same terminal window, and repeat steps 4 to 9. |
| jq: command not found | Install jq (macOS with Homebrew: brew install jq; Debian or Ubuntu, also under the Windows Subsystem for Linux (WSL): sudo apt-get install jq), then run steps 7, 10 and 11 again. |
| The upload says the file could not be read, or "We don’t recognise this as a Cloudflare WAF export" | Upload cloudflare-waf.json from step 11, which holds the three rules answers together; custom.json, managed.json and ratelimit.json are not meant for upload on their own. zone-settings.json, bot-management.json and ddos-l7.json are read as steps 7 to 9 write them; the 404 answer of step 9 is refused. |
What we read from it
- Checks run
- 24 + 6 guidance items, not counted
- Formats read
- WAF rules JSON (Cloudflare API) · Zone settings JSON (Cloudflare API) · Bot management JSON (Cloudflare API) · HTTP DDoS rules JSON (Cloudflare API)
- Releases
- 2024.1 to current
Checks run is the number of checks that reached a result on this system's own export in our tests, as the vendor table shows it.
The areas checked
- From one JSON file shaped like the note shows: custom WAF rules (customRules) and managed-rule exceptions (managedExceptions), with broad allows, rules that log and do not block, and skip rules that bypass the managed rulesets
- From that JSON file: managed rulesets (managed_rules, managedRulesets, including OWASP) and whether they block or just log, the OWASP score threshold and paranoia level from Cloudflare's overrides, and whether the Exposed Credentials Check ruleset is switched off
- From that JSON file: rate-limiting rules (rateLimitRules) and whether they just log
- From one JSON file, zone-settings.json as step 7 writes it: SSL mode, minimum TLS version, TLS 1.3, Always Use HTTPS, Automatic HTTPS Rewrites, HSTS (strict_transport_security), security level, Browser Integrity Check and email obfuscation
- From one JSON file, bot-management.json as step 8 writes it: whether Bot Fight Mode is off (fight_mode), or Super Bot Fight Mode lets definitely automated traffic through (sbfm_definitely_automated)
- From one JSON file, ddos-l7.json as step 9 writes it: the sensitivity level of the HTTP DDoS Attack Protection managed ruleset (sensitivity_level)
The grade its findings reach
Observed Findings from this file are OBSERVED: read from the system's own export and cited to the setting.
Its findings feed attack paths: each one can be a step on a path an attacker could take to your crown jewels.
Attack paths, the one change and dollar figures are MODELED. How each grade is worked out is on the method page.
What we do not read from this export
- The rules answers custom.json, managed.json and ratelimit.json on their own: upload cloudflare-waf.json, which holds all three
- Enterprise Bot Management settings: not read
- API Shield: not in this export
- DNSSEC: not in this export
- Zone settings other than the nine step 7 asks for: not in this export
- DNS records, including CAA: not in this export, so the review lists its CAA check as not assessed and raises no CAA finding
- Access policies on sensitive paths: not in this export
- Page Rules, Transform Rules and Workers
- Rulesets deployed above the zone, for all your zones at once (an Enterprise plan feature): Cloudflare returns them from a different call that needs a separate permission, so they are not in this file
- Hit counts and traffic analytics
- Complex rule expressions in depth: just literal match-everything rules are found
Limits of the reader
- The checks of this system are not counted: a check counts once a test shows it firing on a file in the layout the vendor documents.
A finding never comes from what the file does not hold: live traffic, running hosts and logs are not in a configuration export.
A Cloudflare WAF finding from the sample company
Custom rule skips the managed rules
Run the sample to see this finding with its fix and the paths it sits on.
Questions
Who can export the Cloudflare WAF configuration?
An application programming interface (API) token with four read permissions, limited to your one zone: Zone WAF Read ("Grants read access to Zone WAF"), Zone Settings Read ("Grants read access to zone settings"), Bot Management Read and HTTP DDoS Managed Ruleset Read. Cloudflare lists Zone WAF Read among the permissions the three rules calls accept, Zone Settings Read for the zone settings call, Bot Management Read for the bot settings call and HTTP DDoS Managed Ruleset Read for the ddos_l7 entry point. A user token acts for the person who creates it and inherits a subset of that person’s permissions, and Cloudflare does not let you create a token with more permissions than you hold yourself, so create it under My Profile → API Tokens while signed in as someone who can see the zone.
Does the export change anything?
The calls are GET requests that read rulesets and settings and send no change. The steps create one API token in your Cloudflare profile, which stays valid until its end date or until you delete it. Cloudflare Audit Logs record user actions made through the dashboard and the API.
Does the file hold passwords or keys?
No Cloudflare credential is written to the file. Rule expressions and descriptions are kept in clear text, and an expression can hold a secret key (as in the Cloudflare example is_timed_hmac_valid_v0("mysecrettoken", …)), required header values, allowed IP addresses and internal paths. The token is not in the file; it can stay in your shell history from the export line in step 3. With redaction on (the default), the passwords, keys and tokens the review recognises are replaced with a placeholder before anything is stored; the check before upload shows how many it found.