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.