devops
Like a parent disciplining a misbehaving child, PHP’s annual update clamps down on loose default behaviors to curb malicious hacker horseplay.
On Thursday, PHP version 8.6 was released on its usual yearly schedule, popping up as if the web scripting language hadn’t been under intense scrutiny this past month.
For those who missed it: a swarm of unearthed vulnerabilities has plagued PHP since October, allowing unauthenticated attackers to crash PHP workers or execute arbitrary code on the server. Users of every PHP-based application, including WordPress, Laravel, and Symfony, had to scramble to update their PHP instances.
The PHP core development community, along with the PHP Foundation, responded with a coordinated release of patched versions of PHP (8.5.13, 8.4.28, 8.3.37, 8.2.36 and the new 8.6) that closed seven critical remote code execution (RCE) flaws in one sweep.
In addition to patching specific exploitable holes in the PHP engine, the new version of PHP also tamps down some of PHP’s historically liberal configuration settings.
Lucky for PHP, and for the rest of us, core developer Jörg Sowa called out these lax settings in June, when he posted a proposal to set more security-friendly defaults.
Sowa saw that three configuration settings of PHP’s session extension – Strict Mode, HttpOnly, and SameSite – were designed to boost security but shipped “with defaults that leave applications unnecessarily exposed.”
No cookies for impostors
In a retrospective posted last month, the PHP Foundation admitted that consensus-driven gridlock had stalled complex fixes for months and vowed to get patches out the door sooner, should the vulnerabilities leak ahead of the agreed-upon deadline.
Code-wise, Sowa’s proposal to harden PHP settings was accepted for PHP 8.6. These changes won’t stop the flood of AI-generated CVEs, but at least these holes will be more difficult to exploit.
For Strict Mode, PHP will no longer accept uninitialized session IDs that it didn’t create itself. Before, an attacker could just plant a made-up session ID on the victim to gain entry. “The built-in files handler checks whether a session file for that ID exists on disk; because an attacker-planted ID has no corresponding file, a fresh random ID is generated instead,” Sowa wrote.
Furthermore, PHP will now, by default, add the HttpOnly flag to its session Set-Cookie header, blocking client-side JavaScript from reading the session ID, which could otherwise be stolen to masquerade as the user. Believe it or not, any script on the page could read it before.
Finally, the server will withhold session cookies on cross-site POST requests, as well as for subrequests and iframes. “Without it, a forged form or link on an attacker-controlled site can trigger authenticated requests using the victim’s session,” Sowa wrote.
Going forward, cookies will only be sent on same-site requests and top-level GET navigations, such as clicking a normal link.
Collectively, these changes should thwart session hijacking and cross-site request forgeries. They won’t stop remote code execution hacks, though they will make it a lot more difficult for attackers to gain entry.
The new release brings some other security-minded changes as well.
The PHP engine will be a lot stricter when it encounters strings with null values (“
