Cloud & app security

API Security Best Practices: OWASP Top 10 Controls That Work

Most API breaches are authorization failures, not exotic exploits. Here are the practices that stop them, mapped to the OWASP API Security Top 10.

Cysoro Security TeamPublished · 8 min read
GET /users/{id}POST /loginDELETE /admin✓CLOUD & APP SECURITYAPI securitybest practicesOWASP Top 10 controls that work.
Quick answer

API security best practices start with strong authentication and object-level authorization on every endpoint, short-lived tokens, TLS everywhere, strict input validation against an OpenAPI schema, rate limiting, and a complete API inventory. Test with at least two user accounts to catch broken object-level authorization, the top OWASP API risk, and log and monitor every API call for abuse.

Key takeaways

  • Three of the ten OWASP API risks are authorization failures — test them first with two accounts.
  • You cannot protect APIs you cannot see: keep a live inventory and retire zombie endpoints.
  • Validate every request against your OpenAPI schema and return generic errors that leak nothing.

APIs carry the data behind almost every app, and they are a favorite target because they are easy to forget. An endpoint shipped for one feature, a debug route left live, or an ID a user can change in a request can expose data that no firewall ever sees.

What is API security?

API security is the set of controls that protect application programming interfaces: authentication, authorization, input validation, encryption, rate limiting, logging and testing. It covers REST, GraphQL, gRPC and event-driven APIs.

APIs differ from web pages because clients call them directly, often with tokens rather than browser sessions, and because a single API can expose thousands of objects. A web page hides data behind a user interface; an API hands it to anyone who can form a request.

The OWASP API Security Top 10 2023 is the standard awareness list for API risks. It replaced the 2019 edition and remains the latest edition as of November 2026. Three of its ten risks are authorization failures, which is why this guide starts there.

What are the OWASP API Security Top 10 risks?

The OWASP API Security Top 10 2023 lists the ten most critical API risks, ranked by prevalence and impact from real incidents. Broken Object Level Authorization is number one, and authorization failures dominate the top of the list.

RiskWhat goes wrongMain defense
API1 Broken Object Level AuthorizationA user changes an ID and reads or edits someone else's recordObject-level check on every request
API2 Broken AuthenticationLogins, tokens or resets can be guessed, forged or replayedStrong auth, short-lived tokens, MFA
API3 Broken Object Property Level AuthorizationResponses expose fields, or updates set fields the user should not controlAllow-list fields, filter responses
API4 Unrestricted Resource ConsumptionNo limits on rate, size or costRate limits, quotas, payload caps
API5 Broken Function Level AuthorizationA regular user calls an admin functionRole checks on every function
API6 Unrestricted Access to Sensitive Business FlowsBuying, booking or voting flows are automatedFlow limits, human checks, monitoring
API7 Server-Side Request ForgeryThe API fetches a user-supplied URL it should not reachAllow-list URLs, block internal addresses
API8 Security MisconfigurationDefaults, verbose errors, loose CORS, debug flagsHardened config, minimal errors
API9 Improper Inventory ManagementShadow, zombie and deprecated endpoints stay liveLive inventory, retire old versions
API10 Unsafe Consumption of APIsThird-party responses are trusted without validationValidate and sanitize all inbound data

OWASP calls the list an awareness document, not a standard to certify against. Use it to prioritize, not as a compliance checklist. OWASP's DevSecOps API security guideline gives the same risks in more testing detail. The sections below turn each risk into a practice you can implement.

Authorization is three checks, not oneObject levelCan this user accessthis record?Check ownership onevery ID in a requestProperty levelCan this user seeor set this field?Allow-list fields;filter responsesFunction levelCan this user callthis function?Check the role onevery endpointHiding a button in the app is not authorization.
Object, property and function authorization are three separate checks. Illustration by Cysoro.

How should APIs handle authentication?

Use strong, standard authentication on every endpoint, including internal and legacy ones, with short-lived tokens and multi-factor authentication where users are involved. Never leave an endpoint unauthenticated because it seems unimportant.

