Cloudflare Worker (TypeScript) cron that syncs sefinek/Cloudflare-WAF-Expressions WAF custom rules + IP blocklist (SniffCat + AbuseIPDB) — 4x daily, WAF does the blocking

TypeScript Cloudflare Worker cron that keeps sefinek/Cloudflare-WAF-Expressions in sync — no VPS, no PM2.
The Worker runs scheduled (0 9,15,18,22 * * *) and pushes WAF Custom Rules (Parts 1–5) + IP List (sefinek_cf_waf merged from ip-blocklist.txt + SniffCat + AbuseIPDB) to http_request_firewall_custom. WAF does the blocking; Worker only updates.
Ported from
sefinek/Cloudflare-WAF-Expressionsindex.js/data/services/cloudflare/updateWAFRules.js+syncIPList.js—fetch+scheduledinstead ofaxios+cron+simple-git+PM2.
MAX_EXPRESSION_LENGTH 4096, RULE_CAPS per plan, normalize() diff, preserves user rulessefinek_cf_waf (10k Free cap auto-handled, trims AbuseIPDB tail) — cursor pagination, bulk opscfut_... with CF_ZONE_IDS/CF_ZONE_NAMES stub) and Account tokens (cfat_... with Filter Lists:Edit + WAF:Edit) — adaptive: cfut_... auto-strips ip.src in $... if list unavailable, cfat_... syncs full listmedia-cdn1.seabuddy.co default via ALLOWLIST → not (allowlist) and (part))X-Secret-Token) + AbuseIPDB (Key), PHP_SUPPORT/WORDPRESS_SUPPORT toggles, EXCLUDED_ZONESGET /health, GET /sync?dryRun=1 (no auth), POST /sync (Bearer)npm install
# required secrets
npx wrangler secret put CF_API_TOKEN # cfat_... (Account) or cfut_... (zone-scoped)
npx wrangler secret put CF_ACCOUNT_ID # 32-char hex from dash.cloudflare.com/<id>/
# optional intel (recommended)
npx wrangler secret put SNIFFCAT_API_TOKEN
npx wrangler secret put ABUSEIPDB_API_KEY
npx wrangler deploy
wrangler.toml [vars]:
CF_IP_BLOCKLIST_NAME = "sefinek_cf_waf" # "" to disable list
ALLOWLIST = 'http.host eq "media-cdn1.seabuddy.co"'
PHP_SUPPORT = "false"
WORDPRESS_SUPPORT = "false"
CF_ZONE_IDS = "0115c6fc4aab62dff1c8c1730b17cea9" # for cfut_... zone-scoped
CF_ZONE_NAMES = "seabuddy.co"
SNIFFCAT_CONFIDENCE_MIN = "80"
SNIFFCAT_LIMIT = "2000"
ABUSEIPDB_CONFIDENCE_MIN = "75"
ABUSEIPDB_LIMIT = "8000"
To sync all zones with a cfat_..., clear CF_ZONE_IDS/CF_ZONE_NAMES.
npx wrangler dev --test-scheduled
curl "http://localhost:8787/__scheduled?cron=0+9+*+*+*"
curl "http://localhost:8787/sync?dryRun=1"
curl -X POST "http://localhost:8787/sync" -H "Authorization: Bearer $CF_API_TOKEN"
Create Account API Token (cfat_...) at dash.cloudflare.com/<account_id>/config/api/tokens → Custom:
THE SOCIAL MARITIME PTE LTD → Filter Lists:Edit, Account:Readseabuddy.co (or All zones) → WAF:Edit, Zone:ReadFor WAF-only with cfut_... (zone WAF:Edit only), IP list will be skipped and Part 4's ip.src in $... stripped automatically — WAF Parts 1–5 still sync.
Original (sefinek) | This Worker |
|---|---|
Node 20+ cron PM2 simple-git nodemailer axios | fetch + scheduled |
rules/expressions.md git-pulled | Bundled src/assets/bundled.ts or live RULES_SOURCE_URL |
GET /zones enumeration | + stubbed CF_ZONE_IDS for cfut_... |
syncIPList throws on auth | Skipped with warning, WAF retry without list |
DavidJKTofan/cf-icloud-private-relay-ip-list-manager (Worker cron IP List)klinge/crowdsec-cloudflare-synchomieyangg/cloudflare_waf_multi_zone_ci_exampleseabuddy.co (0115c..., Pro, 20-rule cap) — https://cf-waf-sync.super-dream-1056.workers.devGPL-3.0 — same as upstream.
Stars
0
Forks
0
Watchers
0
Primary Language
TypeScript
# 1.0.0 (2026-09-16) ### Bug Fixes * add missing semantic-release plugins changelog + git ([7b4cabf](https://github.com/ayushjaipuriyar/cf-waf-sync/commit/7b4cabfd23d786d807af72101a93ff40f78c0eb1)) * ci pnpm minimumReleaseAge 0 for fresh Cloudflare releases ([b659256](https://github.com/ayushjaipuriyar/cf-waf-sync/commit/b65925618b38510e42068bf92fe1aa51396cbca4)) ### Features * harden worker — zod, retry, concurrency, auth, KV audit, tests ([44d54b9](https://github.com/ayushjaipuriyar/cf-waf-sync/commit/44d54b9d2787353a25176ecce77cd5fbf1ea166b)) * initial release — Cloudflare Worker (TS) cron for sefinek WAF sync ([d635349](https://github.com/ayushjaipuriyar/cf-waf-sync/commit/d63534981c480a839c01fda75c26aff0053b009c))