How to test API security safely, operation by operation
API security testing verifies authentication, object/function/property authorization, input handling, and resource controls for each endpoint within an approved scope. Learn to turn an OpenAPI inventory into a test matrix, compare read/write behavior with synthetic accounts, and verify actual state changes safely.
How to test API security safely, operation by operation
API security testing verifies whether authentication, object and function authorization, data exposure, input handling, and resource controls behave as intended for each authorized endpoint. A 200 OK response alone does not prove a vulnerability. Confirm whether the test account should have access to that object or action, and whether the response or resulting state change matches the policy.
Apply this workflow only to APIs you own or are explicitly authorized to test, using approved test accounts and data. Even for production systems, do not create load or access another user’s data without a written scope, test window, safety limits, and stop contact.
Set scope and safety conditions first
Record the owner, host and API version, test or production environment, approved accounts and roles, data boundaries, time window, automation limits, prohibited actions, stop contact, and cleanup or recovery method. Do not assume a third-party service or shared tenant is in scope; it may require separate permission.
Prefer an isolated test environment and synthetic data. Prepare at least two test users with distinct roles or tenants; each should operate only on objects they created. Replace hard-to-reverse actions—real payments, email delivery, deletion, or external webhook calls—with a sandbox or harmless target. If you encounter unexpected personal data, secrets, or another person’s data, stop further access, retain only minimal redacted evidence, and notify the owner.
Inventory the API surface
Start by understanding both the documentation and actual behavior. If an approved OpenAPI description exists, extract paths, HTTP methods, input schemas, responses, authentication methods, and authorization requirements. If documentation is absent or stale, combine source/configuration, developer guides, approved proxy records, and owner input. Published documentation does not prove that undocumented or observed endpoints are irrelevant.
At minimum, track:
| Item | Record | Why |
|---|---|---|
| Operation | Path and method, such as GET /v1/orders/{id} | Reads, updates, and deletes may have separate checks |
| Identity | Anonymous, user, administrator, service account | Compare authentication states and roles |
| Object boundary | Owner, tenant, organization, related object | Check whether changing an identifier bypasses access control |
| Properties | Sensitive fields that can be returned or changed | Object access and field-level access are different |
| Cost and side effects | Compute cost, rate, external actions, data changes | Set safe limits and recovery steps |
| Result | Expected and observed response, state change, evidence | Do not conclude from status code alone |
The OWASP API Testing section and REST Assessment guidance describe comparing machine-readable contracts such as OpenAPI with actual behavior and systematically checking authentication, authorization, input handling, and limits. OWASP API Security Top 10 is a taxonomy of risk categories, not a complete testing procedure. Use it as an index for missing risks in your matrix.
Check authentication and authorization per operation
Authentication establishes who is calling. Authorization decides which operations and objects that caller may use. A valid login or token does not automatically grant access to every endpoint or record.
For each operation, define expected behavior in advance and compare test accounts:
No credentials: a non-public operation should return the documented denial.
Valid lower-privilege account: administrative functions and unauthorized writes should remain unavailable.
Authorized account: an allowed operation should succeed.
Expired, revoked, or malformed token: the API should deny it according to its authentication policy.
Different scope or role: operations requiring more privilege should be denied for both reads and writes.
The documented API policy may use 401, 403, or 404 to conceal resource existence. The key check is that an unauthorized request did not disclose data or alter state. An error response does not guarantee that no change occurred, so verify using a safe read of a synthetic object.
Separate object and property authorization
Broken object-level authorization (BOLA/IDOR) occurs when a server accepts an object identifier without checking whether the caller may access that object. With a test object owned by one account, use another approved test account to check reads and separately check PUT, PATCH, and DELETE. Follow what each identifier resolves to on the server, whether it names a user, order, file, or job. Use synthetic IDs already visible to your test accounts, such as in their own list responses; do not guess identifiers or explore other people’s data.
Function-level authorization asks whether a lower-privileged role can call an action reserved for administrators, such as exporting data or inviting users. Base the test on the action’s policy, not whether a URL contains /admin. A read may be blocked while another method or route exposes the same function.
Property-level authorization asks which fields a caller may read or change on an otherwise accessible object. For example, add synthetic fields such as role, isVerified, or tenantId to a normal profile update and check whether the server ignores or rejects them. Do not stop at seeing a field echoed in a response: use a later authorized read to determine whether it persisted and changed behavior. If the effect is broader than expected, stop and restore the test fixture.
Check tokens, input, and request cost
For token-based APIs, verify that expiry, issuer and audience, signature, scope, revocation, and post-logout behavior match the server policy. Credentials in URL query strings may end up in logs or caches. Use only invalid or expired tokens created for the test, and never copy secrets into logs or reports.
Start input tests with valid requests and change one constraint at a time. Check missing, malformed, boundary, overlong, nested, array, and unknown fields against the documented contract. For mass assignment, limit fields such as role, owner, or verification status to synthetic objects. Acceptance of an undocumented field alone is not proof of a vulnerability; compare it with the intended schema and server policy, then verify whether state actually changed.
Review resource limits on operations with different costs, such as login, token issuance, search, export, and bulk writes. Within the approved test limit, increase request volume slowly and record when throttling starts and the response. Do not run load or denial-of-service tests, credential guessing, or data harvesting without explicit separate approval. Request-frequency throttles alone may not limit expensive work inside one request, so also review page sizes, upload sizes, concurrent jobs, and costly functions.
For webhooks or external URL fetching, use only an agreed test host to check that server-side requests follow the allowed-target and redirect policy. Do not probe internal network addresses or cloud metadata without explicit scope and safe isolation.
Example: an orders API with two tenants
Hypothetical example: User A in Tenant A and User B in Tenant B each create a test order. For GET /v1/orders/{id}, combine B’s token with the ID of A’s synthetic order. The expected outcome is the documented denial, without exposing order data. Check PATCH and DELETE separately, using only test orders you created, and record the state and recovery method after each change. A should still be able to read their own order and change fields allowed by policy.
Separately, test whether a regular user in either tenant can call an administrator-only refund function. Do not combine permission to access an order with permission to issue a refund into one assertion. This scenario uses hypothetical synthetic data; it is not a test performed against a real API.
Verify findings and finish safely
For each finding, record the path and method, test account role and tenant, preconditions, reproduction steps, expected and actual results, data or state impact, relevant contract or policy, minimal redacted evidence, and a suggested fix. Do not include sensitive response bodies, tokens, personal data, or another user’s identifiers. Submit evidence through an approved private channel.
At the end, remove synthetic objects and disable or delete temporary accounts. Restore ordinary traffic levels and test settings, and ask the API owner to confirm there were no unintended side effects. If unapproved data appears or latency/errors rise, stop; retain only the time, request identifier, and redacted evidence needed to report it. Record any item without explicit scope or safe conditions as untested.
References
OWASP, [Web Security Testing Guide: API Testing](https://wstg.owasp.org/latest/16-API_Testing/) — areas including API reconnaissance, object/function authorization, authentication, rate limits, and mass assignment.
OWASP Cheat Sheet Series, [REST Assessment Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/REST_Assessment_Cheat_Sheet.html) — comparing OpenAPI with behavior and assessing tokens, BOLA, mass assignment, and limits.
OWASP Developer Guide, [API Top 10](https://devguide.owasp.org/en/07-training-education/07-api-top-ten/) — a taxonomy of API risk categories, not a replacement for test procedures.