Prefer OAuth 2.0 with short-lived access tokens and refresh-token rotation for user-facing APIs, and mutual TLS or signed service credentials for service-to-service calls. Avoid API keys as the only control for sensitive data: keys are easy to leak, hard to rotate and rarely tied to a person.

Set short token lifetimes, revoke tokens on logout and password change, and rate-limit login and password-reset endpoints. If you accept JSON Web Tokens, validate the signature, issuer, audience and expiry on the server, and never trust claims from the client. You can inspect a token's structure with our free JWT decoder, but never paste a live production token into any third-party tool.

Broken authentication is OWASP API2. It is often found on non-obvious or legacy endpoints, so inventory those first and test them like any public route.

How do you fix broken authorization?

Enforce an authorization check on every request that carries an ID, a field or a privileged function, using server-side session data rather than anything the client claims. The check must run even when the client is your own app.

For object-level authorization, look up the object, check that the authenticated user owns it or has a role that permits access, and only then return or change it. Use random, non-sequential identifiers such as UUIDs so IDs cannot be guessed, but treat that as defense in depth, not as authorization.

For property-level authorization, allow-list the fields a caller may read and write. Do not accept a request body and pass it straight to the database: that is mass assignment, and it lets a caller set fields such as role or price. Filter responses too, so a record does not leak fields the caller should not see.

For function-level authorization, check the caller's role on every administrative endpoint, not only in the user interface. Test with a low-privilege account calling admin routes directly.

How should APIs validate input and output?

Validate every request against your OpenAPI schema before it reaches business logic, and reject anything that does not match. The schema is a security contract, not just documentation.

Test positive cases, negative cases and boundary values: valid requests should succeed, invalid types, missing fields and oversized values should return a clean 400 error, not a 500 or a data leak. Enforce maximum string lengths, array sizes and payload sizes, and reject unexpected fields.

Encode output for its context and return generic errors. A verbose error that includes a stack trace, a database message or an internal path helps an attacker and embarrasses your team. Log the detail server-side and return a short, safe message to the caller.

For GraphQL, limit query depth and complexity and disable introspection in production. For file uploads, validate type, size and content server-side, and never trust a filename or content-type header from the client.

How do you stop abuse with rate limiting?

Apply rate limits per user, per API key and per IP, and add quotas and payload caps so one caller cannot exhaust your service or your bill. Rate limiting is the main defense against OWASP API4 and API6.

Set different limits for different endpoints: login and password reset need tight limits, while read-only public endpoints can allow more. Return a 429 status with a Retry-After header when a limit is hit, and log repeated limit hits as a signal of abuse.

Protect sensitive business flows with more than a rate limit. A purchase, booking or account-creation flow that can be automated at scale needs human checks, device signals or step-up verification, not just a higher request cap.

Also cap resource consumption: limit response sizes, pagination page sizes and expensive query parameters, and add timeouts to outbound calls so a slow third party cannot hold your workers open.

Why does API inventory matter?

You cannot protect APIs you cannot see. Shadow APIs that are not in your spec, zombie endpoints from retired versions, and test hosts that were never switched off are a common way in, and they are OWASP API9.

Keep a live inventory by parsing OpenAPI and AsyncAPI specs from source control, watching traffic in staging and production for endpoints that receive calls but are not in the spec, and crawling regularly to catch deprecated versions that still respond.

Retire old versions on a published schedule, and remove them rather than leaving them live with a warning. Document every API's owner, data classification and authentication method, and review the inventory at least quarterly.

For APIs hosted on Google Cloud, the same inventory discipline pairs with cloud posture tools. Our list of the best GCP security tools covers the native and third-party platforms that surface those assets.

How should APIs handle encryption, logging and secrets?

Use TLS everywhere, encrypt sensitive data at rest, never put secrets in code or URLs, and log security events without logging sensitive data. These are the controls that limit damage when another control fails.

  • TLS: require HTTPS for every endpoint, use modern TLS versions, and check your setup with our free SSL checker.
  • Secrets: store API keys and credentials in a secrets manager, rotate them, and never commit them to source control or pass them in a URL.
  • Logging: log authentication failures, authorization failures, validation errors and rate-limit hits, with a request ID you can trace.
  • Data in logs: never log passwords, tokens, card numbers or full request bodies that contain them.
  • CORS: allow only the origins you need, never a wildcard with credentials, and keep preflight handling strict.
  • SSRF: allow-list outbound URLs, block private and metadata addresses, and validate any URL a user supplies before your server fetches it.

