In short
- Most API flaws are authorization flaws. Three of the first five risks in the OWASP API Security Top 10 (2023) are about who may touch which object, which field and which function.
- An API pentest needs at least two accounts. With one account you can test authentication. Only a second account shows whether user B can read or change user A's records.
- Your API is larger than your
/apifolder. Server Actions, Supabase tables and database functions, edge functions, GraphQL and old versions like/v1are all endpoints a stranger can call. - A scanner that reads your OpenAPI file checks formats and headers. It cannot know that order 1042 belongs to someone else. That takes a test built on ownership.
- You can run four checks on your own API in ten minutes with curl: no token, the other user's id, a privileged field, and a method you never offered.
On this page
- What is API penetration testing?
- Where is the API in an app built with AI?
- What an API pentest covers: the OWASP API Top 10 in plain words
- How an API pentest runs, step by step
- Four checks to run on your own API today
- API security testing tools, and where each one stops
- How to prepare for an API pentest
- How often should an API be tested?
- How Keybrum tests an API
- Questions
- Sources
What is API penetration testing?
API penetration testing is an attack on your API that you asked for. A tester, or a tool, calls every endpoint the way an outsider could, tries to get data and actions it should not get, and reports what worked. A web app pentest covers the pages as well. An API pentest skips the interface and talks to the backend directly, which is what an attacker does anyway.
The reason it deserves its own test is in the OWASP API Security Top 10. Its first entry, broken object level authorization, is rated easy to exploit, widespread and easy to detect, and OWASP calls it "extremely common in API-based applications" because the server relies on ids sent by the client to decide which object to return. The flaw is rarely in the code that checks the password. It is in the code that forgot to ask whose record this is.
Where is the API in an app built with AI?
Founders who ship with Lovable, Bolt, v0, Cursor or Claude Code often answer "we don't really have an API". They do. Anything the browser calls is an API, and a stranger can call it without the browser. Scope the test on this list, not on the folder named api.
| Surface | What it is | What people forget |
|---|---|---|
| Route handlers | Files like app/api/orders/route.ts in Next.js, or Express and FastAPI routes | Each exported method (GET, POST, PATCH, DELETE) needs its own session and ownership check |
| Server Actions | Functions marked 'use server' that a form or a button calls | The Next.js docs say an exported Server Action "is reachable via a direct POST request, not just through your application's UI" |
| Supabase Data API | Every table, view and function in an exposed schema, served automatically | Supabase's docs describe two layers, grants and row level security, and say to use both for every exposed object. See Supabase RLS |
| Database functions (RPC) | Postgres functions callable at /rest/v1/rpc/ followed by the function name | On existing projects, new functions in public are executable by the anon role by default |
| Edge and cloud functions | Supabase Edge Functions, Firebase callable functions, serverless handlers | Turning off the platform's JWT check to clear a 401 during development leaves your own code as the only check |
| GraphQL and tRPC | One endpoint that carries many operations | Authorization must hold per field and per procedure, and introspection tells a visitor the schema |
| AI routes | The endpoint that forwards a prompt to a model | With no session check, anyone spends your credits. See unprotected AI endpoints |
| Old versions and docs | /v1 next to /v2, a public /openapi.json or /api-docs | OWASP lists deprecated versions left running, with weaker checks, as its own risk |
What an API pentest covers: the OWASP API Top 10 in plain words
The OWASP API Security Top 10, last published in 2023, is the list most testers scope against. Here is each risk as a question about your own app.
| Risk | The question a tester asks | Typical finding |
|---|---|---|
| API1 Broken object level authorization | Can user B fetch or change user A's object by sending A's id? | GET /api/invoices/871 returns another customer's invoice. This is the IDOR family |
| API2 Broken authentication | Can I get or forge a session I should not have? | A token whose signature is never verified, no limit on login attempts, a reset link that leaks |
| API3 Broken object property level authorization | Does the response carry fields I should not see, and can I set fields I should not set? | A user list that returns password hashes, a profile update that accepts "role": "admin" |
| API4 Unrestricted resource consumption | What does one request cost you, and can I repeat it without limit? | An SMS, email or AI endpoint with no rate limit |
| API5 Broken function level authorization | Can an ordinary user call an admin function? | /api/admin/export answers any signed-in user, or DELETE works where only GET was meant |
| API6 Unrestricted access to sensitive business flows | Can a script abuse a normal flow at scale? | Mass sign-ups for a referral credit, bulk reservation of stock |
| API7 Server-side request forgery | Does the API fetch a URL I give it? | An image or webhook URL field that reaches internal addresses |
| API8 Security misconfiguration | What did the defaults leave open? | CORS that reflects any origin with credentials, stack traces in errors, debug routes |
| API9 Improper inventory management | Which hosts and versions are still running? | A staging API on real data, an old version without the new checks |
| API10 Unsafe consumption of APIs | Do you trust what third parties send you? | A webhook accepted without checking its signature. See Stripe webhook security |
Read the first five again: three of them are authorization. That shapes the whole test. Authentication asks who you are, and frameworks handle it well. Authorization asks what you may touch, and no framework can answer that for your data model.
How an API pentest runs, step by step
- 1
Inventory every endpoint
The tester reads your OpenAPI or GraphQL schema if you have one, then your JavaScript, because the frontend names the routes it calls. Anything found in the code and missing from the documentation goes on the list too. That gap is often where the weakest endpoints are.
- 2
Call each one with no account
Every endpoint is requested with no token and no cookie. Whatever answers with data is public, on purpose or not.
- 3
Call each one as an ordinary user
A fresh account calls everything, including the routes the interface hides from it. Hidden buttons are not access control.
- 4
Cross two accounts
Account A creates a record. Account B asks for it, tries to change it, tries to delete it. This is the step that finds API1 and API5, and it is the step a single-account scan cannot run.
- 5
Push on the edges
Extra fields in the body, a different HTTP method, an older version of the route, a token that is expired or signed with the wrong key, a burst of requests on the expensive endpoints.
- 6
Report with the request that worked
Each finding is the exact request, the account it ran as and the answer it got, with personal data redacted. Then the fix, then a retest. Our pentest report sample shows the format.
Four checks to run on your own API today
You need two accounts on your own app, the session token of each (copy the Authorization header or the cookie from the browser's network tab), and curl. Use test records, never a customer's.
# Your own API only. TOKEN_A and TOKEN_B are two accounts you created.
# 1. No token: a private route should answer 401, not data.
curl -i https://your-app.example/api/orders/1042
# 2. Account B asks for a record account A created: expect 403 or 404.
curl -i -H "Authorization: Bearer $TOKEN_B" \
https://your-app.example/api/orders/1042
# 3. A field the client should never set. Then read your profile back.
curl -i -X PATCH -H "Authorization: Bearer $TOKEN_A" \
-H "Content-Type: application/json" \
-d '{"name":"Test","role":"admin"}' \
https://your-app.example/api/me
# 4. A method you never offered, on your own test record.
curl -i -X DELETE -H "Authorization: Bearer $TOKEN_B" \
https://your-app.example/api/orders/1042- Check 1 returns data: the route has no session check. In Next.js, add it inside the handler or the Server Action itself. A check in middleware alone has been bypassed before, see CVE-2025-29927.
- Check 2 returns A's record: the route checks that you are signed in and never checks that the record is yours. The fix is a filter on the owner in the query, or a row level security policy if the data sits in Supabase.
- Check 3 changes your role: the handler writes the whole request body to the database. List the fields a user may change and ignore the rest.
- Check 4 deletes the record: a handler exists for a method the interface never uses, and it skips the check the others have.
API security testing tools, and where each one stops
The phrase API security testing covers several kinds of tools. They answer different questions, and the difference matters when you read their reports.
| Tool type | What it does | Where it stops |
|---|---|---|
| Linters for OpenAPI files | Flag routes with no security scheme, loose schemas, missing limits | They read the document, not the running API. A route can declare a scheme and ignore it |
| Schema-driven fuzzers | Send malformed and unexpected values to every documented operation | They find crashes and validation gaps. They do not know who owns a record |
| Intercepting proxies | Let a person replay and edit real requests by hand | As good as the person and the hours booked |
| Vulnerability scanners | Match versions, headers and known patterns | Maybes, with false positives. See pentest vs vulnerability scan |
| Proof-based automated pentest | Creates its own accounts and records, crosses them, keeps the request that worked | Only the flaw classes it has attacks for. See automated pentest |
| Manual pentest | A tester who learns your roles and your business rules | A snapshot, priced by the day. See pentest cost |
For GraphQL, add two questions of your own. Is introspection open in production? The GraphQL documentation notes that turning it off is a form of security through obscurity and is not enough by itself. And is there a depth limit? The same documentation recommends one, because nested list fields multiply the work a single query asks for.
How to prepare for an API pentest
- An inventory: every host, version and environment that answers, including staging. Say which ones share the production database.
- The schema, if you have one: OpenAPI, GraphQL schema or a Postman collection. A tester without it spends paid hours rebuilding it.
- Two accounts per role: two ordinary users, two admins, two tenants if the app is multi-tenant. Crossing accounts is the test.
- Test data you can lose: records created for the test, so writes and deletes can be tried without touching a customer.
- Rules of engagement: which endpoints must not be hit hard (payments, SMS, email), the hours allowed, who to call if something breaks.
- A decision on write tests: reading is safe. Changing another user's record proves more and needs your written consent and a test record.
- A place for the report to land: who fixes what, and a date for the retest.
Ask the tester what they will not cover. Rate limits on a shared platform, third-party APIs you call, and business flows that need a real card are common gaps. A report that lists what was not tested is worth more than one that implies everything was.
How often should an API be tested?
An API changes more often than the pages in front of it. Every new feature adds a route, and every migration can add a table that the Data API serves at once. A yearly test sees one state of that list. The penetration testing methodology guide covers the standards and the rhythm auditors expect.
A workable rhythm for a small team: run the four checks above on every new route, run an automated test on every deploy, and book a manual test when a customer or an auditor asks for a report, or when money starts to move through the API.
How Keybrum tests an API
Keybrum is the automated pentest we build for apps made with AI. On an app with its own backend it reads the routes named in your JavaScript and any public OpenAPI document, then attacks API routes, tRPC procedures and GraphQL as a stranger and as two accounts it creates. Its library covers reading and changing another user's record, privileged fields set from the client, admin operations open to ordinary users, method overrides, older versions of a route, tokens whose signature is not checked, and CORS that trusts any origin with credentials.
It only attacks an app after its owner proves ownership. Tests that change data need your consent and run on a marked record the test created itself, which is restored afterwards. Every finding carries the request and the response, and your coding agent reads the fix through Keybrum's MCP server. A one-time report costs €49. Plans, from €29 a month excluding VAT, attack every deploy and keep retests open.
Questions
What is the difference between API security testing and API penetration testing?
API security testing is the wider term: it includes linting the OpenAPI file, fuzzing inputs and scanning for known patterns. API penetration testing is the part where someone, or a tool, actually attacks the running API and reports what worked. A pentest finding comes with the request that proves it.
How long does an API pentest take?
It depends on the number of endpoints and roles. A manual test of a small API usually takes a few days of testing plus the report, and a large one several weeks. An automated test runs in minutes and can repeat on every deploy, within the flaw classes it covers.
How much does an API pentest cost?
Manual tests are priced by the tester's days, so the endpoint count and the number of roles drive the quote. The penetration testing cost guide breaks down the ranges. Keybrum charges €49 for a one-time report on one app, and plans from €29 a month excluding VAT attack every deploy.
Do I need an OpenAPI file to pentest an API?
No, but it helps. Without a schema the tester rebuilds the endpoint list from your frontend's JavaScript and from traffic, which takes time and can miss routes. If you have a schema, check whether it is public: a visitor who can read /openapi.json gets the same map.
Can I pentest my Supabase or Firebase API?
Yes, your own project. The Data API of Supabase and the Firebase SDK endpoints are APIs like any other, and the test is the same: no account, one account, then a second account against the first one's rows. Start with the Supabase RLS checker or the Firebase rules checker.
What is BOLA in API security?
BOLA stands for broken object level authorization, the first risk in the OWASP API Security Top 10. The API checks that you are signed in and does not check that the object you asked for is yours, so changing an id in the request returns someone else's data. It is the API name for IDOR.
Sources
- 1.OWASP Top 10 API Security Risks, 2023, OWASP
- 2.API1:2023 Broken Object Level Authorization, OWASP
- 3.API3:2023 Broken Object Property Level Authorization, OWASP
- 4.API5:2023 Broken Function Level Authorization, OWASP
- 5.API9:2023 Improper Inventory Management, OWASP
- 6.Form 8-K, January 2023, T-Mobile US, filed with the SEC
- 7.Data Security, Next.js Docs
- 8.Securing your API, Supabase Docs
- 9.Securing your functions, Supabase Docs
- 10.Security, GraphQL Foundation
- 11.REST Security Cheat Sheet, OWASP Cheat Sheet Series