Why We Don’t Trust the Database With Authentication – Sturdy Statistics
When writing an API, it’s easy to unknowingly introduce a dangerous, implicit assumption: that the database is the ultimate source of truth. If a record is in the database, an application often treats it as authoritative. I want to explain in this post why that might be a very bad idea. Here at Sturdy Statistics, our core engineering philosophy is Defense in Depth: we work to prevent failure at every layer, but we design each layer as though the others could fail. When it comes to API authentication, trusting the database as the sole arbiter of identity is a critical vulnerability masquerading as standard practice. Here is why we don’t trust our database with authentication, and how we structurally prevent database-level compromises from becoming full-system breaches. Consider the dangerous implicit default for handling API keys. If you treat a machine token like a user password, the implementation seems obvious: This feels secure because the database only holds hashes, not plaintext s
When writing an API, it’s easy to unknowingly introduce a dangerous, implicit assumption: that the database is the ultimate source of truth. If a record is in the database, an application often treats it as authoritative. I want to explain in this post why that might be a very bad idea. Here at Sturdy Statistics, our core engineering philosophy is Defense in Depth: we work to prevent failure at every layer, but we design each layer as though the others could fail. When it comes to API authentication, trusting the database as the sole arbiter of identity is a critical vulnerability…
saved by
related reading
- Everything I know about good API designseangoedecke.com
- RFC 9700: Best Current Practice for OAuth 2.0 Securitydatatracker.ietf.org
- Database Cryptography Fur the Rest of Us - Dhole Momentssoatok.blog
- Stytch - A better way to build authstytch.com
- Secure AI Agent & User Authentication | Auth0auth0.com
- webauth:sec10.pdfpdos.csail.mit.edu
- A More Human Approach To Databasesccorcos.github.io
- Keyhive: Local-first access controlinkandswitch.com
- Databases in 2025: A Year in Review // Blog // Andy Pavlo - Carnegie Mellon Universitycs.cmu.edu
- Secure AI Agent & User Authentication | Auth0auth0.auth0.com
- Understanding API keys | Supabase Docssupabase.com
- Infisical | The modern security platform for developers and agentsinfisical.com