Welcome to the WAF Checker project. This document provides essential information for AI agents working on this codebase.
WAF Checker is a security testing tool designed as a Cloudflare Worker using TypeScript. It allows users to test Web Application Firewalls (WAF) by sending various attack payloads and analyzing the responses.
- Runtime: Cloudflare Workers
- Language: TypeScript
- Frontend: HTML/JS/CSS (Bootstrap 5) served as static assets.
- Development: Wrangler CLI
- Testing: Vitest with
@cloudflare/vitest-pool-workers
/app/src/api.ts: Entry point and request router./app/src/handlers/: Contains logic for specific API endpoints (check, WAF detect, batch, etc.)./app/src/payloads.ts: Base attack payloads and categories./app/src/advanced-payloads.ts: Advanced evasion techniques and WAF-specific payloads./app/src/waf-detection.ts: Fingerprinting logic for various WAF vendors./app/src/encoding.ts: Utilities for payload obfuscation./app/src/utils/security.ts: Security utilities, primarily SSRF protection./app/src/static/: Frontend assets (served viaenv.ASSETS)./app/test/: Unit and integration tests.
- Run Locally: From the root directory, run
npx wrangler dev. This uses the rootwrangler.tomlwhich binds static assets. - Run Tests: Navigate to the
appdirectory and runnpm test.
Any endpoint that accepts a target URL MUST validate it using isValidTargetUrl from app/src/utils/security.ts. This is critical to prevent the worker from being used as an SSRF proxy to internal services.
import { isValidTargetUrl } from './utils/security';
if (url && !isValidTargetUrl(url)) {
return new Response(JSON.stringify({ error: 'Invalid URL or restricted IP' }), { status: 400 });
}- Base Payloads: Add to
app/src/payloads.ts. UseParamCheckfor query/body params,FileCheckfor path-based attacks, andHeaderfor header-based attacks. - Evasion: Add complex or WAF-specific bypasses to
app/src/advanced-payloads.ts.
When adding support for a new WAF:
- Update
app/src/waf-detection.tswith relevant header signatures or body patterns. - Update the
WAF_BYPASS_PAYLOADSinapp/src/advanced-payloads.tsif specific bypasses are known.
The frontend is a single-page application. Update app/src/static/main.js for UI logic and app/src/static/index.html for layout changes.
Before submitting any changes to API handlers:
- Check SSRF Validation: Ensure
grep "isValidTargetUrl" app/src/handlers/*.tsshows that all new URL-accepting handlers use the validation utility. - Verify Tests: All tests in
app/test/must pass.