Identity Propagation in Microservices: Securing Non-Human Identities

microservices identity propagation non-human identity workload identity machine identity security
Lalit Choda
Lalit Choda
 
June 26, 2025 11 min read

Introduction: The Challenge of Identity in Distributed Systems

Securing microservices starts with a strong foundation: understanding identity in distributed systems. But how do you ensure that each microservice knows who is accessing it, and what they are allowed to do?

In a microservices architecture, applications are built as suites of independent modules. Each microservice handles specific tasks, communicating with others via APIs. This distributed nature introduces unique challenges for identity management:

  • Authentication: Verifying the identity of users, services, or devices requesting access. For example, an IoT device trying to send data to a cloud service needs to prove it is what it claims to be.
  • Authorization: Determining what actions an authenticated entity is permitted to perform. Think of a healthcare application where a doctor has access to patient records, but a nurse might have limited access.
  • Identity Propagation: Passing identity information securely between microservices. Consider a retail application where the "Order Service" needs to know the user's identity to validate their payment with the "Payment Service".

Without proper identity propagation, you risk:

  • Security Breaches: Unauthorized access to sensitive data.
  • Compliance Violations: Failure to meet regulatory requirements (e.g., GDPR).
  • Operational Overhead: Increased complexity in managing and monitoring access controls.
sequenceDiagram participant User participant API Gateway participant Microservice A participant Microservice B
User->>API Gateway: Request
API Gateway->>Microservice A: Request (no identity)
Microservice A->>Microservice B: Request (no identity)
Microservice B-->>Microservice A: Response
Microservice A-->>API Gateway: Response
API Gateway-->>User: Response

In the above diagram, the lack of identity propagation creates a blind spot, where microservices A and B don't know who initiated the request.

As we move forward, we'll explore the risks associated with improper identity propagation and delve into strategies for securing non-human identities in your microservices.

Understanding the Risks of Improper Identity Propagation

Did you know that a data breach can cost a company an average of $4.45 million? That's why understanding the risks of improper identity propagation is crucial in a microservices architecture. Let's dive into why this is so important.

Without proper identity propagation, microservices operate in isolation, unaware of the original request's source. This can lead to a cascade of security vulnerabilities:

  • Unauthorized Access: If a microservice doesn't know the identity of the requester, it can't properly enforce authorization policies. Imagine a scenario where a rogue script exploits this lack of awareness to access sensitive data in a healthcare application.
  • Privilege Escalation: A compromised service might be able to perform actions beyond its intended scope. Consider a financial application where a compromised reporting service gains the ability to initiate fund transfers due to missing identity context.
  • Data Corruption: Without knowing who is making changes, it's difficult to audit and prevent malicious modifications. In a retail setting, this could mean unauthorized changes to product pricing or inventory levels.

The consequences of these vulnerabilities can be severe. For instance, consider a supply chain management system where different microservices handle inventory, shipping, and billing. If identity isn't properly propagated, a vulnerability in the shipping service could be exploited to manipulate inventory data, leading to significant financial losses and operational disruptions.

sequenceDiagram participant User participant API Gateway participant Inventory Service participant Shipping Service participant Billing Service
User->>API Gateway: Place Order
API Gateway->>Inventory Service: Request (no identity)
Inventory Service->>Shipping Service: Request (no identity)
Shipping Service->>Billing Service: Request (no identity)
Billing Service-->>Shipping Service: Response
Shipping Service-->>Inventory Service: Response
Inventory Service-->>API Gateway: Response
API Gateway-->>User: Order Confirmation

In this scenario, a lack of identity propagation between the Inventory, Shipping, and Billing services makes the system vulnerable to unauthorized modifications.

Furthermore, improper identity propagation can lead to compliance violations. Regulations like GDPR require organizations to track and control access to personal data. Without proper identity propagation, it becomes nearly impossible to demonstrate compliance and avoid hefty fines.

To address these risks, organizations must implement robust identity propagation strategies. As Authentication in microservices can have three meanings for end-users, microservices connecting to other microservices, and external services connecting to your microservices via API, it's crucial to choose the right approach.

In the upcoming sections, we'll explore common identity propagation strategies for non-human identities and delve into best practices for securing your microservices.

Common Identity Propagation Strategies for NHIs

Securing non-human identities (NHIs) in microservices can feel like navigating a maze, but with the right strategies, you can ensure your system remains secure and compliant. Let's explore some common identity propagation strategies tailored for NHIs.

  • JSON Web Tokens (JWT): JWTs are a popular and effective way to propagate identity. As mentioned earlier, JWTs provide a secure mechanism for sharing claims between a client and a microservices application. For example, in a financial application, a JWT can carry the ID of the calling microservice, the client ID, or the system that initiated the request.

  • Bearer Tokens: These tokens act like digital cash. If a microservice possesses a valid bearer token, it's trusted without further verification at each step, streamlining internal communications. However, it's crucial to implement robust security measures to prevent token theft or misuse.

  • Access Tokens: Using access tokens received at the edge and transferring them to individual microservices allows for granular control over microservice authentication, according to Authentication article.

  • mTLS provides strong authentication by requiring both the client and server to verify each other's identities using digital certificates. This approach is particularly useful for securing service-to-service communication within a microservices architecture. Imagine a healthcare system where the "Patient Records Service" needs to communicate with the "Billing Service." mTLS ensures that both services are who they claim to be, preventing unauthorized access to sensitive patient data.

