🛡️ Application Security CheatSheet

API Security

APIs expose the real “create/update/delete” actions of an application. Even if the UI is strict, Someone can call APIs directly. So APIs must enforce authorization and validation server-side for every request.

In the wild: API credential incidents are boring and brutal — one leaked token + missing scoping/rotation becomes a full environment compromise.

60-second interview answer: “I start with authorization (BOLA/BFLA). Then I validate authentication and token handling (JWT/OAuth). Next I test schema validation and mass assignment. Finally I assess abuse controls like rate limits, logging, and monitoring. Fixes should be centralized authorization policies plus strong tests.”

Mental model (attacker mindset)

API testing methodology (repeatable)

1) Build an Authorization Matrix

2) Capture “golden requests”

3) Validate schema and state

High-yield API vulnerabilities

Vulnerability Explain simply How to test (interview-safe) How to fix
BOLA (Broken Object Level Authorization) Change an ID and you access someone else’s object. Swap IDs across accounts; check nested IDs; verify unauthorized read/write. Enforce ownership checks server-side on every request; deny-by-default; central policies + tests.
BFLA (Broken Function Level Authorization) Normal user calls admin-only functions. Call privileged endpoints with low-priv tokens; test method switching and hidden endpoints. Centralize authZ; consistent role checks; separate admin surfaces; least privilege.
Mass Assignment API accepts extra fields and updates sensitive attributes. Add “shouldn’t change” fields (role, isAdmin, price, status) and check persistence. Allow-list DTOs; reject unknown fields; server-controlled fields only.
Excessive Data Exposure API returns more data than needed (PII/internal flags). Inspect responses for hidden PII, internal IDs, admin flags, tokens, debug fields. Response shaping; separate internal/external DTOs; minimize fields.
Rate-limit / abuse gaps Attackers brute force, enumerate, or spam operations. Check throttling on login, OTP, password reset, search, exports, payments. Per user/IP/device throttles; progressive delays; detection + alerts; safe errors.
Remember: Real-world API breaches are often authorization failures (BOLA/BFLA) more than “fancy crypto”.

JWT basics (deep but clean)

JWT is a signed token containing claims about the user and permissions.

OAuth2 basics (interview framing)

Plain: OAuth lets an app access an API on a user’s behalf with scoped permissions.

Deep: emphasize scopes, consent, token lifetime, correct redirect handling, and server-side scope enforcement.

API checklist (quick revision)

Safety note: for interview prep and