An API is where most modern products keep their rules. The website, the mobile app and the partner integrations are all clients of the same endpoints, and each endpoint decides what a caller may read or change. API security testing checks those decisions one endpoint at a time, from the point of view of an attacker who already has a valid account, and proves each weakness with a real request and response.
This guide covers what to test in an API, how to set up the test, the flaws that appear most often, and what to ask for at the end. If you are new to the method, start with what penetration testing is, then read our overview of SaaS security testing for the multi-tenant side of the same problem.
Why APIs Are the Real Target
A typical product has a frontend that is mostly display logic. It shows a button only if the user is allowed to press it, and it calls an endpoint to do the work. The endpoint is what the attacker can reach directly, using nothing more than a token and an HTTP client. If the endpoint trusts the frontend, the rules are only as strong as the button.
Attackers do not need the interface. They can read the traffic a browser sends, reuse endpoints that the frontend no longer calls, or script requests with an account they created for free. A test that only clicks through the website misses all of that.
Map Every Endpoint First
You cannot test what you have not found. Start by building an inventory of the API from several sources:
- The official documentation or an OpenAPI file, if one exists.
- The traffic from the web app and mobile app, captured with a proxy during normal use.
- JavaScript bundles, which often reveal endpoints and parameter names.
- Older versions, such as
/v1/routes after the product moved to/v2/. - Background jobs, webhooks and partner integrations that call internal routes.
For each endpoint, write down the method, the parameters, the roles that should be allowed to call it, and what it returns. The gaps between that list and the endpoints you actually found are often the first findings.
Set Up Accounts and Tokens
Authorization bugs can only be seen by comparing two identities. Prepare at least two accounts in each role, and where the product has tenants or organizations, put them in different ones. Store the tokens for each account separately, so you can switch between them in the same test run. An unauthenticated baseline is also useful, to see which endpoints respond without any token at all.
Make sure each account has realistic data. An empty account shows empty lists, and empty lists hide problems in pagination, filtering and export.
The Checks That Matter Most
The OWASP API Security Top 10 (2023) is a useful checklist. The items below are the ones that produce the most serious findings in practice.
Object level authorization
This is the classic bug. Log in as account A, note an ID that belongs to A, then send the same request as account B with A's ID in the path or body. If B can read, change or delete the object, the endpoint lacks an ownership or tenant check. Test every endpoint that takes an ID, including nested ones such as /projects/{id}/members, because nested routes are often checked at the parent level only.
Function level authorization
Can a normal member call an endpoint meant for admins, such as one that changes roles or lists all users? The frontend may never show the button, but the endpoint may still accept the request. Call every administrative route with a non-admin token, and also with no token at all.
Authentication and tokens
Check how tokens are issued, how long they last, and whether they are revoked when a user logs out or is removed. Look for tokens that are accepted after a password change, API keys that keep working after their owner leaves, and JWTs that accept an unsigned or weakly signed token. Our authentication security checklist covers the account side of this in more detail.
Excessive data exposure
APIs often return the whole database record and let the frontend choose what to show. That means the response can include internal notes, other users' email addresses, password hashes, internal identifiers or tokens, even though the screen shows none of them. Check what each response actually contains, not only what the page displays.
Mass assignment
The opposite problem happens on input. If an update endpoint accepts a whole object and writes every field it receives, a user can send extra fields such as role, plan, tenant_id or is_verified and change values they should never control. Send each update endpoint the fields the UI never sends, and see which ones are stored.
Rate limits and expensive operations
Login, password reset, sign-up, search, exports and AI-powered features are all expensive or sensitive. Check whether they have limits per account and per address, whether a single request can ask for an unlimited page size, and whether a user can trigger costly work repeatedly. A missing limit on password reset can enable account enumeration, and a missing limit on an AI endpoint can become a real cost.
Business flows
Some endpoints are safe to call once and dangerous to call a thousand times: applying a coupon, claiming a trial, redeeming an invitation, or sending a message to every member. Test whether a flow can be repeated, run in parallel, or used out of order, for example by confirming a payment step that was never reached.
Server-side requests and integrations
Any endpoint that fetches a URL a user supplies, such as an import from a link or an avatar from a website, can be turned into a server-side request. Test whether it reaches internal addresses or cloud metadata services. Webhooks should be tested for signature checks, and integrations should be tested for the scopes they are granted.
Common Mistakes in API Testing
- Testing with one token. Authorization is a comparison between identities, so a single account can only show that the endpoint works for that account.
- Trusting the documentation. Endpoints that are missing from the docs are often the ones nobody reviewed.
- Reading status codes alone. An endpoint that returns
200with an empty list or a generic message can still leak data through another field. Read the body, and compare it with what the other account receives. - Testing only GET requests. Write endpoints, file uploads and bulk operations carry most of the risk for changes, and they need their own checks.
- Ignoring GraphQL and batch endpoints. A single request can carry many operations, and a field-level check on one query may not apply to another. Test each field and each operation the schema exposes.
The OWASP REST Security Cheat Sheet gives practical guidance for the design side of these checks, and it is a useful reference when you write fixes as well as tests.
A Short API Security Checklist
| Area | Question to answer | Typical finding |
|---|---|---|
| Object access | Can account B reach account A's objects by ID? | Invoice returned to the wrong user |
| Function access | Can a member call admin routes? | Role change endpoint open to members |
| Responses | Does the response contain fields the UI hides? | Password hash or internal flag in JSON |
| Input | Are protected fields writable by the client? | User sets their own plan |
| Tokens | Are tokens revoked and validated correctly? | Old token works after sign-out |
| Limits | Are sensitive and costly routes limited? | Unlimited reset emails or AI calls |
| Versions | Are old routes still reachable and checked? | Deprecated v1 route with no checks |
| Outbound | Can user input make the server call internal hosts? | Import from a URL reads internal metadata |
Turning Findings Into Fixes
The fix for most API flaws is a single rule applied everywhere: load the object only through the caller's ownership or tenant, check the caller's role on the server before any action, and write only the fields the endpoint is meant to accept. Shared helper functions and a default-deny approach make it hard for a new endpoint to forget the check. Our guide to IDOR and broken access control shows the pattern in code.
After each fix, replay the exact request that worked before. A fix is only real when the same request is refused.
Where Hetz Fits
Hetz tests APIs as part of an automated, agent-driven run. You verify your domain, provide accounts for each role, and agents map the endpoints from the live product, sign in as each account, and test the object, function and input checks described above. Only findings with a proven request and response reach the report, each with a fix for your stack and a retest. The approach is described on our API penetration testing page.
Next steps
List your API endpoints this week, even roughly, and mark which roles should reach each one. Then run a test with two accounts per role before your next release, and repeat it after you add routes. You can see how a full run works on the home page, compare plans on pricing, or start a scan.
FAQ