sequenceDiagram participant Client participant Server
Client->>Server: ClientHello
Server->>Client: ServerHello, Certificate, CertificateRequest
Client->>Server: Certificate, CertificateVerify, ChangeCipherSpec, EncryptedHandshakeMessage
Server->>Client: ChangeCipherSpec, EncryptedHandshakeMessage
Client->>Server: Application Data
Server->>Client: Application Data
  • This strategy involves propagating identity information as part of the request context. This can be achieved through custom headers or metadata within the request. For instance, in a retail application, the "Order Service" can include the user's ID and role in the request headers when communicating with the "Inventory Service." This allows the "Inventory Service" to enforce authorization policies based on the user's identity.

These strategies aren't mutually exclusive; often, a combination provides the most robust security posture.

Next, we'll delve into best practices for implementing secure identity propagation, ensuring your microservices are protected against unauthorized access and data breaches.

Implementing Secure Identity Propagation: Best Practices

Did you know that misconfigured security settings are a leading cause of data breaches? That's why implementing secure identity propagation requires careful planning and execution.

Apply the principle of least privilege to non-human identities. Grant each microservice only the permissions it needs to perform its specific tasks. For example, in a banking application, the "Transaction Service" should only have access to the necessary account details and transaction APIs, not the entire customer database.

Implement robust token management practices. This includes using short-lived tokens, rotating keys regularly, and storing tokens securely. According to Authentication article, you can take an Access Token received at the edge and transfer it to individual microservices.

Always validate and sanitize inputs at each microservice to prevent injection attacks. This is crucial because even with proper identity propagation, a compromised service can still be exploited through malicious inputs. For instance, in a healthcare application, the "Appointment Service" should validate all input parameters to prevent attackers from scheduling unauthorized appointments or accessing sensitive patient data.

Establish comprehensive auditing and logging mechanisms to track all identity-related events. This includes authentication attempts, authorization decisions, and access to sensitive resources. For instance, in a retail application, logging every transaction and access attempt can help identify and prevent fraudulent activities, such as unauthorized discounts or refunds.

Employ mutual TLS (mTLS) for service-to-service communication. mTLS ensures that both the client and the server are authenticated before any data is exchanged, adding an extra layer of security. This is particularly important in highly sensitive environments, such as government or defense systems, where service impersonation can have severe consequences.

sequenceDiagram participant Client participant Server
Client->>Server: ClientHello
Server->>Client: ServerHello, Certificate, CertificateRequest
Client->>Server: Certificate, CertificateVerify, ChangeCipherSpec, EncryptedHandshakeMessage
Server->>Client: ChangeCipherSpec, EncryptedHandshakeMessage
Client->>Server: Application Data
Server->>Client: Application Data

By following these best practices, you can significantly enhance the security of your microservices and protect against unauthorized access and data breaches.

Now that we've covered best practices, let's explore how to choose the right identity propagation strategy for your microservices.

Choosing the Right Strategy for Your Microservices

Choosing the right identity propagation strategy is like selecting the perfect tool for a job – the fit determines the outcome. But how do you ensure you're making the best choice for your microservices?

Here are key factors to consider:

  • Security Requirements: Evaluate the sensitivity of the data handled by each microservice. For highly sensitive data, like financial transactions, mTLS or JWTs with strong encryption are preferable. For less sensitive data, bearer tokens might suffice.

    As Authentication article mentions, if an attacker gets past the gateway, they can freely access any microservice. Thus, consider the defense-in-depth principle.

  • Performance Considerations: Some strategies introduce more overhead than others. JWT validation, for instance, can add latency. If performance is critical, consider strategies that minimize overhead, such as propagating identity in request headers.

  • Complexity and Maintainability: Simpler strategies like request headers are easier to implement and maintain but might offer less security than mTLS or JWTs. The trade-off between complexity and security should align with your team's expertise and resources.

  • Existing Infrastructure: Leverage existing identity and access management (IAM) systems. If you already use OAuth 2.0 for user authentication, extending it for NHIs might be a logical choice.

  • Compliance Requirements: Certain industries have strict compliance requirements. For example, healthcare applications must comply with HIPAA, which mandates strong security measures for protecting patient data.

graph TD A[Start] --> B{Security Needs?}; B -- High --> C[mTLS or JWT]; B -- Low --> D[Bearer Tokens or Headers]; C --> E{Performance Impact?}; D --> E; E -- High --> F[Headers]; E -- Low --> G[mTLS or JWT]; F --> H[Implement]; G --> H[Implement]; H --> I[Test and Monitor];

