Cloudflare — API Token
Cloudflare API tokens control DNS, CDN, Workers, and security settings. Exposure can allow DNS hijacking, traffic interception, or disabling DDoS protection.
Immediate Action Required
Deleting a leaked credential from a repository does not invalidate it. Assume it has already been copied. Follow the revocation steps below immediately, then investigate for unauthorized access.
What Is This Credential?
Cloudflare API tokens control DNS, CDN, Workers, and security settings. Exposure can allow DNS hijacking, traffic interception, or disabling DDoS protection.
Permissions Granted
- DNS record management
- Zone configuration
- Workers deployment
- Firewall and WAF rules
- SSL/TLS certificate management
Exposure & Blast Radius
- DNS record modification enabling domain hijacking
- Disabling DDoS protection and WAF rules
- Deploying malicious Workers scripts
- SSL certificate manipulation
- Traffic interception via DNS manipulation
Immediate Response Steps
Revoke the token
Go to Cloudflare Dashboard → My Profile → API Tokens → Revoke the token.
Audit DNS records immediately
Check all DNS records for unauthorized modifications, especially A, CNAME, and MX records.
Review audit logs
Check Cloudflare Audit Log for all API actions taken with the token.
Create a replacement token
Generate a new token with minimal required permissions using Cloudflare's token templates.
Revocation vs Rotation
Revocation
Revoke at dash.cloudflare.com/profile/api-tokens. Revocation is immediate.
Rotation
Create a new token with appropriate permission scopes. Use Cloudflare's built-in token templates for common use cases.
Grace Period & Session Persistence
Grace Period
None. Token revocation is immediate.
Session Persistence
Cloudflare API tokens are stateless. No session invalidation required beyond token revocation.
Investigation Checklist
- Review Cloudflare Audit Log for all API actions
- Check DNS records for unauthorized changes
- Review Workers scripts for malicious deployments
- Check firewall rules for unauthorized modifications
- Look for new page rules or redirect rules
- Review SSL/TLS settings
Recovery Steps
- Restore any modified DNS records
- Re-enable any disabled security features
- Review and remove any unauthorized Workers
- Update all services using the old token
- Enable Cloudflare's anomaly detection alerts
Prevention
- Use scoped tokens with minimal permissions
- Set token expiration dates
- Use IP address filtering on tokens
- Enable Cloudflare audit log alerts
- Store tokens in a secrets manager
Sources & Evidence
Always verify critical instructions with official provider documentation before taking action. Provider behavior may change without notice.
Found an issue with this playbook?
If these instructions are incorrect, outdated, or missing important information, please report it so we can improve the playbook.
Report an Issue on GitHub