Implementing security boundaries between microservices
Implementing security boundaries between microservices connects a security requirement to the behaviour of a real feature. The relevant controls need to remain effective across custom code, integrations and the production configuration. Understanding security boundaries between microservices helps establish which security property the feature needs and where that property is actually enforced.
What does this involve?
A framework provides useful security mechanisms only when the application uses them consistently and deploys them with appropriate settings. Custom handlers, plugins and alternate execution paths can bypass protections that the development team assumes are automatic.
Each service must enforce access to its protected operations, including internal calls. Prefer shared, reviewed policies as the system grows, with service-level enforcement of object, tenant, and business-specific rules. See Authorisation Patterns for policy placement and Policy and Data Distribution for update and outage handling. Gateway checks complement these controls; they do not establish that a downstream operation is authorised.
Propagate authenticated user context in a form each receiving service can validate, and authenticate the calling service separately. A signature protects an assertion's integrity; it does not itself grant access to a requested resource. See Identity Propagation Patterns for forwarding, token exchange, trusted internal assertions, and their limitations.
Why it matters
Consider a realistic failure: a microservice trusts a network location or forwarded header as sufficient permission to perform a privileged operation.
A configuration or integration mistake can affect many routes at once. The important question is which application data and operations become reachable, rather than whether a framework option merely differs from its default.
Implementation guidance should be applied to a real feature and its deployment. Framework defaults, custom handlers and integrated services all influence whether the intended protection remains effective.
How penetration testers check for it
Trace the relevant feature from its entry point to the data or operation it protects, including custom code and alternate paths.
- Review supported runtime versions and release settings.
- Trace identity, input and output through real application paths.
- Inspect custom integrations and security overrides.
- Test important negative cases alongside ordinary functionality.
How to fix it
Use the appropriate maintained mechanisms and verify the result in the actual production configuration.
- Use gateway checks to reject unauthorised ingress requests, and prevent direct access that bypasses those checks. Keep fine-grained authorisation at the service when it needs resource or business context. See Authorisation Patterns for gateway and proxy enforcement, its limitations, and propagated authorisation context.
- The microservice queries the token service. For OAuth, token introspection reports whether a token is active and can reflect revocation known to the authorisation server.
- The microservice validates a signed token using trusted issuer keys and the applicable token profile. For example, RFC 9068 defines validation for JSON Web Token (JWT) access tokens; signature verification alone is insufficient. See validation at each boundary.
- This avoids a per-request introspection call, but local validation alone does not detect server-side revocation before token expiry. Use token lifetimes or an additional revocation mechanism that meets the required response time.
- Avoid unnecessary custom replacements for trusted mechanisms.
- Retain regression checks for the application's actual trust boundaries.
A secure framework cannot determine every business permission or data ownership rule. Those requirements still need clear application design and enforcement.
Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.
Related issues
- Isolating trust between independently deployed frontend modules
- Securing Next.js rendering, server actions and data boundaries
- Implementing OAuth flows with safe redirects and token boundaries
Read about our methodology or contact pentested.com to discuss secure development and code review.