Selecting the right strategy is an iterative process. Start with a pilot implementation, monitor its performance and security, and adjust as needed. Don't be afraid to combine strategies to achieve the right balance of security, performance, and maintainability.

Now that we've explored how to choose the right strategy, let's delve into the tools and technologies available for identity propagation.

Tools and Technologies for Identity Propagation

Selecting the right tools can make or break your identity propagation strategy. Let's explore some of the technologies that can help you secure your microservices.

IAM systems play a crucial role in managing and authenticating identities across your microservices architecture. These systems provide a centralized way to manage user access and permissions, ensuring that only authorized entities can access sensitive resources. Many organizations leverage existing IAM systems like Keycloak to extend their identity management capabilities to non-human identities, as noted by Yogendra Mishra.

API gateways act as a single entry point for all requests to your microservices. They can handle authentication and authorization at the edge, ensuring that only authenticated requests are routed to the appropriate microservices. This approach simplifies identity propagation by centralizing the authentication process and reducing the complexity of individual microservices. According to a post on dev.to, using an API gateway for global authentication and authorization per service is an effective strategy.

Service meshes provide a dedicated infrastructure layer for handling service-to-service communication. They can enforce security policies, including authentication and authorization, at the network level. Service meshes like Istio and Linkerd support mutual TLS (mTLS) and can automatically inject identity information into requests, simplifying identity propagation and enhancing security.

graph LR A[Client] --> B(API Gateway) B --> C{Authentication?} C -- Yes --> D(Service Mesh) D --> E{Authorization?} E -- Yes --> F[Microservice] E -- No --> G[Reject] C -- No --> H[Reject]

JSON Web Tokens (JWTs) are a popular way to propagate identity information between microservices. JWT libraries simplify the process of creating, signing, and verifying JWTs. These libraries are available in various programming languages, making it easy to integrate JWT-based authentication into your microservices.

Choosing the right tools and technologies is essential for implementing a robust and secure identity propagation strategy. With the right tools in place, you can ensure that your microservices are protected against unauthorized access and data breaches.

Next, we'll conclude by summarizing the key concepts and best practices for securing your microservices with robust identity propagation.

Conclusion: Securing Your Microservices with Robust Identity Propagation

Securing your microservices with robust identity propagation is not just good practice; it's essential for maintaining trust and compliance. Let's recap the key steps to ensure your microservices are secure.

  • Understand the risks: As we've covered, improper identity propagation can lead to unauthorized access, privilege escalation, and data corruption.
  • Choose the right strategy: Select a strategy that aligns with your security requirements, performance needs, and existing infrastructure. For instance, if you need granular control over microservice authentication, consider using access tokens, as mentioned earlier.
  • Implement best practices: Enforce the principle of least privilege, implement robust token management, and establish comprehensive auditing mechanisms.

Employ the right tools, such as API gateways and service meshes, to streamline identity propagation. As Authentication article notes, API gateways can centralize authentication, reducing the complexity of individual microservices.

sequenceDiagram participant Client participant API Gateway participant Microservice
Client->>API Gateway: Request
API Gateway->>Microservice: Request with Identity
Microservice-->>API Gateway: Response
API Gateway-->>Client: Response

By focusing on these key areas, you can create a secure and resilient microservices architecture that protects your data and maintains the trust of your users.

Lalit Choda
Lalit Choda
 

NHI Evangelist : with 25+ years of experience, Lalit Choda is a pioneering figure in Non-Human Identity (NHI) Risk Management and the Founder & CEO of NHI Mgmt Group. His expertise in identity security, risk mitigation, and strategic consulting has helped global financial institutions to build resilient and scalable systems.

Related Articles

Kubernetes Workload Identity

Kubernetes Workload Identity Simplified

Learn about Kubernetes Workload Identity, its benefits, types, and real-life applications. Get insights into managing machine identities effectively.

By Lalit Choda June 12, 2025 3 min read
Read full article
OAuth 2.0

Secure Your Machines with OAuth 2.0 and OpenID Connect

Discover how OAuth 2.0 and OpenID Connect enable secure machine identities. Learn the steps, comparisons, and real-life applications for smooth integration.

By Lalit Choda June 6, 2025 3 min read
Read full article
HSM

The Essentials of Hardware Security Modules and TPM

Learn about Hardware Security Modules (HSM) and Trusted Platform Module (TPM). Discover their roles in security, types, and real-world applications in machine identity.

By Lalit Choda May 31, 2025 3 min read
Read full article
Zero Trust

Mastering the Zero Trust Security Model

Dive into the Zero Trust Security Model, a crucial framework that challenges traditional security methods. Learn the steps, types, and real-world examples.

By Lalit Choda May 19, 2025 2 min read
Read full article