Cloudflare WAF Adds Protection Against phpAfterShell Critical PHP Flaw
Cloudflare has deployed WAF rules to protect against phpAfterShell, a critical vulnerability in PHP's default session handler that allows remote code execution on affected servers.

By Elena Rostova, Cybersecurity
2 min read
Cloudflare has added managed WAF rules to protect against phpAfterShell, a critical vulnerability in PHP's default session handler that can lead to remote code execution on affected servers.
The vulnerability, tracked as CVE-2026-XXXXX, was publicly disclosed this week. It exploits how PHP's default file-based session handler processes session data, allowing an attacker to inject malicious code that executes when the session is read. The flaw affects PHP versions 8.1 through 8.3 under certain configurations.
Cloudflare says its security team analysed the exploit pattern and deployed protective rules globally within hours of disclosure. The rules are active for all customers using Cloudflare's WAF, including those on the free plan. The managed ruleset blocks requests that attempt to manipulate session identifiers or inject payloads through the session mechanism.
According to Cloudflare's blog post, the WAF rules target the specific deserialisation pathway used by the exploit. The company reports seeing active exploitation attempts in the wild since disclosure, with the highest volume targeting hosting providers and shared infrastructure.
Site administrators using PHP applications behind Cloudflare do not need to take additional action; the managed rules apply automatically. However, Cloudflare recommends updating PHP to the latest patched version as the primary remediation, since the WAF rules are a mitigation layer, not a fix for the underlying code.
The phpAfterShell vulnerability highlights the risk of deserialisation attacks in widely deployed language runtimes. PHP's session handler is enabled by default, making the attack surface broad across content management systems, frameworks and custom applications.
Sources
- 1Cloudflare Blog: How Cloudflare WAF helps protect against phpAfterShellblog.cloudflare.com