Skip to content
Free since 2014. Built for the engineers who keep things running.

cat /articles/what-phps-session-handler-teaches-us-about-atomicity.md

PHP

What PHP’s Session Handler Teaches Us About Atomicity

A look at how a missing truncate step in PHP's file-based session handler, tied to CVE-2026-126714, let a partial write turn into a serious code execution risk despite file locking.

amitmerchant.com26 Nov 2026 · 5 min read · summary

article --summary

The summary

The article argues that a file lock only controls who may write, not what the file contains if a write is interrupted partway through. It uses PHP's default file session handler as the example, showing how a partial overwrite could leave a mix of new and old session bytes that PHP later unserializes, potentially enabling remote code execution under certain conditions. The fix in PHP was to always truncate the session file before writing, and to abort if truncation fails. The post lists the patched PHP releases (8.2.36, 8.3.37, 8.4.28, 8.5.13) and notes that disabling upload progress only removes one input path. The broader takeaway is to ask separately about concurrency, reader visibility, crash behaviour, and durability when designing persistent writes, and to consider temp-file-and-rename or transactional storage where appropriate.

Editorial note: This is a summary of an article first published by amitmerchant.com. The full piece is on their site.

Reading now

Topic
PHP
Source
amitmerchant.com
Published
26 Nov 2026
Format
Curated summary

Have a take on this?

Write it up and submit it. It goes on the list once an editor approves it.

Submit an article

articles --latest

Latest articles

New from the blogs we follow and the community.

All articles

newsletter --weekly

LaraChat Weekly, minus the noise.

The best reads, new jobs and upcoming events, in one email a week.