PHP 8.6 tightens session security by default, but old config files can switch the protections off
PHP 8.6 was released on Thursday on the language's usual yearly schedule. It arrives after a difficult month: a swarm of vulnerabilities found since October allowed unauthenticated attackers to crash PHP workers or run arbitrary code on the server. Users of PHP-based applications, including WordPress, Laravel and Symfony, had to scramble to update.
The PHP core team and the PHP Foundation responded with coordinated patched releases (8.5.13, 8.4.28, 8.3.37, 8.2.36 and the new 8.6) that closed seven critical remote code execution flaws at once. In a retrospective, the Foundation admitted that consensus-driven gridlock had stalled complex fixes for months, and promised faster patches if vulnerabilities leak before the agreed deadline.
Version 8.6 also hardens three session settings, following a proposal from core developer Jörg Sowa. Strict Mode means PHP will no longer accept session IDs it did not create, which stops an attacker planting a made-up ID on a victim. The HttpOnly flag is now added to session cookies by default, so client-side JavaScript cannot read the session ID. SameSite handling means session cookies are withheld on cross-site POST requests, subrequests and iframes, and sent only on same-site requests and top-level GET navigations such as clicking a normal link. Together these should make session hijacking and cross-site request forgery harder. They will not stop remote code execution.
PHP will also be stricter with strings containing null bytes, often throwing an error instead of silently passing them through, since null bytes are a favoured trick for triggering code execution. Some functions, such as those that close files or copy data, will now return false when they fail.
There is a catch for administrators. The new defaults apply only where settings are not specified elsewhere. As engineer Rajekevin Dourepoulle notes, a reused php.ini, such as one from an Ansible template or a Dockerfile, with an explicit session.use_strict_mode = 0 line will override the new default, so upgrading gains nothing.
Why it matters
Teams that treat a PHP version upgrade as an automatic security improvement are exposed: configuration copied from older servers, containers or templates can quietly keep the weak session settings in place. The assumption that new defaults apply everywhere breaks wherever php.ini is managed by automation, so the decision is to audit configuration, not just version numbers. The hardening also does nothing against the code execution flaws, so patching remains a separate job.
What to do
- Patch to PHP 8.5.13, 8.4.28, 8.3.37, 8.2.36 or 8.6 to close the seven critical remote code execution flaws.
- Search your php.ini files, Ansible templates and Dockerfiles for explicit session.use_strict_mode = 0 lines and remove them.
- Check that application and framework settings are not overriding the HttpOnly and SameSite session cookie defaults.
- Test applications for new errors from null byte handling and functions that now return false on failure.