Vulnerabilities & Risk

API Security Basics

why modern apps leak through the back door, and the checks that fix it

2 min readupdated by Syed Khaleel Ahmed

An API (application programming interface) is how programs talk to each other: a phone app to its server, one service to another, a partner to your platform. APIs expose data and actions directly, with no friendly page in between, so mistakes are easy to exploit and easy to automate.

What the OWASP API Security Top 10 highlights

The 2023 list stresses these risks, among others:[1]

  1. Broken object level authorization (BOLA): the API does not check that this user may access this specific record. Change an ID in a request and you get someone else's data. It sits at number one.
  2. Broken authentication: weak tokens, missing checks, poor password or token handling.
  3. Broken object property level authorization: exposing fields a user should not see (excessive data exposure) or letting them set fields they should not (mass assignment, such as flipping isAdmin).
  4. Unrestricted resource consumption: no limits on requests, size or cost, enabling denial of service or large bills.
  5. Broken function level authorization: ordinary users can call admin endpoints.
  6. Unrestricted access to sensitive business flows: abuse of legitimate features at scale, such as bulk buying or fake sign-ups.
  7. Server-side request forgery (SSRF): the API fetches a URL the attacker controls, reaching internal systems.
  8. Security misconfiguration.
  9. Improper inventory management: forgotten shadow and old versions of APIs still running, unpatched and unmonitored.
  10. Unsafe consumption of APIs: blindly trusting data from third-party APIs.

Practical controls

  • Authenticate every request with a standard mechanism (OAuth 2.0 / OpenID Connect tokens) and validate token signature, expiry and audience.
  • Authorize on the server, per object and per function. Never rely on the client to hide things.
  • Return only the fields needed and accept only the fields expected (an allowlist).
  • Rate limit and set quotas, with sensible limits on payload size.
  • Validate all input against a schema.
  • Keep an inventory of every API, version and owner, and retire what is unused. An API gateway helps with central authentication, throttling and logging.
  • Use HTTPS everywhere and avoid secrets in URLs.
  • Log and monitor for unusual patterns such as one user walking through thousands of IDs.[2]

Testing mindset

Ask of every endpoint: who can call it, what can they ask for, and what stops them asking for someone else's? Test as two different users and swap their identifiers.

Sources

  1. OWASP API Security Top 10 (2023)
  2. OWASP REST Security Cheat Sheet

Test yourself

My notes

Private — saved only on this device, never sent anywhere.