Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/waf/README.md
1# Cloudflare WAF Expert Skill Reference23**Expertise**: Cloudflare Web Application Firewall (WAF) configuration, custom rules, managed rulesets, rate limiting, attack detection, and API integration45## Overview67Cloudflare WAF protects web applications from attacks through managed rulesets and custom rules.89**Detection (Managed Rulesets)**10- Pre-configured rules maintained by Cloudflare11- CVE-based rules, OWASP Top 10 coverage12- Three main rulesets: Cloudflare Managed, OWASP CRS, Exposed Credentials13- Actions: log, block, challenge, js_challenge, managed_challenge1415**Mitigation (Custom Rules & Rate Limiting)**16- Custom expressions using Wirefilter syntax17- Attack score-based blocking (`cf.waf.score`)18- Rate limiting with per-IP, per-user, or custom characteristics19- Actions: block, challenge, js_challenge, managed_challenge, log, skip2021## Quick Start2223### Deploy Cloudflare Managed Ruleset24```typescript25import Cloudflare from 'cloudflare';2627const client = new Cloudflare({ apiToken: process.env.CF_API_TOKEN });2829// Deploy managed ruleset to zone30await client.rulesets.create({31zone_id: 'zone_id',32kind: 'zone',33phase: 'http_request_firewall_managed',34name: 'Deploy Cloudflare Managed Ruleset',35rules: [{36action: 'execute',37action_parameters: {38id: 'efb7b8c949ac4650a09736fc376e9aee', // Cloudflare Managed Ruleset39},40expression: 'true',41enabled: true,42}],43});44```4546### Create Custom Rule47```typescript48// Block requests with attack score >= 4049await client.rulesets.create({50zone_id: 'zone_id',51kind: 'zone',52phase: 'http_request_firewall_custom',53name: 'Custom WAF Rules',54rules: [{55action: 'block',56expression: 'cf.waf.score gt 40',57description: 'Block high attack scores',58enabled: true,59}],60});61```6263### Create Rate Limit64```typescript65await client.rulesets.create({66zone_id: 'zone_id',67kind: 'zone',68phase: 'http_ratelimit',69name: 'API Rate Limits',70rules: [{71action: 'block',72expression: 'http.request.uri.path eq "/api/login"',73action_parameters: {74ratelimit: {75characteristics: ['cf.colo.id', 'ip.src'],76period: 60,77requests_per_period: 10,78mitigation_timeout: 600,79},80},81enabled: true,82}],83});84```8586## Managed Ruleset Quick Reference8788| Ruleset Name | ID | Coverage |89|--------------|----|---------|90| Cloudflare Managed | `efb7b8c949ac4650a09736fc376e9aee` | OWASP Top 10, CVEs |91| OWASP Core Ruleset | `4814384a9e5d4991b9815dcfc25d2f1f` | OWASP ModSecurity CRS |92| Exposed Credentials Check | `c2e184081120413c86c3ab7e14069605` | Credential stuffing |9394## Phases9596WAF rules execute in specific phases:97- `http_request_firewall_managed` - Managed rulesets98- `http_request_firewall_custom` - Custom rules99- `http_ratelimit` - Rate limiting rules100- `http_request_sbfm` - Super Bot Fight Mode (Pro+)101102## Reading Order1031041. **[api.md](api.md)** - SDK methods, expressions, actions, parameters1052. **[configuration.md](configuration.md)** - Setup with Wrangler, Terraform, Pulumi1063. **[patterns.md](patterns.md)** - Common patterns: deploy managed, rate limiting, skip, override1074. **[gotchas.md](gotchas.md)** - Execution order, limits, expression errors108109## See Also110111- [Cloudflare WAF Docs](https://developers.cloudflare.com/waf/)112- [Ruleset Engine](https://developers.cloudflare.com/ruleset-engine/)113- [Expression Reference](https://developers.cloudflare.com/ruleset-engine/rules-language/)