Why are APIs a separate security topic?
An API is the application's gateway to data and actions, and it often carries fewer restrictions than the browser UI. An attacker does not fill in a form; they call the endpoint directly and change parameters. That is why the question that works for websites, "is the visitor human?", falls short for APIs.
The OWASP API Security Top 10 lists these risks. In brief:
- BOLA (broken object-level authorization): requesting
/orders/124instead of/orders/123and reading someone else's data. - Broken authentication: weak token generation, tokens that never expire, logins open to brute force.
- Unrestricted resource consumption: endpoints with no rate, size or pagination limits.
- Broken function-level authorization: an ordinary user able to call an admin endpoint.
- SSRF, misconfiguration, poor inventory: forgotten old versions that are still live.
What do a WAF and a rate limiter do, and not do?
Set balanced expectations by separating them:
| Threat | WAF / rate limiter | Real fix |
|---|---|---|
| SQL injection, XSS payloads | Helps (signatures and normalization) | Parameterized queries, input validation |
| Brute force, credential stuffing | Helps (rate limit) | Multi-factor authentication, account lockout |
| Resource consumption, scraping | Helps | Pagination limits, limits on costly queries |
| BOLA, function-level authorization | Does not solve | Ownership and role check on every request |
| Business-logic abuse | Partly | Application rules |
A WAF cannot know that a request is valid but unauthorized. GET /orders/124 is syntactically clean; only the application knows that order does not belong to this user. For how a WAF works in general, see what is a WAF.
How do you design a rate limit?
Pick the key. An IP alone is a blunt key: hundreds of customers behind one office or mobile-carrier NAT look like a single IP. For authenticated APIs a per-token limit is fairer; keep the IP limit as a second layer.
Pick the window. A fixed window allows a burst at the start of each minute. A sliding window gives smoother results.
Report the rejection well. When the limit is hit, return 429 Too Many Requests (RFC 6585) and say how long to wait with the Retry-After header (RFC 9110). Good clients back off by that value; a bare 429 with no hint invites a retry storm.
Weight by cost. A search endpoint and a health check should not share the same limit.
Token scopes and idempotency
Each token should be able to do only what it needs (least privilege). Separate a read-only token from one that creates sites, so a leaked token does limited harm. Make tokens expire and rotate them regularly.
An idempotency key prevents an operation from repeating when the same request is resent after a network error. The client sends a unique value for each logical operation; when the server sees the same value again, it returns the first response. It helps most on payment and resource-creation calls.
Webhooks and mobile apps
Browser-facing verification pages (CAPTCHA, proof-of-work) do not work for clients that do not run JavaScript. A payment system sending webhooks, a mobile app or a server-to-server call cannot solve such a page and gets blocked. The fix is to treat these paths separately: protect webhooks with signature verification on your side, exclude the path from the verification page, and limit it by IP or rate. How the bot side is handled is covered in bot protection.
Common mistakes
- One global limit. Login and password-reset endpoints need a far stricter limit than general read endpoints.
- Limiting only at the edge. Keep per-resource checks inside the application too; if the proxy is bypassed, the application is the last defense.
- Putting the token in the URL. A token in a query string leaks into access logs, browser history and referrers. Use a header.
- Not publishing the limit. If clients do not know it, they retry blindly; document it.
Error responses and inventory
Detailed error messages guide an attacker: stack traces, SQL error text and file paths leak information (CWE-209). Return a generic message and a correlation ID to the client, and keep the detail in the server log.
Inventory is a security job as well. A forgotten /v0 may still be live next to /v1, keeping an old unpatched code path open. List every version, every environment (staging included) and every endpoint, and shut down what is unused. To put staging behind an identity layer, see Zero Trust.
How Nexren Shield handles this
Traffic profiles. Per-IP request limits per second: api 20, webhook 5, realtime 30. These values are halved during an attack or mitigation.
Per-path rate limits. You can set a per-IP limit on a path; when exceeded, the response is 429 with Retry-After.
REST API v1. It is described in OpenAPI 3.1 and uses scoped tokens. You send the token as Authorization: Bearer <token> or in X-API-Key. The default per-token limit is 120 requests per minute (sliding window); there is also a per-IP limit of 300. Responses to requests sent with Idempotency-Key are kept for 24 hours. The base URL is shield.nexren.info/api/v1; documentation lives at apidocs.nexren.info.
MCP server. At shield.nexren.info/mcp it exposes six tools over JSON-RPC 2.0: list sites, get a site, create a site with DNS verification, purge the cache, read the WAF configuration and query events. Permissions match the panel's module permissions.
To see your token's identity and limits:
curl -s https://shield.nexren.info/api/v1/whoami \
-H "Authorization: Bearer YOUR_API_TOKEN"
The endpoint returns token metadata, granted scopes, the client IP and rate-limit status. Replace YOUR_API_TOKEN with your own token.
Limits: the WAF uses 600+ signature rules and is regex-based; its false-positive rate has not been measured. Nexren Shield does not fix authorization flaws such as BOLA. For the overall structure see the technology page. For behavior under attack, read when to use Under Attack mode.
Checklist
- Does every endpoint check ownership and role? (BOLA)
- Are tokens scoped, expiring and rotatable?
- Are rate limits defined separately for token and IP?
- Do 429 responses include
Retry-After? - Are webhook and mobile paths excluded from the verification page, and is there signature verification?
- Are old API versions in the inventory and shut down?
Sources
Related product pages:Technology
Frequently asked questions
Does a WAF close a BOLA flaw in an API?
No. In BOLA the request is entirely valid; the flaw is that the application does not check object ownership. It has to be fixed in application code.
Should I rate-limit by IP or by token?
Use the token for authenticated APIs and the IP for unauthenticated endpoints. A single-IP limit unfairly cuts off customers behind a shared egress IP; a token limit avoids that.
My mobile app cannot solve a CAPTCHA. What do I do?
Mobile apps and server-to-server calls cannot solve a browser-style verification page. Exclude the API paths or use the api traffic profile, and rely on tokens and rate limits for protection.
How does authentication work in the Nexren Shield API?
You send a scoped API token in the Authorization: Bearer header or in the X-API-Key header. Documentation is at apidocs.nexren.info.
What is an Idempotency-Key for?
If you resend the same request after a network error, it prevents the operation from running twice. Nexren Shield API v1 keeps responses for an Idempotency-Key for 24 hours.
Related guides
What Is a WAF? How a Web Application Firewall Works
A WAF (web application firewall) inspects the HTTP requests headed for your application against a set of rules and blocks attacks such as SQL injection and XSS before they reach the app.
Bot Protection and CAPTCHA Alternatives: Methods Compared
Bot protection answers three questions: is the client a real browser, does its behavior look human, and does the request come from a reputable source.
Zero Trust Access: A Practical Guide for Web Applications
Zero trust means a request is not trusted because it comes from inside the network; every access is verified by identity and context.
When to Enable Under Attack Mode: Decision Guide and Side Effects
Under Attack mode asks every visitor to pass a short verification before reaching your site.