AI pentesting guides / What to test

API security

API pentesting

API pentesting is the authorised testing of an application programming interface to find and prove flaws that let a caller read, change or delete data, or perform actions, beyond what they are allowed. Because APIs expose objects and functions directly, the most common serious findings are authorisation failures rather than classic injection.

The OWASP API Security Top 10 (2023) reflects this: broken object-level authorisation (BOLA) is first, broken authentication second and broken object property-level authorisation, which includes mass assignment, third. An API pentest is organised around those risks.

Building the API inventory

You cannot test what you have not found. Start from an OpenAPI or Postman specification if one exists, then look for what it misses: older versions (/v1 alongside /v2), internal or debug routes, and parameters the documentation omits. Traffic captured from the web or mobile client, JavaScript bundles and historical URLs are all good sources. Undocumented endpoints are disproportionately likely to lack authorisation checks.

The checks that matter most

  • Object-level authorisation (API1): replay requests with another user's object IDs.
  • Authentication (API2): token validation, JWT signature and algorithm handling, credential stuffing protection, password reset flows.
  • Property-level authorisation (API3): extra fields in responses (excessive data exposure) and writable fields that should be read-only (mass assignment).
  • Function-level authorisation (API5): calling admin or privileged endpoints as a normal user.
  • SSRF (API7): URL and webhook parameters that the server fetches.
  • Resource consumption (API4): missing rate limits, unbounded page sizes and expensive queries.

What counts as proof in an API test

API findings are proven with a pair of requests: the attack and a control. For BOLA, user A's token fetching user B's record returns B's data, while a well-formed but non-existent ID returns 404. For mass assignment, a registration body with an added role field produces an admin account, while the same body without it does not. Each finding should include both requests, both responses and the accounts used.

Remediation patterns

Enforce authorisation in one place per object type, keyed on the authenticated identity rather than on IDs supplied by the client. Use explicit allow-lists for writable fields (data transfer objects) rather than binding request bodies directly to models. Validate JWTs with a fixed algorithm and key. Apply rate limits per user and per endpoint, not just per IP address.

With Pentest-Swarm

How Pentest-Swarm tests APIs

APIs are Pentest-Swarm's primary target. The api-security playbook maps REST and GraphQL endpoints, then the exploit agents work through authorisation and injection classes and try to prove each one.

  • Proves BOLA/IDOR with a differential oracle: the victim's ID versus a non-existent control ID.
  • Proves mass assignment by replaying a body with a privileged field against the same body without it.
  • Tests broken authentication and JWT flaws with jwt_tool, and function-level authorisation (BFLA) chains such as cross-user password reset.
  • Practise on bundled API labs: OWASP crAPI and VAmPI, where shipped chains cover BOLA, BFLA, mass assignment and an unauthenticated debug endpoint.
  • Every request is checked against a fail-closed scope before it leaves the process, with a full audit trail.

Where it falls short

Pentest-Swarm does not currently test rate limiting, race conditions or OWASP API6 (sensitive business flows) automatically, and its results depend on how much of the API it can discover; supplying a specification and test accounts for each role improves coverage considerably. For APIs carrying payments or regulated data, pair automated testing with a manual review of business logic.

Questions

What is the difference between API pentesting and web app pentesting?

The techniques overlap, but API tests focus on direct object and function access, token handling and schema abuse rather than browser-side issues such as XSS or clickjacking.

Do I need an OpenAPI spec for an API pentest?

It helps a lot but is not required. Testers can rebuild the inventory from client traffic and discovery, though undocumented endpoints take longer to find.

Which OWASP list applies to APIs?

The OWASP API Security Top 10, most recently updated in 2023. Its top three risks are BOLA, broken authentication and broken object property-level authorisation.

Sources

  1. OWASP API Security Top 10 (2023)
  2. OWASP crAPI