How to Security Test an API
APIs need different security testing than traditional web pages. Here's a practical, step-by-step approach to testing an API for real vulnerabilities.
APIs get tested differently than traditional web pages, for a simple reason: there's no UI constraining what requests get sent. A web form might limit input length or type through client-side validation, but an API endpoint receives whatever a client — or an attacker bypassing the intended client entirely — chooses to send. Testing needs to account for that directly.
Start by mapping the actual API surface
Before testing, establish what actually exists:
- Every documented endpoint — from OpenAPI/Swagger specs if available
- Undocumented or internal endpoints, which are common and often less scrutinized
- Every HTTP method each endpoint supports, not just the obvious one
- Versioned endpoints — older API versions are often left running, less maintained, and less tested than the current version
Undocumented and older-version endpoints are disproportionately likely to have issues, precisely because they receive less attention.
Test authentication thoroughly
- Can endpoints be reached without a token or credential at all?
- Are tokens validated correctly — checked for expiration, signature, and issuer, not just presence?
- Can an expired or revoked token still be used?
- Are API keys or tokens exposed anywhere they shouldn't be — client-side code, logs, URLs?
Test authorization at the object level
This is the category that causes the most damage in real-world API breaches: Broken Object Level Authorization, where an endpoint checks that a user is authenticated but doesn't verify they're authorized to access the specific resource requested.
Test this directly: authenticate as one user, then attempt to access, modify or delete another user's resources by changing an ID in the request. This single test category catches a disproportionate share of serious real-world API vulnerabilities.
Test input validation and injection
APIs frequently accept structured input — JSON, XML — and injection testing needs to account for that structure, not just flat form fields:
- SQL injection through JSON body fields, not just query parameters
- NoSQL injection, if the backend uses a NoSQL database, which has its own distinct injection patterns
- Command injection through any field that might be passed to a system command
- XML external entity (XXE) injection, if the API accepts XML input
Test rate limiting and resource consumption
APIs without rate limiting are vulnerable to abuse — brute-force attacks against authentication, or resource exhaustion through expensive requests sent at volume. Test whether rate limiting actually exists, and whether it applies per-user or can be bypassed by rotating credentials or IP addresses.
Test mass assignment
Check whether an endpoint accepting an object for update or creation properly restricts which fields a client can set. A classic example: a user-update endpoint that inadvertently allows a client to set a role or isAdmin field simply because it's present in the request body and the backend doesn't explicitly restrict which fields are writable.
Test error handling
Verbose API error responses can leak internal details — stack traces, database structure, internal service names — that are useful to an attacker mapping the system. Check what actual error responses look like, not just the happy path.
Don't skip internal or partner APIs
APIs intended only for internal services or trusted partners are often tested less rigorously, under the assumption that they're not internet-facing. That assumption is frequently wrong, or becomes wrong later as infrastructure changes — internal APIs deserve the same testing rigor as public ones.
How does Averto fit in?
API testing is a core part of Averto's continuous scanning — including authenticated, object-level authorization testing, which is where a disproportionate share of real-world API vulnerabilities live and where many generic scanners fall short.
Frequently asked questions
What's the most common serious API vulnerability?
Broken Object Level Authorization — where authentication is checked but authorization to the specific requested resource isn't — is consistently among the most common and damaging API vulnerability categories.
Do internal APIs need the same security testing as public ones?
Yes — internal-only status is often assumed rather than verified, and can change as infrastructure evolves.
How is API testing different from testing a web page?
APIs lack UI-level constraints on input, so testing needs to directly craft requests — including structured payloads like JSON — rather than relying on what a browser interface would normally allow.
Should older API versions still be tested?
Yes — older versions often remain reachable and are frequently less maintained and less tested than the current version, making them a common source of overlooked vulnerabilities.