API security essentials
Parameterized queries vs SQL injection, secrets management, TLS everywhere, input validation at trust boundaries, OWASP API Top 10. Security questions decide senior loops.
The mental model
Think of your API as a building with many doors, and every door opens onto something valuable — data, money, other users' accounts. Security is not one big lock on the front; it is the discipline of assuming every input is hostile until proven otherwise and putting a check at every door, not just the lobby. The formal name for that discipline is the trust boundary: the line where data crosses from something you control into something you do not, or vice versa. The whole of API security is about knowing where those lines are and validating everything that crosses them.
The analogy that makes it concrete: a restaurant kitchen. Ingredients arrive from suppliers (user input). You do not throw them straight into the pot — you inspect them, wash them, and reject the spoiled ones, because one bad batch poisons everyone downstream. SQL injection is a supplier smuggling a note into the delivery that the cook reads as an instruction ("also, unlock the safe"); the fix, parameterized queries, is refusing to ever read the delivery as instructions — ingredients are data, the recipe is code, and the two never mix.
Why this exists as its own topic: individual features are usually built by someone thinking about the happy path — "the user enters their email, we look them up". The attacker thinks about the *unhappy* path — "what if the email field contains ' OR '1'='1?" Without a security mindset, every feature ships with the happy path only, and the OWASP API Top 10 is essentially a catalogue of the unhappy paths teams forget. The reason security questions decide senior loops is that they reveal whether a candidate can think adversarially — can they look at their own code and see the doors they left open?
The three ideas that carry most of the weight: never trust input (validate at the boundary), never build commands from strings (parameterize / escape at the point of use), and secrets are not configuration (they live in a vault, never in code or logs). Everything else is elaboration.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision