Join our Newsletter — 33% off our NHI Course

What is the difference between securing a microservice at the gateway and securing it inside the application itself?

Gateway security protects traffic before it enters the service, while application security depends on code inside each microservice to validate requests. Gateway controls are easier to standardise across many services, but they do not replace in-app checks for sensitive operations. The strongest approach uses both: the gateway as the primary enforcement point and the application as the final trust boundary.

Gateway Enforcement vs In-Application Enforcement

The gateway is the outer control plane for a microservice: it can authenticate callers, enforce coarse authorisation, rate-limit traffic, and block obviously invalid requests before they reach the service. Inside the application, the microservice still has to re-check identity, permission, request context, and business rules because the gateway only sees the edge of the request, not the full meaning of the action.

A gateway is best for standardised policy and consistent traffic shaping across many services. It is weaker for decisions that depend on resource ownership, transaction state, tenant context, or sensitive operations that only the service itself can interpret. That is why gateway security and application security solve different layers of the same trust problem, rather than duplicating each other.

This separation is visible in common API security guidance. OWASP ASVS places core authentication, session handling, and access control expectations inside the application, while OWASP API Security Top 10 highlights how broken authorisation often emerges when the API itself fails to enforce object or function boundaries.

Why the Application Remains the Final Trust Boundary

A gateway can reduce exposure, but it cannot safely make every decision for every endpoint. Once a request crosses into the service, the code must still validate whether the caller may access that record, invoke that function, or bypass a workflow rule. If the service trusts the gateway blindly, any routing mistake, misconfiguration, internal bypass, or reused credential path can become a direct privilege escalation path.

In practice, the application is where the service knows whether a request is for one user’s object, a shared tenant resource, a privileged admin action, or an operation that must be constrained by business logic. That is why the final check belongs in the service even when the gateway has already authenticated the caller.

For teams that use OAuth or token-based access, the same principle still holds: the gateway may validate token presentation, but the service should still verify audience, scope, and action-level permission before performing sensitive work. RFC 9700 and OAuth-based security guidance both reinforce that token acceptance at an edge component does not remove the need for correct downstream enforcement.

How to Think About Division of Responsibility

The practical test is simple: put controls at the gateway when the rule is about entry, volume, or broad policy consistency; keep the control inside the service when the rule depends on the data, state, or business meaning of the operation. A gateway can reject unauthorised or malformed traffic quickly, but only the application can reliably decide whether the request is valid for that specific microservice action.

That means the gateway usually handles shared concerns such as authentication, coarse allow or deny logic, schema filtering, and traffic protection, while the application handles fine-grained authorisation, object ownership, state transitions, and sensitive operations. This layered model is especially important when multiple teams build services independently, because central gateway policy alone rarely captures every service-specific exception.

Microservices that expose APIs also benefit from testing at both layers. API-focused testing should check whether the gateway blocks obvious abuse, but it should also confirm that direct service calls, alternate routes, and internal callers cannot bypass in-application checks.

Risk and Threat Considerations

The main risk is false confidence: teams treat the gateway as a substitute for service-level trust decisions and leave the application under-protected. When that happens, attackers, insiders, or even legitimate callers using the wrong path can exploit broken object-level or function-level authorisation inside the service.

Failure mechanism: A gateway enforces entry policy, but the microservice omits or weakens its own object, tenant, or action checks, so any path that reaches the service can trigger an unauthorised operation.

Impact: The result can be data exposure, privilege abuse, cross-tenant access, or silent business-logic abuse even though the edge layer appears to be secured.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while OWASP ASVS, NIST SP 800-53 Rev 5, NIST Zero Trust (SP 800-207) and NIST SP 800-63 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP ASVS V8 — Authorization Microservices need in-app authorization beyond gateway checks.
V6 — Authentication Gateway auth does not replace application authentication expectations.
Recommendation — Enforce service-level authorization for each sensitive endpoint. Validate authenticated identity before allowing service actions.
OWASP API Security Top 10 API5 — Broken Function Level Authorization A gateway cannot prevent service-level function abuse if the app skips checks.
API1 — Broken Object Level Authorization Object access must still be enforced inside the API or microservice.
API8 — Security Misconfiguration Overreliance on the gateway can hide service misconfiguration that weakens enforcement.
Recommendation — Protect privileged functions with application-side authorization checks. Verify object ownership and access on every request. Harden service routes and remove bypass paths.
NIST SP 800-53 Rev 5 AC-3 — Access Enforcement The service must enforce access decisions, not rely only on the gateway.
IA-2 — Identification and Authentication (Organizational Users) Caller identity still has to be validated before service access.
IA-5 — Authenticator Management Token and credential handling still matter when services accept gateway-mediated access.
Recommendation — Enforce access decisions at the system boundary and within the service. Authenticate callers before granting any protected service operation. Manage tokens and credentials so downstream services can trust them.
NIST Zero Trust (SP 800-207) Never Trust, Always Verify Microservice design benefits from verifying each request at the service, not trusting the network edge.
Recommendation — Apply per-request verification instead of assuming gateway trust.
NIST SP 800-63 Digital Identity Guidelines Token and assertion validation inform how identity is trusted across gateway and service boundaries.
Recommendation — Bind downstream authorization to validated identity and assurance.

Practitioner Guidance

What to verify: Confirm that every sensitive endpoint still performs its own authorisation decision, even when the gateway already authenticated the caller. The easiest mistake is to trust upstream headers or tokens without re-checking what the request is actually allowed to do inside the service.

What good looks like: The gateway provides consistent first-line enforcement, while the application independently enforces the final decision for object access, privileged functions, and workflow-sensitive actions. If either layer fails, the other should not be assumed to compensate.

Practitioner takeaway: Use the gateway to standardise and reduce exposure, but use the microservice itself to decide whether a specific action is truly allowed, because only the application has the full trust context.