WAF vs application security: where edge controls stop
What a WAF can and cannot see, mapped to the OWASP API Security Top 10 2023, with edge rules that help and the code fixes they cannot replace.
- Published
- Author
- Next Security Research
- Topics
- WAF
- API security
- Cloudflare
- Authorization
- Cloud security
- Tested scope
- Method article: no live system tested. Rule syntax follows Cloudflare Rules language documentation as of November 2026; feature availability depends on plan.
Key takeaway
A WAF reduces exposure to known request patterns and volume, but it cannot decide whether a user may touch a given object, so authorization flaws need a code fix.
TL;DR
A web application firewall inspects HTTP requests at the edge and decides whether to pass, challenge, rate-limit or block them. It is good at things that are visible in a single request or in request volume: known attack payloads, malformed input, unexpected methods and paths, abusive rates and automated clients. Used well, it buys time between disclosure of a vulnerability and a deployed fix.
It cannot see who owns the object in GET /api/invoices/8812, whether a discount can be applied twice, or whether a field in a JSON body should be writable by this user. Those decisions live in application code and data. A request that exploits a broken authorization check looks the same at the edge as a legitimate one.
Two conditions turn a WAF from a partial control into no control at all: an origin that accepts traffic not routed through the edge, and rules running in log-only mode that everyone assumes are blocking.
Business context and attack surface
Questions about WAFs usually come up in three situations. An auditor or customer questionnaire asks whether one is in place. A penetration test reports a finding and someone proposes marking it “mitigated by WAF”. Or a team is choosing where to spend limited engineering time and the WAF looks like the cheaper option.
All three are reasonable, and all three need the same answer: for each risk, does the edge see enough of the request and its context to make the right decision? Sometimes yes. For most API authorization and business-logic issues, no.
The attack surface has more than one entry point:
- The edge. DNS points at the WAF or CDN, which terminates TLS, applies rules and forwards to the origin.
- The origin. A load balancer, ingress or server with a public IP or hostname. If it accepts direct connections, the edge is optional for an attacker.
- The application. Authentication, authorization, input handling and business rules.
- Internal paths. Service-to-service calls, queues, webhooks from partners and admin interfaces that may not pass the edge at all.
What the edge sees, and what it does not
A WAF decision is based on the request line, headers, body (up to an inspection size limit), client IP and reputation, TLS and client fingerprints, and counts of similar requests over time. It usually does not know the application’s data model, the relationship between the authenticated user and the requested object, the state of a multi-step business flow, or what the response will contain.
| Control at the edge | Works well for | Stops at |
|---|---|---|
| Managed rule sets | Known payload classes such as SQL injection and XSS patterns, known CVE probes | Novel payloads, encodings the parser does not normalize, payloads in fields the rules do not inspect |
| Custom rules | Allowed methods and paths, blocking admin paths from the internet, required headers | Anything that needs per-user or per-object knowledge |
| Rate limiting | Credential stuffing, enumeration at volume, scraping | Low-and-slow abuse spread across many accounts or IPs |
| Bot management | Commodity automation | Real browsers driven by humans or well-built automation |
| Schema validation | Rejecting requests that do not match your OpenAPI spec | Requests that match the schema and abuse the logic |
Mapping to the OWASP API Security Top 10 2023
The OWASP API Security Top 10 2023 is a useful test because most of its entries are authorization and logic issues.
| Risk | Can the edge help? |
|---|---|
| API1 Broken Object Level Authorization | No. The request is valid; only the application knows ownership. Rate limits can slow bulk enumeration. |
| API2 Broken Authentication | Partly. Rate limits and bot controls slow credential stuffing; token validation flaws need a code fix. |
| API3 Broken Object Property Level Authorization | Mostly no. Schema validation can reject unknown fields; excessive data in responses needs a code fix. |
| API4 Unrestricted Resource Consumption | Yes, partly. Rate limits and body size limits help; expensive queries need application limits. |
| API5 Broken Function Level Authorization | Partly. Blocking admin paths at the edge helps when admin routes are distinct; role checks still belong in code. |
| API6 Unrestricted Access to Sensitive Business Flows | Partly. Bot and rate controls raise cost; the business rule belongs in the application. |
| API7 Server Side Request Forgery | Rarely. The malicious URL is often a legitimate parameter; egress controls at the server matter more. |
| API8 Security Misconfiguration | Partly. Can hide some exposed paths; cannot fix the configuration. |
| API9 Improper Inventory Management | No. Old API versions on other hostnames may not even route through the edge. |
| API10 Unsafe Consumption of APIs | No. This is your server trusting a third party’s responses. |
Worked case: object-level authorization
What an attacker needs
A valid account (often a free sign-up), and a way to learn or guess identifiers of other users’ objects: sequential IDs, IDs leaked in other responses, or IDs shared in URLs. With those, they send ordinary authenticated requests with a different ID.
What the WAF sees
GET /api/v1/invoices/8812 with a valid bearer token, a normal user agent, from a residential IP, at a normal rate. Nothing in that request is malformed. If the attacker stays under rate limits, there is nothing for the edge to act on.
What they cannot do
They cannot reach objects if the application scopes every lookup to the caller’s tenant or ownership. They cannot enumerate quickly if per-account rate limits are tight, and they cannot guess identifiers that are random and unguessable, though unguessable IDs are a mitigation for discovery, not a substitute for the check.
Root cause and fix
The root cause is a lookup that trusts a client-supplied key: CWE-639: Authorization Bypass Through User-Controlled Key. The fix is to make ownership part of the query, so a missing check cannot slip through in one handler:
// Before: any authenticated user can read any invoice
const invoice = await db.invoice.findUnique({ where: { id: req.params.id } });
// After: the lookup is scoped to the caller's tenant; a mismatch looks like not-found
const invoice = await db.invoice.findFirst({
where: { id: req.params.id, tenantId: req.auth.tenantId },
});
if (!invoice) return res.status(404).end();
For systems with many handlers, enforce the scope centrally (row-level security in the database, a repository layer that requires a tenant context, or a policy engine) and add a test that calls each object endpoint as a second user.
Edge configuration that does help
None of the above means the WAF is useless. These are examples of edge rules that are worth having, written in Cloudflare’s Rules language. Field and function availability varies by plan, so check the Rules language documentation for yours.
Allow only the methods your API uses:
# Custom rule, action: Block
starts_with(http.request.uri.path, "/api/")
and not http.request.method in {"GET" "POST" "PATCH" "DELETE"}
Require a JSON content type on write requests to the API:
# Custom rule, action: Block
starts_with(http.request.uri.path, "/api/")
and http.request.method in {"POST" "PATCH"}
and not any(http.request.headers["content-type"][*] contains "application/json")
Keep admin paths off the public edge unless the request comes from your access proxy:
# Custom rule, action: Block
starts_with(http.request.uri.path, "/admin")
and not ip.src in $corp_egress_ips
Beyond custom rules, rate limit login, password reset and object-read endpoints per account or API key where your plan supports counting by those characteristics, not only per IP. If you publish an OpenAPI description, schema validation at the edge rejects unknown paths and unexpected fields before they reach code.
Lock the origin
An edge you can walk around is decoration. Make the origin accept only traffic from the edge, using one of: a tunnel where the origin has no inbound public listener, mutual TLS between edge and origin (Cloudflare calls this Authenticated Origin Pulls), or at minimum a firewall allowlist of the provider’s published IP ranges. With nginx and mutual TLS:
server {
listen 443 ssl;
ssl_certificate /etc/nginx/certs/origin.pem;
ssl_certificate_key /etc/nginx/certs/origin.key;
ssl_client_certificate /etc/nginx/certs/edge-origin-pull-ca.pem;
ssl_verify_client on;
}
An IP allowlist alone still accepts traffic from other customers of the same provider, so prefer mutual TLS or a tunnel.
Virtual patching, with an expiry
When a vulnerability is disclosed and a fix needs days, a targeted rule can block the specific request pattern. Record it as a compensating control with a ticket for the code fix and an expiry date. If the rule outlives the fix, remove it; if the fix never ships, the rule becomes the only thing standing between the bug and the internet, and it was written in a hurry.
Validation steps
- Origin exposure. From outside your network, resolve historical DNS records and certificate transparency entries for your hostnames, then try to reach the origin directly with the correct
Hostheader. It should refuse the connection or fail the TLS handshake. - Rule mode. List every rule and its action. Anything in log or simulate mode is not blocking. Check how long it has been there.
- Exceptions. Review skip rules and managed-rule exceptions. Each should have a reason and an owner.
- Authorization tests in the application. With two test accounts, request each object endpoint for the other account’s objects. These tests should fail at the application regardless of WAF state; run them with the WAF bypassed in a test environment to prove it.
- Rule regression. For each virtual patch, keep a safe test request in staging that the rule should block, and run it after rule changes.
- Coverage. Compare the list of hostnames and API versions in DNS and your API inventory with what routes through the edge.
Framework mapping
- OWASP API Security Top 10 2023, as in the table above.
- CWE: CWE-639 for object-level authorization bypass, CWE-862: Missing Authorization for function-level gaps, CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes for mass assignment.
Limits and uncertainty
This is a method article. It does not benchmark any WAF product, and it makes no claim about detection rates for managed rule sets, which change with every ruleset release and depend on configuration.
Rule syntax and feature availability are Cloudflare-specific and plan-dependent. AWS WAF, Azure Front Door, Akamai and others offer comparable controls with different expression languages and limits, including different maximum body sizes for inspection.
Some edge platforms now offer features that learn API traffic patterns and flag sequence or volume anomalies. These can help detect enumeration of object IDs, but they infer behavior from traffic. They do not know your authorization model, and they do not replace the ownership check in code.