Web applications used to hide their data model behind server-rendered pages. Today, most applications are a thin client (a single-page app or a mobile app) talking to a set of APIs that return raw JSON objects. That is great for developers. It also means the business logic, and every object ID, is exposed directly to anyone who opens the browser's developer tools or proxies a mobile app.
Attackers have noticed. Two of the most discussed breaches of the past year were API failures:
- Optus (September 2022): data on up to 9.8 million customers was reportedly retrieved through an internet-facing API endpoint that did not require authentication, by iterating through customer identifiers.
- T-Mobile (disclosed January 2023): an attacker abused an API to obtain data on around 37 million current customer accounts.
In June, OWASP published the 2023 edition of the API Security Top 10, the first update since 2019.
The 2023 list
| # | Risk | In one sentence |
|---|---|---|
| API1 | Broken Object Level Authorization | The API returns any object whose ID you ask for |
| API2 | Broken Authentication | Weak tokens, missing checks or credential stuffing |
| API3 | Broken Object Property Level Authorization | Reading or writing fields you should not (merges 2019's excessive data exposure and mass assignment) |
| API4 | Unrestricted Resource Consumption | No limits on requests, payload size or costly operations |
| API5 | Broken Function Level Authorization | Regular users can call admin endpoints |
| API6 | Unrestricted Access to Sensitive Business Flows | Automating purchases, sign-ups or referrals at scale (new) |
| API7 | Server Side Request Forgery | The API fetches URLs you supply (new) |
| API8 | Security Misconfiguration | CORS, verbose errors, missing hardening |
| API9 | Improper Inventory Management | Old versions and undocumented hosts still live |
| API10 | Unsafe Consumption of APIs | Trusting data from third-party APIs too much (new) |
BOLA: the bug we find in almost every API test
Broken object-level authorisation stays at number one because it is easy to introduce and easy to exploit. The pattern looks like this:
// Vulnerable: authenticates the user, but never checks they own the invoice
app.get("/api/invoices/:id", requireLogin, async (req, res) => {
const invoice = await db.invoices.findById(req.params.id);
if (!invoice) return res.sendStatus(404);
res.json(invoice);
});Any logged-in user can change /api/invoices/1001 to /api/invoices/1002 and read someone else's invoice. Switching to UUIDs makes guessing harder but does not fix the bug, because IDs leak through URLs, logs and other endpoints.
The fix is to scope every query to the caller, and to make that the default rather than something each endpoint remembers:
// Fixed: the query itself is scoped to the caller's tenant and user
app.get("/api/invoices/:id", requireLogin, async (req, res) => {
const invoice = await db.invoices.findOne({
id: req.params.id,
tenantId: req.user.tenantId,
ownerId: req.user.id,
});
if (!invoice) return res.sendStatus(404); // same response whether it exists or not
res.json(invoice);
});In larger codebases, centralise this in a data-access layer or policy engine so an endpoint cannot fetch an object without an authorisation context.
Property-level authorisation and mass assignment
APIs often return the whole database object and let clients pick the fields they display. That leaks internal fields such as isAdmin, passwordHash and internalNotes. On writes, frameworks that bind request JSON straight onto a model let attackers set fields they should not:
PATCH /api/users/me
Content-Type: application/json
{ "displayName": "Sam", "role": "admin", "creditLimit": 100000 }Use explicit response schemas (serialise only allowed fields) and explicit allow-lists for writable properties.
Business flows and inventory: the new emphasis
Two themes in the 2023 list are worth highlighting:
- Sensitive business flows (API6). An endpoint can be perfectly "secure" and still be abused, for example by scripts that buy every concert ticket, create thousands of accounts for referral bonuses or scrape a catalogue. Protecting these needs rate limits per user and device, bot detection and business-level monitoring, not just input validation.
- Inventory (API9). The API you are testing is rarely the one that gets breached. It is
/v1/, which the mobile app stopped using two years ago but nobody switched off, or the staging host with production data. You cannot protect APIs you do not know about.
A checklist for API owners
- Keep an inventory of every API host, version and environment, generated from gateways and traffic rather than documentation.
- Require authentication by default; make anonymous endpoints an explicit, reviewed exception.
- Enforce object- and function-level authorisation centrally, with tests that try cross-tenant and cross-user access.
- Return explicit schemas; never serialise whole database objects.
- Rate-limit and quota per user, token and IP, including on expensive operations like search and exports.
- Validate outbound fetches to stop SSRF: allow-list destinations and block internal ranges and metadata endpoints.
- Log with context (user, object ID, result) so abuse such as ID enumeration is detectable.
Why scanners miss this
Automated scanners are good at injection and misconfiguration. They are poor at authorisation, because they do not know that user A should not see user B's invoice. Finding BOLA and business-flow abuse needs a tester who understands the application's roles and data model, working with at least two accounts per role.
That is exactly how our application penetration testing and application security testing engagements approach APIs.