Single NUL byte silently corrupted 14,994 audit log records in SQLite

A developer building Chron, an audit log tool for AI coding sessions, discovered that a single NUL byte in stored data caused 14,994 records to falsely appear tampered during verification. The issue arose when importing Claude Code transcripts: SQLite stored the full 530-byte string including the embedded NUL, but returned only 298 characters when the value was read back, causing the write-time and verify-time hashes to differ. Because each record in the hash chain inherits from the previous one, a single corrupted row invalidated every subsequent entry in the chain. The root cause was that the tool was hashing data as written rather than as it would later be retrieved — a mismatch the developer summarized as 'hash what you can read back.' The fix required sanitizing content before database insertion, not just before hashing, to ensure both operations work on identical data.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in