If your business has a mobile app, a customer portal, an online store or a system that talks to a courier, it has APIs. They're the doors your software uses to pass data back and forth, and most of them are invisible to you. That's fine when they're locked. The trouble is that an API doesn't look broken when it's unlocked. It just quietly answers anyone who asks.
You don't need to write code to understand API security best practices. You need to know what can go wrong, what to ask the people who build and run your systems, and what "good" looks like. This guide walks through the industry's standard list of API risks in plain English, with one real case and a couple of short code examples for your developers.
What an API is, in one paragraph
An API (application programming interface) is how one piece of software asks another for something. Your app asks your server "show me order 1042", your website asks a payment gateway "charge this card", your stock system asks a marketplace "how many did we sell?". We explained the business side in our guide to API integration services. From a security point of view, every one of those requests has to answer two questions: who is asking, and are they allowed to see or do this?
Most API breaches are a failure to answer the second question properly.
A real case: Optus, 2022
In September 2022, Australian telecoms company Optus disclosed a breach that initially appeared to affect about 150,000 customers. It later emerged that between 2.5 million and 9.7 million records had been accessed, including names, dates of birth, phone numbers and email addresses, and for some customers, addresses and driver licence, Medicare or passport numbers (Queensland Government).
According to the Australian Communications and Media Authority's court claim, as reported by iTnews, the cause was not a sophisticated hack. These are allegations in court proceedings:
- About 2018
A code change weakens an access control
Optus had access controls on the API, but a change inadvertently weakened one so it could be bypassed.
- August 2021
The error is found, but only fixed in one place
Optus spotted the coding error on its main website, about three years after it was made. The same issue on an API endpoint on a subdomain wasn't detected or fixed.
- September 2022
The forgotten endpoint is used
The endpoint was internet-facing but 'dormant and not in use'. An attacker used it to pull customer records.
- 21 September 2022
Taken offline
The endpoint was removed four days after the breach was uncovered.
The lesson most businesses can take from OptusThe API nobody remembers is the one nobody is protecting.
Two items on the list below describe exactly this: broken access control, and an inventory of APIs that nobody kept up to date.
The OWASP API Security Top 10, in plain English
OWASP, the non-profit Open Worldwide Application Security Project, publishes the most widely used list of API risks. The current edition is from 2023 (OWASP). Here's what each one means for a business, and what to ask about it.
10
risks in the OWASP API Security Top 10, 2023 edition
OWASP
3 of 5
of the top five risks are about authorization: who's allowed to see or do what
OWASP
9.7M
records accessed at the upper estimate in the Optus breach
Queensland Government
1. Broken object level authorization (API1)
The API checks that you're logged in, but not that the thing you're asking for is yours. Change /orders/1042 to /orders/1043 and you see someone else's order. It's the most common serious API flaw, and it's why it sits at number one.
Ask: "For every request that fetches a record, do we check that this user is allowed to see that specific record?"
How broken object level authorization plays out
- 01
Log in
The attacker signs up as an ordinary customer
- 02
Look
They notice their order is /api/orders/1042
- 03
Change
They ask for /api/orders/1043, 1044, 1045…
- 04
Collect
The API returns every order, because it only checked they were logged in
Here's what the fix looks like in code. The important line is the ownership check, not the login check:
// app/api/orders/[id]/route.ts (Next.js example)
export async function GET(req: Request, { params }: { params: { id: string } }) {
const user = await getSessionUser(req) // 1. Who is asking?
if (!user) return new Response('Unauthorized', { status: 401 })
const order = await db.order.findUnique({ where: { id: params.id } })
// 2. Are they allowed to see THIS order? Without this line, any
// logged-in customer can read every order by changing the ID.
if (!order || order.customerId !== user.id) {
return new Response('Not found', { status: 404 })
}
return Response.json(order)
}
Returning "not found" rather than "forbidden" also avoids telling an attacker that order 1043 exists.
2. Broken authentication (API2)
Weak login, password reset or token handling: no limit on login attempts, tokens that never expire, API keys sent in URLs. Attackers can then guess or reuse passwords at scale, as we described in our post on credential stuffing.
Ask: "Are login and password-reset endpoints rate-limited, and do tokens expire?"
3. Broken object property level authorization (API3)
The API returns more fields than the screen shows (for example, a customer's full address or an internal cost price hidden by the app but visible in the raw response), or lets users update fields they shouldn't, such as "role": "admin" or "price": 1.
Ask: "Do our APIs return only the fields each screen needs, and do we ignore fields users aren't allowed to change?"
4. Unrestricted resource consumption (API4)
No limits on how often, how much or how big. An attacker, or a buggy integration, can run up your server bill, exhaust SMS credits or slow the site for everyone.
Ask: "What are our rate limits, page-size limits and upload limits, and what happens when someone hits them?"
A basic rate limit is a few lines. This example uses a fixed one-minute window per IP address; in production you'd store the counts in a shared store such as Redis rather than in memory:
// A simple fixed-window rate limiter (illustrative)
const WINDOW_MS = 60_000
const MAX_REQUESTS = 60
const hits = new Map<string, { count: number; resetAt: number }>()
export function rateLimit(ip: string) {
const now = Date.now()
const entry = hits.get(ip)
if (!entry || now > entry.resetAt) {
hits.set(ip, { count: 1, resetAt: now + WINDOW_MS })
return { allowed: true }
}
entry.count++
if (entry.count > MAX_REQUESTS) {
const retryAfter = Math.ceil((entry.resetAt - now) / 1000)
return { allowed: false, retryAfter } // respond 429 with a Retry-After header
}
return { allowed: true }
}
Login, password reset and anything that sends an SMS or email deserve much tighter limits than ordinary pages.
5. Broken function level authorization (API5)
Ordinary users can call admin functions because the API only hides the button, not the endpoint. If /api/admin/refund works for anyone who knows the address, it's broken.
Ask: "Are admin actions checked on the server, by role, not just hidden in the interface?"
6. Unrestricted access to sensitive business flows (API6)
The API works exactly as designed, but nothing stops it being used at a scale that hurts the business: bots buying all your limited stock, creating thousands of fake accounts, or booking every appointment slot.
Ask: "Which of our flows would hurt us if a bot did them a thousand times, and what slows bots down there?"
7. Server-side request forgery (API7)
The API fetches a URL that the user supplies, such as an image link or a webhook address, without checking it. An attacker points it at internal systems the outside world shouldn't reach.
Ask: "Anywhere we fetch a URL a user gave us, do we restrict where it can point?"
8. Security misconfiguration (API8)
Default settings, verbose error messages that reveal internals, missing security headers, permissive CORS settings, unpatched servers. Not one flaw but many small ones. Our website security checklist covers the basics.
Ask: "When did someone last review our API servers' configuration and patch level?"
9. Improper inventory management (API9)
You don't know every API you have: old versions still running, test endpoints left online, a mobile app's API from three redesigns ago. This is the Optus lesson. You can't protect what you've forgotten.
Ask: "Can we list every API endpoint we have exposed to the internet, which version it is, and who owns it?"
10. Unsafe consumption of APIs (API10)
You trust data from third-party APIs (a courier, a payment provider, a marketplace) more than data from users, and don't validate it. If that supplier is compromised, so are you. It's the same idea we covered in software supply chain attacks.
Ask: "Do we validate data coming from partners' APIs as carefully as data from customers?"

The quick version
| Risk | In one line | First thing to check |
|---|---|---|
| API1 Object authorization | Can I see your record by changing an ID? | Ownership check on every record lookup |
| API2 Authentication | Can I guess or reuse a login? | Rate limits on login and reset; tokens expire |
| API3 Property authorization | Does the API return or accept too much? | Return only needed fields; allow-list editable fields |
| API4 Resource consumption | Can I overload it or run up your bill? | Rate, size and page limits |
| API5 Function authorization | Can I call admin functions? | Role checks on the server |
| API6 Business flows | Can a bot abuse a normal feature? | Bot protection on high-value flows |
| API7 SSRF | Can I make your server fetch internal URLs? | Allow-list outbound destinations |
| API8 Misconfiguration | Are defaults and errors giving things away? | Config review and patching |
| API9 Inventory | Do you know every API you run? | A list of endpoints, versions and owners |
| API10 Third-party APIs | Do you trust partner data blindly? | Validate inbound partner data |
Your API security checklist
API security best practices, for the next meeting with your developers
- Keep an up-to-date list of every internet-facing API, its version and its owner, and switch off the ones nobody uses
- Check authorization on every request: not just 'logged in', but 'allowed to see this record and call this function'
- Return only the fields each screen needs, and ignore fields users aren't allowed to change
- Rate-limit everything, with tighter limits on login, password reset, SMS and email
- Use short-lived tokens, never put API keys in URLs, and rotate keys when people leave
- Log failed authorization attempts and alert on unusual patterns, like one user requesting thousands of records
- Validate data from partner APIs, and restrict where your servers can make outbound requests
- Test authorization in every release, ideally with automated tests that try to read another user's data
Not sure what your APIs are exposing? Ask us for an API security review. We'll list your endpoints, test the authorization on each, and tell you plainly what needs fixing first.



