PHP 8.6 tightens session security defaults, but old settings can override them

PHP 8.6 tightens session security defaults, but old settings can override them

PHP’s developers released version 8.6 on Thursday, tightening three session security defaults alongside fixes for seven critical remote code execution flaws.

Administrators may not receive the new default protections simply by upgrading. Settings in applications, frameworks or existing php.ini files can override them.

Backend software engineer Rajekevin Dourepoulle highlighted that risk in a blog post. A deployment retaining session.use_strict_mode = 0, for example, will keep Strict Mode disabled after moving to PHP 8.6.

The session changes address session hijacking and cross-site request forgery. They are separate from the patches for remote code execution vulnerabilities.

Three changes to session handling

Core developer Jörg Sowa proposed the defaults in June, before the recent series of PHP security disclosures. His proposal covered Strict Mode, HttpOnly and SameSite.

Strict Mode now rejects uninitialized session IDs rather than accepting an identifier planted by an attacker. With PHP’s built-in files handler, an ID without a matching session file prompts generation of a fresh random ID.

PHP also adds the HttpOnly flag to its session Set-Cookie header by default. That prevents client-side JavaScript from reading the session ID, reducing one route for stealing it and impersonating a user.

The SameSite change limits when browsers send session cookies across sites. Cookies will be withheld from cross-site POST requests, subrequests and iframes.

They will still accompany same-site requests and top-level GET navigation, such as following a normal link. The restriction is intended to make forged authenticated requests harder to carry out.

Security fixes follow a difficult month

The annual release follows vulnerabilities disclosed since October that allowed unauthenticated attackers to crash PHP workers or execute arbitrary server code. Administrators running PHP-based applications, including WordPress, Laravel and Symfony, had to update their PHP installations.

PHP’s core development community and the PHP Foundation coordinated the security releases. Versions 8.5.13, 8.4.28, 8.3.37, 8.2.36 and 8.6 closed seven critical remote code execution flaws.

In an October retrospective, the foundation acknowledged that consensus-driven decision-making had delayed complex fixes for months. It pledged faster patch releases if vulnerability details leaked before an agreed disclosure deadline.

PHP 8.6 also changes how the engine handles strings containing null bytes (\0). In many cases, it now raises an error instead of silently accepting them.

This matters because C functions treat a null byte as the end of a string. Data after that byte can be ignored, creating opportunities for exploitation.

Some file-closing and data-copying operations also report failures more explicitly. They now return false when they fail or stop prematurely, giving developers a signal for handling potential data integrity problems.

New tools beyond security

Partial Function Application lets developers pre-fill some arguments and create a reusable closure from a function.

The release also adds a native polling API for event-driven networking. A new Duration class measures elapsed time over more than 250 years.

The new clamp() function keeps a value within a specified range. For administrators, however, the immediate deployment issue is whether existing configuration files preserve the older, less restrictive session settings.

Got Something To Say?

Your email address will not be published.