API security testing: what each method finds, and what it misses

API security testing is checking an API for the weaknesses attackers use: endpoints that return other users' data, missing authentication, injection, and calls with no limit on cost. No single method finds all of them. Scanners are good at known patterns, people are good at business logic, and runtime filtering covers the time between finding a flaw and fixing it.

Section API security Updated Compares four approaches

Quick facts

Goal
Find authorisation, authentication, injection and resource-use flaws before attackers do
Checklist to test against
OWASP API Security Top 10 2023
Methodology
OWASP Web Security Testing Guide, which includes API tests
Hardest to find automatically
Broken object level authorization and business logic flaws
What runtime filtering adds
Protection between finding a flaw and fixing it; not discovery

The risks being tested for are summarised on API security and OWASP API Top 10.

API security testing methods compared

MethodWhen it runsGood atMisses
Static analysisOn the code, before deploymentInjection, unsafe functions, secrets in codeAuthorisation across requests, configuration
Dynamic scanningAgainst a running APIKnown patterns, missing headers, verbose errorsBusiness logic, other users' objects
Manual testingAgainst a running API, by a personAuthorisation, logic, chained flawsBreadth, repeatability
Runtime filteringIn front of production trafficBlocking known attack shapes and limiting ratesFinding the flaw in the first place

Most teams combine the first two in their build pipeline, add manual testing for important releases, and keep runtime filtering on all the time.

Security testing for API endpoints: what to run first

Security testing for API endpoints starts with an inventory, because whichever API security testing method you pick, a scanner or static analysis can only reach routes it knows about. List every route in the API description, then mark the ones that take an identifier, accept uploads or change data. Run a scan against a staging copy and read which routes it reached. Spend manual time on the marked routes. Security testing API endpoints in order of exposure keeps results comparable between releases; the routes nobody lists are the ones no tool visits. Once the inventory exists, API endpoint security turns each route into a short checklist, and the HTTP methods a route accepts are the first line of it. Two checks worth adding are for mass assignment and, for query-based APIs, GraphQL security. Inventory gaps are the subject of shadow APIs.

DAST: dynamic application security testing, and how it differs from a WAF

DAST meaning: dynamic application security testing, the dynamic scanning row above. OWASP describes it as black-box testing that finds security vulnerabilities and weaknesses in a running application by injecting malicious payloads, without needing the source code. Static application security testing (SAST) is its counterpart: it reads the code. A DAST tool is a program that communicates with a web application through its web front end, which makes it a web application security scanner; it is one form of web application security testing.

OWASP names input and output validation, authentication issues and server configuration mistakes as what DAST tools are especially helpful for detecting, and notes that they can run as part of a nightly scan, so a CI/CD pipeline can include one. OWASP's ZED Attack Proxy (ZAP) is listed there as an open-source example. A dynamic test cannot cover all of an application's code, so check what a scan reached.

A DAST scan and a WAF both deal with attack-shaped requests, at different moments. A scan sends test attacks at a running API so you can fix what it finds. A WAF sits in front of live traffic and matches requests against named categories; it finds nothing in your code. A scan result can still guide the filter while the fix is made, as under Reading the results below.

Testing authorisation: the part tools miss

The most common serious API flaw, broken object level authorization, is a correct-looking request for an object the caller does not own. A scanner sees a valid response and moves on; only a test that knows which user owns which object can tell. How such a test works is on BOLA.

Test it with two accounts. Create objects as one user, then request, change and delete them as the other, by changing identifiers in paths, bodies and query strings. Repeat for every endpoint that takes an identifier, including old versions.

WHICH METHOD REACHES WHICH RISK INJECTION OBJECT AUTHORIZATION RESOURCE CONSUMPTION BUSINESS LOGIC STATIC ANALYSIS DYNAMIC SCANNING MANUAL TESTING RUNTIME FILTERING // only people reliably test authorisation and logic
// four methods, and the risks each one can reach

An API security test checklist

  • Every endpoint without credentials returns an authentication error, unless public on purpose.
  • Every identifier, changed to another user's, returns a not-found or forbidden response.
  • Every field in a response is one the caller is allowed to see.
  • Every writable field is one the caller is allowed to change, including role and owner fields.
  • Every list, upload and expensive call has a size and rate limit that holds under repeated requests.
  • Every old version still answering gets the same tests as the current one.

When to test an API

Continuously for what is cheap: static analysis and a scan of each build catch injection, exposed secrets and missing API authentication before deployment. Before release for what is expensive: manual authorisation tests on new or changed endpoints, especially those that take identifiers. And whenever the API description changes, because a new endpoint is a new surface.

Old versions deserve a place in the schedule. An endpoint that still answers on a previous version path usually lacks the fixes made since, and it is often missing from the description that tools read.

Choosing API security tools

Rather than comparing products, ask what each tool can see. Does it read your API description to know all endpoints? Can it hold two sessions to test authorisation? Does it run in your build pipeline, or only against a deployed environment? How many of its findings does your team actually fix? The same questions apply to any API security testing tools you shortlist, free or paid: what the tool sees decides what it can find.

A tool that produces a long list nobody acts on adds risk by making real findings harder to see. Start narrow, fix what it finds, then widen. Whatever you test, introduce runtime filtering by observing first, as on monitor mode.

Reading the results

Sort findings by what an attacker could do, not by the tool's severity label. A missing header on a public endpoint and a readable record belonging to another user may get the same rating; only the second is a data breach.

For each confirmed flaw, decide where it is fixed: authorisation and logic in the code, resource limits in the code or at the edge, known attack shapes optionally also in a filter while the fix is made, as virtual patching describes. Retest after the fix with the same request that found it.

Questions

What is API security testing?

API security testing checks an API for weaknesses such as broken authorisation, missing authentication, injection and unlimited resource use, using static analysis, scanning, manual testing or a combination.

Can automated tools find broken object level authorization?

Rarely on their own. Finding it requires knowing which user owns which object, so it is usually tested manually with two accounts.

What should API security tests check?

Authentication on every endpoint, object ownership on every identifier, which fields can be read and written, size and rate limits, and old API versions.

How do you start security testing for an API?

Start by listing every endpoint from the API description and marking the ones that take identifiers, uploads or writes. Scan a staging copy, then test the marked endpoints by hand with two accounts. Old versions that still answer belong on the list.

Does a WAF replace API security testing?

No. A WAF blocks known attack shapes and limits rates on live traffic; testing finds the flaws, including authorisation problems a WAF cannot see.

What is DAST?

DAST is dynamic application security testing: black-box testing that finds weaknesses in a running application by sending it malicious payloads, without access to the source code. Static analysis (SAST) reads the code instead.

Is DAST the same as a WAF?

No. DAST scans a running application to find weaknesses so you can fix them; a WAF filters live requests and finds nothing in your code. A scan can show what to filter while the fix is made.