API Penetration Testing: How to Find Security Risks in Modern APIs
Hero Summary
API penetration testing is a security test of an application programming interface (API) that checks whether an attacker can read data they should not see, perform actions they are not permitted to, or abuse the API's business functions. APIs differ from web pages: they expose functions and data objects directly, usually with no user interface to constrain what a client can send, so authorization flaws are the dominant risk. The OWASP API Security Top 10 (2023 edition) is the standard reference, led by Broken Object Level Authorization.
Executive Summary
Modern applications — mobile apps, single-page web apps, partner integrations, and microservices — rely on APIs to move data. Every endpoint is a potential entry point, and APIs often expose more data and more functions than the interface built on top of them. This guide explains how APIs differ from traditional web applications, what the OWASP API Security Top 10 (2023) covers, how an API penetration test is carried out, what documentation and access a tester needs, and how to prepare so the test finds real issues.
What is API penetration testing? {#what-is}
An API lets one piece of software request data or actions from another, typically over HTTP using formats such as REST, GraphQL, or SOAP. API penetration testing examines those interfaces directly. The tester sends requests that a normal client would not — changing identifiers, removing fields, replaying tokens, calling functions out of order — to find where the API trusts input or identity too much. It combines vulnerability assessment (finding weaknesses) with exploitation to show real impact. For the underlying distinction, see VAPT vs Penetration Testing.
Why APIs need their own testing approach {#why}
- The interface does not limit the attacker. A web page might only let a user click their own invoice, but the underlying API may accept any invoice number. Testing the visible interface misses what the API will actually accept.
- Authorization is checked per object and per function, and mistakes are easy to make and hard for scanners to detect, because only someone who understands who should see what can recognize a violation.
- APIs expose data in bulk. One flawed endpoint can return many records, and APIs frequently return more fields than a client displays.
- Attack surface is easy to lose track of. Old versions, test endpoints, and undocumented routes persist.
- Automation is built in. Attackers can call an API thousands of times, which makes rate limiting and resource controls important.
The OWASP API Security Top 10 (2023) {#owasp}
| ID | Risk | What it means in practice |
|---|---|---|
| API1:2023 | Broken Object Level Authorization | An API lets a user access objects by ID that belong to someone else, because the check on the specific object is missing |
| API2:2023 | Broken Authentication | Weak or flawed login, token, or credential handling lets attackers assume other identities |
| API3:2023 | Broken Object Property Level Authorization | Users can read or modify properties of an object that they should not, including through over-exposed fields |
| API4:2023 | Unrestricted Resource Consumption | No effective limits on requests, payload size, or processing, enabling abuse or denial of service |
| API5:2023 | Broken Function Level Authorization | Users can call administrative or privileged functions they should not be able to reach |
| API6:2023 | Unrestricted Access to Sensitive Business Flows | Automated abuse of legitimate business functions, such as bulk purchasing or account creation |
| API7:2023 | Server Side Request Forgery | The API fetches a remote resource from an attacker-supplied address, reaching internal systems |
| API8:2023 | Security Misconfiguration | Insecure defaults, missing hardening, permissive cross-origin settings, or verbose errors |
| API9:2023 | Improper Inventory Management | Old, test, or undocumented API versions and endpoints remain exposed |
| API10:2023 | Unsafe Consumption of APIs | The API trusts data from third-party APIs without validating it |
OWASP's guidance on the first risk is that developers should add object-level authorization checks to every function that accesses a data source using an ID from the user. In testing, this is usually the first thing examined: can user A fetch, change, or delete user B's data by changing an identifier?
How an API penetration test works {#process}
- Discovery and inventory. Collect the API's documentation, such as an OpenAPI/Swagger specification or Postman collection, and supplement it by observing real client traffic to find endpoints that are undocumented.
- Authentication and token testing. Examine how users and services authenticate — API keys, OAuth 2.0 and OpenID Connect flows, JSON Web Tokens — and look for weak validation, token reuse, missing expiry, or flaws in token issuance.
- Authorization testing. Using accounts with different roles, test whether each endpoint properly enforces which objects and functions each role may access. This covers both object-level and function-level authorization.
- Input handling. Test for injection, unexpected data types, mass assignment (sending fields the client should not control), and server-side request forgery.
- Business logic and flow abuse. Try calling steps out of order, replaying requests, and abusing legitimate functions at scale.
- Resource and rate limits. Check whether the API restricts request volume, payload size, and expensive operations.
- Configuration review. Examine transport security, cross-origin settings, headers, and error messages.
- Reporting and retest. Document findings with evidence and remediation, then verify fixes.
What testers need {#needs}
- API documentation or a specification, plus a Postman collection or sample requests.
- Test accounts for each role, and at least two accounts per role, so cross-user access can be tested.
- A non-production environment with realistic data, or clear rules for testing in production.
- Information about authentication — how tokens are issued and which identity provider is used.
- A list of third-party APIs and integrations, with confirmation of what the tester may and may not touch.
Common findings and how to fix them {#fixes}
- Missing object-level checks: authorize every request against the specific object and the authenticated user, on the server, for every endpoint.
- Excessive data exposure: return only the fields a client needs, and avoid sending whole database objects.
- Mass assignment: accept only an explicit list of writable fields.
- Weak token handling: use short-lived tokens, validate signature, issuer, audience, and expiry, and revoke tokens when needed.
- No rate limiting: apply limits per user and per client, and cap payload sizes and expensive operations.
- Shadow and zombie APIs: maintain an inventory, retire old versions, and monitor for undocumented endpoints.
How to prepare {#prepare}
Maintain an up-to-date API inventory, prepare role-based test accounts, document the authentication flow, and decide in advance what testing is allowed against third-party services. Combine API testing with testing of the web or mobile application that uses it — see Web Application VAPT and Mobile Application VAPT.
How Threat ResQ fits {#threat-resq-fit}
Threat ResQ's VAPT service covers vulnerability assessment and penetration testing, with retest included on all critical findings, delivered in collaboration with a CERT-In empanelled security firm. The empanelment belongs to that partner, not Threat ResQ itself.
FAQ {#faq}
What is API penetration testing? A security test of an API that sends crafted requests to find authorization, authentication, input-handling, and business-logic weaknesses, and attempts to exploit them to show real impact.
What is the most common API vulnerability? Broken Object Level Authorization, which tops the OWASP API Security Top 10 (2023): an API returns or changes an object because the caller supplied its ID, without checking that the caller is allowed to access that particular object.
How is API testing different from web application testing? Web testing focuses on the pages and flows a user sees. API testing examines the underlying endpoints directly, where there is no interface limiting what a client can send, so authorization and data-exposure flaws are more prominent.
What does a tester need to test an API? Documentation or a specification, test accounts for each role (and at least two per role), a suitable environment, authentication details, and clear rules about third-party services.
How often should APIs be tested? After significant changes — new endpoints, authentication changes, new integrations — and on a regular schedule, because APIs change frequently and new weaknesses are discovered continuously.
Frequently asked questions
What is API penetration testing?
A security test of an API that sends crafted requests to find authorization, authentication, input-handling, and business-logic weaknesses, and attempts to exploit them to show real impact.
What is the most common API vulnerability?
Broken Object Level Authorization, which tops the OWASP API Security Top 10 (2023): an API returns or changes an object because the caller supplied its ID, without checking that the caller is allowed to access that particular object.
How is API testing different from web application testing?
Web testing focuses on the pages and flows a user sees. API testing examines the underlying endpoints directly, where there is no interface limiting what a client can send, so authorization and data-exposure flaws are more prominent.
What does a tester need to test an API?
Documentation or a specification, test accounts for each role (and at least two per role), a suitable environment, authentication details, and clear rules about third-party services.
How often should APIs be tested?
After significant changes — new endpoints, authentication changes, new integrations — and on a regular schedule, because APIs change frequently and new weaknesses are discovered continuously.
Official references
- OWASP, API Security Top 10 (2023): https://owasp.org/API-Security/editions/2023/en/0x11-t10/
- OWASP, API1:2023 Broken Object Level Authorization: https://owasp.org/API-Security/editions/2023/en/0xa1-broken-object-level-authorization/
- OWASP API Security Project: https://owasp.org/www-project-api-security/
Ask TIARA about this article
Get a grounded answer on API security testing, or ask your own question.