Skip to main content

The APIs Nobody Told You About

· 7 min read
Ankush K
Co-founder and CTO, Dwaar
The APIs Nobody Told You About

When someone asks how many APIs you run, the first thing you reach for is the OpenAPI spec. That file is a statement of intent. It records what the team meant to ship. What answers on a port tonight is a different question, and whether that thing checks who is asking is a third.

The usual program is sensible: keep the spec current, point a scanner of known CVEs at the hosts it names, patch what comes back. It fails in two places. The scan covers the hosts you handed it, and those came from the list that is wrong. And a CVE scanner compares component versions against known vulnerabilities, so it can tell you the gateway in front of your API has a published flaw, but not whether user B may read user A's invoice. That is my reasoning from the definitions, not a measured result, and narrower than Why Scanning Alone Is Not a Security Program.

What an inventory has to answer​

The OWASP API Security Top 10, 2023 edition, names the first gap at API9, Improper Inventory Management. Per the API9 page, you have a documentation blindspot when the purpose of a host is unclear and nobody can say which environment it runs in (production, staging, test, development), who should have network access (public, internal, partners), and which version is running. OWASP adds a data flow blindspot: sensitive data going to a third party with no business justification or no inventory of the flow.

Those are questions about a running system. A spec can assert the answers. It cannot confirm them.

The same page says why this matters. Attackers "usually get unauthorized access through old API versions or endpoints left running unpatched and using weaker security requirements". It adds: "Sometimes different API versions/deployments are connected to the same database with real data." The forgotten host is not necessarily holding forgotten data.

OWASP's first API9 scenario, an illustration and not a reported incident, shows the shape. A beta host runs the same API as production, but rate limiting lives in a separate component that is not in place on beta, so a researcher brute forces a 6-digit reset token and can reset any user's password. The two hosts have the same API. The difference is entirely in what surrounds them.

Every source is a partial witness​

No single system holds the true list. This table is my own assessment, not taken from a standard:

EvidenceWhat it tells youWhat it cannot tell you
Hand-written specWhat the team intendedAnything shipped outside that intent, or after the file went stale
Spec generated in CI/CDWhat the built service declaresOlder deployments still running, hosts outside that pipeline
Gateway configurationRoutes that pass through the gatewayHosts that do not
Traffic logsWhat is being calledRoutes nobody called in the window
Source codeWhich handlers exist, whether a check is writtenWhat is deployed, and who can reach it
Known CVE scanKnown flaws in components on hosts you namedHosts nobody named, and who may read what

OWASP recommends generating documentation automatically in CI/CD, and if you change one thing about your spec, change that. But the value is in the disagreement between the rows. A path in the logs that the spec has never heard of, a route in code with no gateway entry: those are the APIs nobody told you about. You Cannot Secure What You Cannot List makes the wider case.

The bug with no version number​

Now suppose your list is perfect. The top entry on OWASP's list is still waiting.

API1:2023, Broken Object Level Authorization, carries OWASP's ratings of Widespread for prevalence and Easy for exploitability. Those are ratings, not measured rates. The rule: "Every API endpoint that receives an ID of an object, and performs any action on the object, should implement object-level authorization checks."

This sentence explains why it evades the usual tooling: "it's by design that the user will have access to the vulnerable API endpoint/function. The violation happens at the object level, by manipulating the ID." CWE-639, one of the two weaknesses OWASP maps API1 to, adds that the attacker is likely an authenticated user, and notes that BOLA appears to overlap with it but may apply to other weaknesses too.

So the request is unremarkable: valid token, permitted route, well formed ID. The flaw belongs to a handler your team wrote, so a scanner matching known CVEs against component versions has no package, version or advisory to match. That is my inference from these definitions, not a measurement.

OWASP's BOLA scenario describes an e-commerce platform with a pattern like /shops/{shopName}/revenue_data.json. An attacker iterates over shop names and reads the sales data of thousands of stores. OWASP also warns that comparing the session's user ID with the ID parameter "isn't a sufficient solution", and as I read it this scenario shows why. A shop name is not a user ID. Whether this caller may see this shop's revenue depends on your data model, so the answer can only live in your code and your tests.

Here the two problems join up. "Every API endpoint" is a claim about a set, and you cannot test a set you have not enumerated. Inventory does not fix authorization. It defines how much authorization work there is.

One API can carry a lot. T-Mobile's Form 8-K of 19 January 2023 says it identified on 5 January 2023 that "a bad actor was obtaining data through a single Application Programming Interface". Its preliminary result was approximately 37 million current postpaid and prepaid customer accounts, many of which did not include the full data set. The filing does not call the flaw BOLA, so I will not either, and that number counts accounts, not harm.

What I am not arguing​

CVE scanning stays. It finds vulnerable components, gateways included, on the APIs you know about. Specs stay too. My complaint is with hand-maintained ones treated as the inventory.

I do not think finding BOLA needs a new category of tool. Alongside a proper authorization mechanism, OWASP's prevention advice includes tests: "Write tests to evaluate the vulnerability of the authorization mechanism. Do not deploy changes that make the tests fail."

And I am giving you no figure for how many organizations run APIs they do not know about, because I could not find a neutral one.

Two accounts, one route​

Pick one production service. Diff the routes in its spec against the distinct method and path pairs in your gateway or load balancer logs. For anything in the logs and not in the spec, write down environment, audience and version. If nobody can answer, that is your first inventory entry.

Then take one route that accepts an object ID and create two test identities that own different objects.

# Illustration written for this post, not from any source.
GET /invoices/{id-owned-by-A} with A's token expect success
GET /invoices/{id-owned-by-A} with B's token expect refusal

If the second request succeeds, you have a bug no version bump will fix. If it is refused, commit the pair as a test that blocks deployment, and move to the next route on the list you just built.

References​