The Bug That Taught Me Cryptography Isn't Enough: How Flawed API Logic Can Destroy a Secure Vault
When I thought of building security-focused applications, the emphasis was on encryption. Use a well-tested cryptographic library, avoid storing plaintext, and derive keys properly. Those are all good practices. I followed the same approach while building a small self-hosted password manager called vo!t (sounds similar to vault!) using Flask. Passwords were encrypted before being written to disk, and I eventually replaced a stored encryption key with one derived from a master password using PBKDF2. From a cryptographic standpoint, nothing was obviously wrong. The problem was in the application logic. During testing, I found that submitting an incorrect master password didn't return an authentication error. Instead, the application accepted the request, wrote data encrypted with the wrong key into the vault, and left the database in a state where legitimate users could no longer decrypt it. The encryption library behaved exactly as expected. My application didn't. ...