What PHP’s Session Handler Teaches Us About Atomicity 0 ▲ Amit Merchant 1 hour ago · Tech · hide There is a comforting line of reasoning that goes like this: if a process locks a file before updating it, another process cannot interfere, so the update is safe. That reasoning is only partly true. A lock can answer who gets to write. It cannot answer what the file looks like if the writer stops halfway through. That distinction sits at the centre of a recent PHP security vulnerability, CVE-2026-126714. It affects PHP’s default, file-based session handler and turns an interrupted session write into something much more serious than a lost login state. The small assumption behind the big problem PHP sessions are commonly stored as files. When a session changes, PHP serializes the session data and writes the result back to its session file. The file-based handler also uses a lock. In simplified PHP code, that looks familiar enough: $handle = fopen($path, 'c+'); flock($handle, LOCK_EX); fwrite($handle, $serializedSession); fflush($handle); flock($handle, LOCK_UN); The lock is useful. It… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town