Are REST APIs a Security Risk? Threats and Defenses
July 16, 2025
REST APIs can expose serious security flaws, but REST itself is not the vulnerability. REST is an architectural style built around resources and standard HTTP semantics. Security depends on how an API authenticates callers, authorizes each action, validates data, constrains resource use, manages inventory, and protects its dependencies.
The most damaging failures often occur after a request has a valid token. If the API does not verify that the caller may access a particular account, field, function, or business flow, edge authentication alone cannot prevent the abuse.
This guide maps REST API risks to the OWASP API Security Top 10 – 2023, explains where the controls belong, and shows how an API gateway can contribute without becoming a substitute for application security.
Key Takeaways
- REST does not provide or prohibit a security mechanism; HTTPS, identity, authorization, validation, and abuse controls must be designed explicitly.
- Authentication answers who or what is calling. Authorization must also be checked for every object, function, property, and business action.
- A valid JSON schema does not make a request safe. Services still need semantic and business validation.
- Rate limits reduce some forms of resource abuse, but sensitive business flows also need domain-specific controls.
- An API gateway can enforce edge policies and normalize telemetry, while services retain data-aware authorization and business rules.
- Inventory, retirement, dependency validation, secret handling, and incident response are part of API security—not optional operational extras.
Why REST Is Not Inherently Insecure
The HTTP specification defines methods, status codes, fields, caching, and message semantics. It does not define who may transfer money or view an invoice. REST likewise encourages constraints such as a uniform interface and stateless interactions, but it does not supply an authorization model.
Statelessness does not require sending a reusable secret in every request. A client can present a short-lived access token over TLS, and the resource server can validate that token without an application session. Conversely, a stateful application can still be insecure if session identifiers leak or authorization checks are missing.
Predictable resource URLs are also not a vulnerability by themselves. /users/123 becomes dangerous when changing 123 to 124 returns someone else's data. Object identifiers should not be treated as secrets; the service must enforce access for the requested object.
SOAP is not automatically safer. WS-Security defines message-level mechanisms used by some SOAP systems, while REST APIs commonly use TLS and established HTTP authorization protocols. Either style can be deployed securely or insecurely. The correct comparison is the complete threat model and implementation, not the wire format.
The Main REST API Security Risks
1. Broken Object-Level Authorization
Broken object-level authorization (BOLA) occurs when an API accepts an object identifier without checking the caller's permission for that object. It can affect reads and writes:
GET /accounts/381/statements Authorization: Bearer <access-token>
The token may be valid, but the account service still needs to decide whether the authenticated subject can read account 381. This check belongs close to the data and business policy. Random identifiers make guessing harder but do not replace authorization.
Tests should include access to another user's object, objects in another tenant, deleted or archived objects, and nested resources. Denials should not leak sensitive object details through error messages.
2. Broken Authentication
Authentication failures include weak credential recovery, exposed API keys, tokens accepted with the wrong issuer or audience, missing signature verification, long-lived credentials without rotation, and secrets written to source code or logs.
For OAuth 2.0 deployments, follow the current OAuth 2.0 Security Best Current Practice (RFC 9700). A resource server should validate the token type, signature or introspection result, issuer, audience, expiration, and required scope according to its protocol and identity-provider configuration. Do not accept a token merely because it can be decoded.
API keys can identify a calling application, but they often do not represent an end user or provide fine-grained delegated authorization. Store API keys securely, show secrets only when necessary, transmit them over TLS, rotate them, and never put them in URLs where browsers, proxies, and logs may retain them.
3. Broken Object-Property Authorization
APIs can expose or accept fields that the caller should not control. A response may reveal an internal risk score, or an update endpoint may accept role: "admin" because a generic object mapper copies every submitted field.
Use explicit request and response models for each operation. Allow-list writable fields, enforce field-level authorization, and return only the properties required by the client. Schema validation helps reject unknown fields, but the service must still decide whether this caller may view or modify each protected property.
4. Unrestricted Resource Consumption
An inexpensive request for the client can be expensive for the server. Examples include a large upload, an unbounded page size, a deeply nested filter, expensive image processing, excessive concurrent connections, or repeated password-reset messages.
Apply several limits rather than relying on one requests-per-minute rule:
- maximum request and response sizes;
- connection, header, and body timeouts;
- pagination and query-complexity bounds;
- concurrency limits for expensive operations;
- per-consumer or per-tenant quotas where identity is reliable;
- budget and billing safeguards for paid downstream services.
Limits should reflect the cost and contract of each API. A global limit that protects a read endpoint may be too high for an expensive export and too low for a lightweight health query.
5. Broken Function-Level Authorization
An authenticated user may discover an administrative or partner endpoint and call it directly. Hiding the route in a UI does not protect it. Every function must enforce the required role, scope, relationship, and state transition on the server.
Test method changes and alternate routes, such as whether a read-only user can send DELETE, call an older version, or reach an internal administrative path through a public gateway. Deny by default and keep authorization policy understandable enough to review.
6. Unrestricted Access to Sensitive Business Flows
Some abuse uses valid requests rather than malformed input: scalping inventory, creating accounts in bulk, redeeming promotions repeatedly, scraping prices, or automating reservations. Authentication and a generic rate limit may not distinguish legitimate automation from abuse.
Protect these flows with domain signals and proportional friction. Controls can include per-account and per-device velocity rules, inventory holds, idempotency, risk scoring, confirmation steps, and manual review. Consider accessibility, privacy, and false-positive impact before adding challenges.
7. Server-Side Request Forgery
Server-side request forgery (SSRF) appears when an API fetches a caller-controlled URL without restricting the destination. The server may then reach cloud metadata, loopback services, private networks, or privileged internal APIs.
Prefer identifiers mapped to approved destinations over arbitrary URLs. If remote fetching is required, use a strict allow-list, resolve and verify addresses, block private and link-local ranges as appropriate, restrict redirects and protocols, set response-size and time limits, and apply network egress controls. Validation must consider DNS changes and alternate IP representations rather than checking only the original string.
8. Security Misconfiguration
Common examples include a public management endpoint, permissive CORS, detailed error stacks, unused HTTP methods, default credentials, missing TLS verification, verbose production logging, and inconsistent policy between routes or environments.
CORS is a browser rule, not an API authorization mechanism. Allowing an origin does not prove the user should access a resource, and non-browser clients do not enforce CORS. Keep administrative and metrics endpoints on protected networks, apply least privilege, scan configuration, and verify the deployed result rather than only reviewing a template.
9. Improper Inventory Management
Unknown and outdated endpoints are difficult to protect. Old versions, test hosts, forgotten subdomains, shadow APIs, and undocumented partner routes may miss current controls.
Maintain an inventory that records owner, environment, version, data classification, authentication method, exposure, dependencies, and retirement date. Compare the intended catalog with gateway configuration, DNS, traffic observations, and cloud inventory. A deprecated API needs a measured migration and removal plan; adding a Deprecated header does not remove its risk.
10. Unsafe Consumption of APIs
Applications often trust data from upstream or third-party APIs more than public input. A compromised or malfunctioning provider can return malicious content, oversized payloads, unexpected redirects, or incorrect data.
Validate responses against the contract, constrain size and time, verify TLS identities, restrict redirect behavior, and sanitize data before it reaches interpreters or downstream systems. Use bounded retries with idempotency awareness. Treat webhooks as untrusted inbound requests: verify their authenticity, prevent replay, and process them through a durable, bounded design.
flowchart LR
Client[Client] --> Edge[CDN, WAF, or network protection]
Edge --> Gateway[API gateway]
Gateway --> Service[Resource service]
Service --> Data[(Domain data)]
Gateway --> Identity[Identity provider]
Service --> Dependency[Third-party API]
Gateway --> Telemetry[Security telemetry]
Service --> Telemetry
Edge -. volumetric defense .-> Gateway
Gateway -. identity, quotas, request policy .-> Service
Service -. object and business authorization .-> Data
A Defense-in-Depth Design
Protect Transport and Network Boundaries
Use HTTPS for external APIs and validate certificates and hostnames. TLS 1.3 is defined in RFC 8446; the exact version and cipher policy should follow the organization's supported clients and security baseline. Consider mTLS for workload or partner identity when certificate lifecycle and revocation can be operated reliably.
Keep the gateway control plane, Admin API, metrics, debug interfaces, and configuration store separate from public data-plane traffic. Network controls are not a substitute for identity, but they reduce unnecessary exposure.
Authenticate at the Boundary, Authorize at Every Layer
A gateway can reject missing or invalid credentials before a request consumes application capacity. It can enforce route scopes or consumer policy and pass a normalized identity context downstream over a trusted channel.
The service must repeat the decisions only it can make: object ownership, tenant membership, field access, account state, monetary limit, and valid workflow transition. Do not let clients supply an identity header that the gateway later treats as authoritative; remove or overwrite such fields at the trust boundary.
sequenceDiagram
participant C as Client
participant G as API gateway
participant I as Identity system
participant S as Resource service
C->>G: Request with access token
alt Signed token validated locally
G->>G: Verify signature, issuer, audience, expiry, and scope
else Opaque token introspection
G->>I: Introspect token over an authenticated channel
I-->>G: Active token result and authorized attributes
end
G->>G: Check route policy and coarse scope
G->>S: Request with trusted identity context
S->>S: Check tenant, object, property, and business policy
S-->>G: Authorized response or denial
G-->>C: Return API response
Validate Structure and Meaning
Request validation should constrain types, formats, required fields, allowed properties, and collection sizes. The following JSON Schema is a structural starting point for a payment request:
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": ["amount_minor", "currency", "idempotency_key"], "properties": { "amount_minor": { "type": "integer", "minimum": 1 }, "currency": { "type": "string", "enum": ["USD", "EUR"] }, "idempotency_key": { "type": "string", "minLength": 16, "maxLength": 128 } }, "additionalProperties": false }
The example uses integer minor units for its allowed currencies instead of a binary floating-point amount. It still does not confirm that the account has funds, the caller owns the payment source, the amount is below a transaction limit, or the idempotency key has not already been used for different data. Those semantic checks belong in the payment service. Also validate outbound responses where an untrusted dependency is involved.
Design Safe Errors and Telemetry
Return enough information for a client to correct a request without revealing stack traces, database details, internal hosts, or whether an unauthorized object exists. Use a correlation identifier that is safe to expose, but do not put unbounded request IDs into metric labels.
Log authentication and authorization outcomes, administrative changes, unusual resource use, and sensitive-flow decisions with appropriate redaction. Never log access tokens, API keys, session cookies, passwords, or full sensitive payloads. Protect the telemetry store and test that alerts arrive when the pipeline fails, not only when attacks are detected.
What an API Gateway Can and Cannot Do
An API gateway is valuable because it applies consistent controls before requests reach many services. Depending on the product and configuration, it can provide:
- TLS termination and upstream TLS policy;
- API key, JWT, mTLS, OAuth 2.0, or OpenID Connect integration;
- route- and consumer-level rate limiting;
- request-size and schema checks;
- IP and network policy;
- header normalization and removal of spoofable identity fields;
- centralized metrics, logs, and trace propagation.
These controls are not automatic. A route with no authentication plugin remains unauthenticated; a schema validates only what it describes; a rate limit does not prevent all business abuse; and a gateway cannot infer object ownership from a URL.
Apache APISIX provides documented plugins for OpenID Connect, request validation, and request limiting, among other controls. Validate plugin fields and behavior against the APISIX release you deploy, protect the Admin API, and test both allowed and denied cases. Edge controls should complement, not replace, service-side authorization.
Secure Development and Operations Checklist
Before Implementation
- Classify the data and business actions exposed by each operation.
- Identify human users, calling applications, workloads, and administrators separately.
- Decide which authorization belongs at the route, object, property, and workflow levels.
- Model abuse cases, resource costs, third-party dependencies, and failure behavior.
During Implementation
- Use maintained identity libraries and explicit issuer, audience, algorithm, expiry, and scope validation.
- Allow-list accepted fields and enforce object and function authorization in the owning service.
- Bound payload, pagination, concurrency, execution time, and outbound calls.
- Use parameterized database operations and context-appropriate output encoding.
- Store secrets outside source code and prevent them from reaching URLs or logs.
- Make state-changing retry behavior explicit with idempotency where required.
Before Release
- Test access across users, tenants, roles, object states, API versions, and HTTP methods.
- Verify deployed gateway and infrastructure policy, including management endpoint exposure.
- Run dependency, secret, static, dynamic, and API-specific tests as part of a broader review.
- Exercise rate limits, timeouts, dependency failure, key rotation, rollback, and telemetry failure.
- Register the API owner, version, environment, exposure, and retirement policy in the inventory.
In Production
- Monitor user-visible errors and latency alongside authentication, authorization, limit, and business-abuse signals.
- Review rejected requests without assuming every denial is malicious.
- Rotate credentials, patch dependencies, and remove retired routes.
- Reconcile observed hosts and routes with the approved inventory.
- Practice incident response for credential exposure, unauthorized data access, and dependency compromise.
Conclusion
REST APIs become a security risk when their implementation trusts valid-looking requests more than verified identity, authorization, and business policy. The defense is not to abandon REST or assume another protocol supplies security automatically. It is to design controls around the API's data, operations, users, and dependencies.
Use a gateway for consistent edge authentication, traffic policy, structural validation, and telemetry. Keep object-level, property-level, function-level, and business-flow authorization in the services that own those decisions. Add resource bounds, inventory, dependency validation, secret hygiene, and tested incident response. Together, these layers address the ways real REST APIs fail without promising that one component can make an entire system secure.

