
Summary
Key points of this document
- 1. Background and Challenges: Indiscriminate Bots Attacking Web Servers and Targeted Scans on PHP/WordPress
- 2. Technical Architecture and Detection Mechanisms of Cloudflare Bot Fight Mode
- 3. On-site Implementation Procedures and Specification Boundaries: Differences Between Free (BFM) and Paid (SBFM) Versions
Overview
Bot Countermeasures at the Edge—Specification Boundaries of Cloudflare Bot Fight Mode and the Evolution of PHP Infrastructure
1. Background and Challenges: Indiscriminate Bots Attacking Web Servers and Targeted Scans on PHP/WordPress
Key Points
- Automated scans that indiscriminately traverse the entire web, often linked to vulnerability disclosures and security advisories, occur daily.
- If requests directly reach the application or OS layers, PHP-FPM processes and DB connections can be exhausted, leading to service outages.
- Beyond intrusion prevention, perimeter defense that blocks unnecessary traffic at the edge before it reaches the origin server is essential.
Web servers exposed on the internet are constantly subjected to indiscriminate automated scans searching for known vulnerabilities and misconfigurations, in addition to targeted attacks against specific companies or services. Platforms like PHP and WordPress, widely used globally, are particularly attractive targets for attackers.
As recently seen with security updates from the official PHP team, the discovery and correction of new vulnerabilities are unavoidable for any software. However, even during the period between vulnerability disclosure and administrators applying patches or updating middleware, requests containing exploit code are simultaneously sent from botnets worldwide.
The problem with such indiscriminate scans is not limited to unauthorized access itself. WordPress administration screens (wp-login.php) and XML-RPC (xmlrpc.php), and a large volume of probes (explorations) to non-existent PHP scripts can monopolize PHP-FPM worker processes behind web servers (Apache or Nginx) and strain database connection pools. Consequently, responses to legitimate general readers and business users are delayed, and in the worst cases, 502/504 errors (service downtime) occur due to server resource exhaustion.
While measures like log monitoring and IP blocking (e.g., fail2ban) within individual servers are effective, they already consume CPU and memory on the host machine by the time a TCP connection is established and request headers are received and parsed. To counter this, a design that filters out automated traffic at the network edge (CDN layer) before it reaches your origin server is extremely effective.
2. Technical Architecture and Detection Mechanisms of Cloudflare Bot Fight Mode
Key Points
- In a global edge network, bots are identified and handled before requests reach the origin.
- Combines IP reputation, machine learning heuristics, browser fingerprinting, and behavioral analysis engines.
- Transparently executes JavaScript Challenge or Managed Challenge (e.g., Turnstile) for automatically detected suspicious communications.
Widely used for bot countermeasures at the edge layer is "Bot Fight Mode" provided by Cloudflare. Cloudflare has edge servers (Anycast network) distributed across hundreds of cities worldwide, relaying vast amounts of web traffic across the entire internet. Leveraging this geographical and scale advantage, it learns the latest threat signatures from hundreds of billions of requests observed daily and evaluates communications at the edge in real-time.
Bot Fight Mode's detection engine does not rely solely on a single static IP list. It calculates a "Bot Score" (confidence level from 1 to 99) by combining multiple layers:
IP Reputation and Threat Intelligence:
Real-time matching of known attack source IPs, hosting providers and proxies, Tor exit nodes, and network ranges (ASNs) where scan activity has recently been observed.
Machine Learning and Heuristics Analysis:
Analysis of request header order, TLS client hello characteristics (JA3/JA4 fingerprints), and HTTP/2 or HTTP/3 frame transmission patterns.
Browser Automation Tool Detection:
Identification of JavaScript execution environment traces and Canvas/WebGL fingerprints left by automation frameworks such as Headless Chrome, Puppeteer, and Selenium.
Behavioral Analysis:
Tracking request frequency from the same session or specific IP, unnatural page transitions, and behaviors deviating from typical human browsing patterns.
Based on these detection mechanisms, communications deemed suspicious are presented with a "Managed Challenge" before requests are passed to the server. Managed Challenge is a system that dynamically selects and executes non-interactive cryptographic puzzles (JavaScript Challenge) or interactive authentication via Cloudflare Turnstile, depending on the visitor's context. Legitimate browsers can pass the automatic verification in a few milliseconds with almost no user awareness, while attack bots using simple HTTP clients or scripts are reliably stopped here, imposing no load whatsoever on the origin server's PHP processes.
3. On-site Implementation Procedures and Specification Boundaries: Differences Between Free (BFM) and Paid (SBFM) Versions
Key Points
- The free version of Bot Fight Mode is a global toggle for the entire zone and cannot exclude specific API paths with WAF Skip rules.
- In the paid version, Super Bot Fight Mode (SBFM), WAF Custom Rules (
http_request_sbfmSkip) allow for granular exclusion of specific APIs and Webhooks. - Prior design and communication testing are essential to avoid mistakenly blocking Webhook receptions, external integration APIs, or monitoring probes.
When implementing Cloudflare's bot countermeasures, what on-site engineers need to understand most accurately are the functional boundaries between the "free version (Bot Fight Mode: BFM)" and the "paid version (Super Bot Fight Mode: SBFM)."
Specifications and Limitations of Free Bot Fight Mode (BFM)
Bot Fight Mode, provided in Cloudflare's Free plan, can be activated from the dashboard's Security > Bots by simply toggling one switch "On," immediately applying edge defense to the entire zone (domain). While it offers high defense with zero configuration effort, it comes with the following strong limitations:
- Exclusion via WAF Skip rules or Page Rules is not possible.:
The challenge action of the free version of BFM cannot be skipped with the 'Skip (Bypass)' action of WAF Custom Rules. This means that flexible condition settings, such as /api/v1/* or /webhooks/*) are not provided, which would allow specific URL paths to be excluded from Bot Fight Mode.
- Webhook blocking risk from external services:
Webhook notifications from payment services (Stripe, PayPal, etc.) and automatic communications from external SaaS (GitHub, Slack, etc.) cannot execute JavaScript because they are not browsers. Therefore, there is a risk of them being mistakenly identified as bots by BFM and blocked with a 403 error or a challenge screen.
- Application judgment:
While the free version of BFM is dramatically effective for corporate sites, blogs, and landing pages that are entirely based on browser viewing, systems with endpoints that directly receive server-to-server API communications or webhooks require careful assessment of the impact range before implementation.
Practical WAF Design with Paid Super Bot Fight Mode (SBFM)
Super Bot Fight Mode (SBFM), available with Pro plans and above, classifies bots into 'Definitely Automated' and 'Likely Automated' categories. For each category, different actions such as 'Block', 'Managed Challenge', 'Interactive Challenge', and 'Allow' can be set.
A further decisive difference is that you can create rules in WAF Custom Rules to skip (bypass) the execution of http_request_sbfm point.
# WAF Custom Rule Configuration Example (SBFM Bypass for Webhook Endpoints)
# Condition (Expression):
(http.request.uri.path eq "/api/webhooks/payment" and http.request.method eq "POST" and ip.src in {198.51.100.0/24})
# Action:
Skip -> WAF components to skip:
[x] Super Bot Fight ModeBy defining Skip rules that combine trusted external service IP ranges, custom headers (pre-shared secrets), and request paths, it becomes possible to design a system that completely guarantees legitimate API communication and Webhook delivery while robustly protecting the entire site's HTML and administration screens from bot scans.
Furthermore, on the API side, it is a fundamental principle of robust system operation to not solely rely on WAF, but to always perform HMAC signature verification of Webhook payloads (Stripe-Signature etc.) and ensure idempotency (considering network disconnections and retries) as a fundamental principle of robust system operation.
4. Deep Respect for PHP and its Contributions to Web Democratization
Key points
- PHP dramatically lowered the barrier to learning, serving as the largest gateway for junior engineers worldwide to enter the IT industry.
- We express deep respect for its history and achievements, including WordPress, which have continuously supported the foundation of modern internet society.
- PHP 8 series (enhanced type system, JIT, mature OPcache) is robust, and the simplistic evaluation of it being 'dead content' is not engineeringly sound.
When discussing the evolution of edge security and cloud architecture, simplistic statements like 'PHP is old' or 'it's a legacy language' are sometimes made. However, if we honestly look back at the history of software engineering and the internet, PHP's contributions to the world are immeasurable.
PHP's greatest achievement is 'dramatically lowering the learning barrier for web development and democratizing technology'.. By simply writing <?php echo "Hello World"; ?> and deploying it to a server via FTP, its overwhelming ease of use immediately made it a vast gateway for young people and beginners worldwide, who lacked special development environments or expensive tools, to enter the world of programming. It is not uncommon for many senior engineers and architects active in today's megatechs and leading companies to have taken their first steps with PHP.
Furthermore, it was the PHP ecosystem that supported over 40% of all websites worldwide, including WordPress, and also powered Facebook from its early days to its growth into a large-scale platform. Without PHP, an internet society where everyone can freely disseminate information and small businesses and individuals can conduct web business at low cost, as we see today, would not have been realized.
Furthermore, the recent evolution of PHP cannot be overlooked. Through continuous language specification improvements from PHP 7 to 8 series, it has gained expressive power comparable to modern statically typed languages, including union types, intersection types, Enums, readonly properties, and constructor property promotion. With the JIT (Just-In-Time) compiler introduced in PHP 8.0 and OPcache optimizations, it boasts top-class execution speed among scripting languages. Modern development environments like Laravel, combined with static analysis tools (PHPStan and Psalm) and automated testing, have matured into an environment capable of building extremely disciplined and robust software.
The assessment 'PHP is bad' is merely a superficial view that misunderstands the language's evolution and actual operational realities. We should continue to pay deep respect to PHP, a great language and ecosystem that built the foundation of the modern web and nurtured countless engineers.
5. From OS Management to Reproducible Immutable Serverless Infrastructure
Key points
- The continuous utilization of PHP and the modernization of its execution infrastructure (containers, serverless) are perfectly compatible.
- Replacing manual changes to individual hosts via SSH with pre-validated immutable containers and serverless solutions enhances reproducibility.
- While incorporating the edge-managed common infrastructure built by megatechs with massive investments, it is necessary to assess the trade-offs in latency and dependencies.
The excellence of the PHP language and the appropriateness of 'manually maintaining individual Linux servers for a long time' as its execution environment must be considered separately.
In traditional hosting environments, it was common practice to log in via SSH to virtual machines (VMs) or dedicated servers and directly apply OS package updates, PHP minor version switches, Nginx configuration changes, and so on. However, this method has a fundamental problem: as servers operate, environmental differences (configuration drift) accumulate 'like a snowball,' making it difficult to identify the cause of failures and roll back in case of issues.
In modern infrastructure design, instead of manually modifying servers, the standard approach is to replace the entire pre-built and validated image with a new environment whenever changes occur, known as 'Immutable Infrastructure'. philosophy has become the standard.
| Execution Platform | Scope of Management Responsibility | Benefits | Main Constraints/Considerations |
|---|---|---|---|
| VM / Traditional Shared Server | Host OS, Web Server, PHP Environment, App, DB, Monitoring | Traditional assets and file arrangements work as is | Manual configuration differences, operational burden of patch application |
| Managed Containers (e.g., Cloud Run) | Dependencies within containers, app code, environment variables | Automatic infrastructure scaling, full reproducibility via container images | Abolition of local file persistence (statelessness required) |
| Edge Serverless (e.g., Workers) | Application code, data placement, distributed design | Global ultra-low latency, near-zero cold starts, complete elimination of OS maintenance | Proprietary runtime constraints, latency considerations for external DB connections |
Even for PHP applications, by containerizing them using Dockerfiles and deploying them to managed container platforms like Google Cloud Run, you can fully leverage your PHP code assets while enjoying the benefits of immutable infrastructure. In this case, a 'stateless' design is required to externalize writes to local disks (session files, image storage) to services like Cloudflare R2, Cloud Storage, or managed Redis. However, once this boundary is established, the time spent worrying about infrastructure patching and scaling will be dramatically reduced.
Furthermore, edge serverless environments, exemplified by Cloudflare Workers, completely abstract away the OS layer using V8 isolate technology, enabling global delivery with millisecond-level latency. Properly utilizing the data center clusters and edge networks built with massive investments by global megatechs like Cloudflare and Google Cloud is an engineering-wise choice to avoid reinventing the wheel and to achieve the strongest security and availability.
At the same time, the high operational capabilities and sincere attitudes of domestic server vendors, who provided rapid patches and thoughtful announcements during recent incidents, should also be highly praised. Moving forward, it is expected that world-class best practices such as automated perimeter defense, API-driven infrastructure management, and immutable execution environments will become more widespread, both domestically and internationally, leading to the growth of Japan's entire Web ecosystem into something more robust and commendable.
6. Decision Axes to Confirm for Defense and Technology Selection
Key Points
- Clearly separate responsibilities at each layer: attack entry point (edge), execution platform, application, and data.
- When implementing bot countermeasures, verify both legitimate traffic (Webhook/API) and out-of-condition traffic.
- Technology selection and infrastructure migration should be decided based on operational effort, total cost of ownership, and rollback feasibility, not trends.
To enhance system security and reliability, the decision axes that on-site engineers and architects should confirm in practice are organized as follows:
| Judgment Perspective | Objective Evidence to Confirm | Specific Verification Action |
|---|---|---|
| Impact of Bot Scans | Number of requests reaching origin, CPU utilization, 5xx error rate | Cross-referencing Cloudflare Analytics with origin access logs |
| Scope of Edge Defense Application | API paths, Webhook reception URLs, URL separation for admin screens | Selection between full application of free BFM or custom WAF Skip by SBFM |
| Preservation of Legitimate Traffic | Webhook reception success rate, error logs from external API clients | Test environment verification before production deployment and connectivity testing in staging |
| Infrastructure Reproducibility | One-to-one correspondence between Git revision and deployment artifact (image) | Prohibit manual SSH login and enforce automatic reflection via CI/CD pipeline |
| Degree of Statelessness Achieved | Session persistence during container restart/scale-out | Separate file storage to object storage (R2/GCS) |
| Disaster Recovery and Rollback | Time required for rollback execution and data integrity | Pre-practice of immediate traffic switching procedures to old images |
Security is not something that can be completed with a single tool or language. Only when traffic filtering at the edge (Cloudflare Bot Fight Mode), immutable execution platforms (containers/serverless), and robustly typed application design are harmonized, can truly attack-resilient and maintainable web services be achieved.
While appreciating the rich development culture that PHP has fostered, let's actively incorporate the powerful defense layers provided by modern cloud technologies and together build secure and reliable systems.


