API Security vs WAF vs API Gateway: Which?
A WAF, an API gateway and API security testing are three different tools, and none of them replaces the others: a WAF filters known attack patterns, a gateway controls who can call your API and how often, and testing finds the flaws in your own logic that both of them let through.
This post is for owners and small teams who keep seeing these terms and want to know which one protects their API. You will get a plain-English definition of each, a side-by-side table of what each one does and misses, a few checks you can run today, and a simple decision guide at the end.
An API (application programming interface) is the part of your site or app that other software talks to. Your mobile app, your checkout page and your login form all use one to fetch and save data.
The short answer
Most small teams do not need all three tools on day one. Here is the honest version:
- A WAF is a cheap first layer that blocks common, noisy attacks.
- An API gateway is useful once you have several services, partners or public API keys to manage.
- API security testing is the only one of the three that checks whether your API lets the wrong person see the wrong data.
The first two are controls you switch on. The third is a check that tells you whether your controls and your code actually work.
What each one actually does
Web application firewall (WAF)
A WAF sits in front of your site and inspects each request. It blocks requests that look like known attacks, such as SQL injection (tricking a database into running attacker commands) or cross-site scripting (injecting script into a page). Many WAFs use rule sets built from the OWASP Core Rule Set. Cloud providers sell managed versions, for example the Cloudflare WAF.
A WAF judges the shape of a request. It does not know your business rules. A request that asks for someone else's invoice looks perfectly normal to it.
API gateway
An API gateway is a single front door for your API traffic. It routes requests to the right service and applies shared rules: checking API keys or tokens, rate limiting (capping how many requests one caller can make), logging and basic request validation. Examples include Kong, AWS API Gateway and Azure API Management.
A gateway can confirm that a caller has a valid token. It usually cannot decide whether that caller is allowed to see that specific record. Your application code makes that decision.
API security testing
API security testing means someone (or something) actively probes your API the way an attacker would. A manual test is done by a person who reads your API, logs in as different users and tries to break the rules. They look for broken access control, weak authentication, data your API returns but should not, and missing limits.
This is where manual testing differs from automated scanning: a scanner can match patterns, but a person can reason about what should be allowed.
General application security
Application security (AppSec) is the whole discipline of building and running software safely. It includes secure coding, patching, dependency updates, secrets handling, configuration, logging and testing. A WAF, a gateway and an API test are all pieces of it.
Side-by-side: what each tool does and misses
| WAF | API gateway | API security testing | General app security | |
|---|---|---|---|---|
| Main job | Filter bad-looking requests | Route, authenticate and limit API calls | Find real flaws by probing the API | Build and run software safely |
| Good at | Known attack patterns, bot noise, virtual patching of known bugs | Token checks, rate limits, central logging, versioning | Broken access control, logic flaws, data exposure, weak auth | Prevention across code, config and process |
| Usually misses | Business logic abuse, stolen valid tokens, access to other users' data | Per-record permissions, flaws inside your code | Anything introduced after the test | Gaps nobody has checked |
| When it works | Continuously, on live traffic | Continuously, on live traffic | At a point in time | Ongoing habit |
| Replaces the others? | No | No | No | It is the umbrella for all of them |
API security vs application security vs web application security
These three terms overlap, which is why they confuse people.
- Application security is the broad umbrella for any software.
- Web application security focuses on browser-facing sites. The usual reference is the OWASP Top 10.
- API security focuses on the endpoints that machines call. It has its own list, the OWASP API Security Top 10.
If you run a typical small site, your web app and its API are tested together. Your website's own API (the one your pages call) is part of that site. A separate API used by a mobile app or partners deserves its own attention, because nothing in the browser protects it.
Why a WAF and gateway are not enough: a worked example
The top item on the OWASP API list is Broken Object Level Authorization, often shortened to BOLA. In plain terms: the API checks that you are logged in, but not that the record you asked for belongs to you.
Imagine an endpoint like GET /api/orders/1002. Customer A is logged in and changes the number to 1003. If 1003 belongs to Customer B and the API returns it, that is a data leak.
The WAF sees a normal request. The gateway sees a valid token. Both let it through. Only your code, or a test that tries it, can catch this.
Quick checks you can run today
Run these only against an API you own, and preferably on a test account.
- Test for other users' data. Create two test accounts. Log in as A, copy A's token, then request one of B's records:
curl -i -H "Authorization: Bearer USER_A_TOKEN" https://api.example.com/orders/USER_B_ORDER_ID
You want 403 (forbidden) or 404 (not found). A 200 with B's data is a serious bug.
- Test for missing login. Repeat the request with no
Authorizationheader. You want401(not authenticated).
- Test rate limits. Send a burst of requests to your login endpoint and count the status codes:
for i in $(seq 1 30); do curl -s -o /dev/null -w "%{http_code}\n" -X POST -H "Content-Type: application/json" -d '{}' https://api.example.com/login; done | sort | uniq -c
If all 30 requests return the same status (such as 401 or 400) and you never see a 429 (too many requests) or a block, your login may have no rate limit. Limits can be set higher than 30 requests, or applied per account, so confirm with your developer or host. Some APIs also slow guessing in other ways, such as account lockouts or growing delays, so treat this as a prompt to check, not proof. Do this on staging or off-peak, since you may lock yourself out.
- Check your security headers. The free security headers tool shows which protective response headers your site sends.
- Ask what your API returns. Open a response and look for fields the app never shows, like internal IDs, emails or admin flags. This is called excessive data exposure (OWASP's 2023 list files it under Broken Object Property Level Authorization, API3:2023).
A simple decision guide for small teams
Pick the row that sounds most like you.
- One website, no separate API. Turn on a managed WAF if your host or CDN offers one. Make sure logins are rate limited. Get the site and its API tested by a person.
- A site plus a public API or API keys for customers. Add a gateway or built-in rate limiting and key management. Keep the WAF. Test access control between customers before launch.
- A mobile app with its own backend. The app can be copied and inspected, so the API must defend itself. Prioritise testing the API directly. A gateway helps with limits and logging.
- Several services or partners. A gateway is worth the effort here. Pair it with regular testing, because more services means more places for a permission mistake.
- A client asks for proof you are secure. A tool alone will not satisfy them. A written report from a human test gives you something concrete to hand over.
If you are not sure whether you are exposed, the guide on whether your website is hackable is a good place to start.
What none of this guarantees
No mix of tools makes a system unhackable. A WAF can be misconfigured, a gateway can be bypassed if your API is reachable directly on another address, and a test only covers the moment it was done. The goal is to reduce risk and find problems early, not to reach perfect.
Key takeaways
- A WAF filters known attack patterns. It cannot tell whether a user should see a particular record.
- An API gateway controls access and traffic, but permission checks on each record still live in your code.
- API security testing is the only option here that finds logic and access-control flaws before an attacker does.
- Most small teams should start with a managed WAF, rate limits on logins, and one manual test of the site and its API.
- Retest after big changes, since protection is not permanent.
Next step
If you want a person to try these checks, a Bug Circuit audit tests your website and the API that site itself calls. A separate API, such as a mobile app backend or partner API, is a standalone API assessment, quoted first, and Pro and Premium add deeper API testing of your website's own API (Advanced API testing). Premium also includes one standalone API assessment and one mobile app assessment each quarter.
Essential is $49 one-time for 1 website and covers manual testing by a real engineer, in standard depth, ending in a written report with severity, evidence and fix steps. Advanced API testing is not available on Essential, and a separate mobile app backend is not covered by the $49 audit. It is a focused small-site audit, not a multi-week enterprise pentest or a compliance certification. We report the problems and explain the fixes. Fixing is a separate service, quoted per issue. See the plans and pricing or run the free passive check first.
A real human security engineer audits your whole site by hand and sends a full report: every issue, its severity, and the exact fix. From $49, with a 14-day money-back guarantee.