Unsafe consumption of third-party APIs is OWASP API10: validate and sanitize every response from an external API before you trust it, just as you would validate input from a user.

How should you test API security?

Test APIs in CI and in production with real authorization tests, schema tests and load tests. Scanners alone cannot find the most common API flaws, because they cannot infer which IDs a user should be allowed to access.

  • Two-account test: create two users, have each try to read and change the other's records, and confirm every attempt is denied.
  • Role test: call every admin endpoint with a low-privilege token and confirm it is denied.
  • Schema test: send invalid, oversized and mistyped requests and confirm they fail cleanly.
  • Rate test: script a burst of requests and confirm limits and 429 responses work.
  • Dependency test: review third-party APIs and libraries for known vulnerabilities on a schedule.

Run these tests on every release, not only before launch. A new field, a new endpoint or a new role can reintroduce a flaw that last month's test passed.

Test APIs the way attackers do1Inventorylist everyendpoint2Two accountstry to crossaccess records3Schema testinvalid andoversized input4Rate testburst requests,expect 4295Monitorlog failuresand abuseRepeat on every release — a new field can reopen an old flaw.
Five-step API security testing loop. Illustration by Cysoro.

What are the most common API security mistakes?

The most common mistakes are trusting the client, hiding admin functions only in the interface, and leaving old API versions live. Each one is a design choice, not a missing product.

  • Trusting client claims: never take a user ID, role or price from the request; derive it from the server-side session.
  • Hiding instead of securing: an admin endpoint is still callable even if the app never shows its button.
  • Verbose errors: stack traces and database messages help attackers map your system.
  • Zombie versions: v1 stays live after v2 ships, with old auth and old flaws.
  • No monitoring: without logs and alerts, abuse runs for weeks before anyone notices.

Check your public endpoints the same way you check your website: confirm TLS and headers with our free security headers checker.

The bottom line

API security is mostly authorization, validation and inventory. Check ownership on every object, allow-list every field, validate against your schema, limit rates, and retire endpoints you no longer support.

Start with the two-account test this week: if one user can read another user's record by changing an ID, you have found your highest-priority fix. Then re-check your public surface with the free SSL checker.

Frequently asked questions

What are API security best practices?

Start with strong authentication and object-level authorization on every endpoint, short-lived tokens, TLS everywhere, input validation against an OpenAPI schema, rate limiting, a complete API inventory, and logging and monitoring for abuse.

What is the OWASP API Security Top 10?

It is OWASP's ranked list of the ten most critical API risks, with the 2023 edition as the latest. Broken Object Level Authorization is number one, and three of the ten risks are authorization failures.

What is broken object level authorization?

It happens when an API lets a user change an ID in a request and read or edit someone else's record. Fix it by checking ownership from server-side session data on every request that carries an ID.

Should APIs use API keys or OAuth?

Use OAuth 2.0 with short-lived tokens for user-facing APIs, and mutual TLS or signed service credentials for service-to-service calls. API keys alone are a weak control for sensitive data because they leak easily and are hard to rotate.

How do you test API security?

Test with at least two user accounts to catch authorization failures, call admin endpoints with a low-privilege token, send invalid and oversized requests against your schema, and script bursts to confirm rate limits work.

What is a shadow API?

A shadow API is an endpoint that receives traffic but is not in your official inventory or spec, often from a forgotten service or test host. Find them by watching traffic and keep a live inventory so you can retire them.

Sources

  1. OWASP — API Security Top 10 2023
  2. OWASP DevSecOps Guideline — API Security
  3. NIST — SP 800-228 Guidelines for API Security (updated edition)
  4. F5 — OWASP API Security Top 10
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the OWASP API Security Top 10 2023 and NIST SP 800-228 guidance on API security.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free