Adventures in Authentication and Authorization

Ian Haken (Security Software Engineer · Netflix)

USENIX Enigma Conference 2023 · Day 1 · Grand Ballroom

Overview

In his USENIX Enigma talk, "Adventures in Authentication and Authorization," Netflix Security Software Engineer Ian Haken takes the audience on a journey through the complex and often counter-intuitive challenges of securing a vast, dynamic microservice ecosystem. Haken recounts Netflix's iterative process of designing and refining its internal authentication and authorization mechanisms, starting from a fundamental flaw discovered during a red team exercise and progressing through multiple architectural iterations, each addressing a newly uncovered vulnerability or scalability bottleneck. The talk highlights that security is not a one-time fix but an ongoing evolution, particularly in environments characterized by thousands of microservices and deep call graphs.

Watch on YouTube · Slides

Visual summary for Adventures in Authentication and Authorization by Ian Haken
Visual summary for Adventures in Authentication and Authorization by Ian Haken

Key moments

  1. 1:00 Initial 'X-User' header forgery attack
  2. 5:30 Bearer credentials and travel service compromise
  3. 9:00 Why fine-grained credential scopes are intractable
  4. 10:30 S2S access control: non-forwardable auth, local checks
  5. 14:30 Final solution: Non-forwardable end user context tickets
  6. 17:00 Abstracting complex auth for developers
  7. 18:30 Summary: Key takeaways on auth and auth design
  8. 20:30 Q&A: Handling external services and different trust levels

Adventures in Authentication and Authorization

Speakers: Ian Haken (Security Software Engineer, Netflix)

Conference: USENIX Enigma

YouTube: https://www.youtube.com/watch?v=gfE9nzbiMww

Overview

In his USENIX Enigma talk, "Adventures in Authentication and Authorization," Netflix Security Software Engineer Ian Haken takes the audience on a journey through the complex and often counter-intuitive challenges of securing a vast, dynamic microservice ecosystem. Haken recounts Netflix's iterative process of designing and refining its internal authentication and authorization mechanisms, starting from a fundamental flaw discovered during a red team exercise and progressing through multiple architectural iterations, each addressing a newly uncovered vulnerability or scalability bottleneck. The talk highlights that security is not a one-time fix but an ongoing evolution, particularly in environments characterized by thousands of microservices and deep call graphs.

The core problem Haken addresses is how to securely propagate user identity and enforce granular access control across numerous interdependent services without introducing unacceptable performance overhead or creating new attack vectors. He meticulously details the pitfalls of common approaches, such as relying on forwardable bearer tokens or overly granular credential scopes, demonstrating how these solutions can lead to widespread compromise from a single point of failure. Ultimately, Haken presents a refined architecture that combines service-to-service access control with a novel approach to managing end-user context, all while emphasizing the critical role of developer abstraction in making such a complex system usable and secure. This talk is essential for anyone grappling with identity and access management in large-scale distributed systems, offering practical lessons derived from real-world challenges at an industry leader.

Background

▶ Watch: Initial 'X-User' header forgery attack (1:00)

The talk begins by illustrating a fundamental security flaw discovered during a red team exercise at Netflix. As a simulated malicious insider, Ian Haken targeted an internal key service responsible for distributing credentials to developers. This key service, residing within Netflix's Virtual Private Cloud (VPC), was not directly accessible from a developer's workstation. Instead, requests were proxied through an internet gateway service, which developers accessed via their Single Sign-On (SSO) credentials. The critical vulnerability lay in how user identity was propagated from the internet gateway to the key service: a simple X-User header. The internet gateway would insert a header specifying the authenticated user's identity, which the key service would then use to consult an authorization service for access decisions.

This header-based identity propagation is problematic because any service capable of communicating directly with the key service could inject an arbitrary X-User header, effectively impersonating any user, including an administrator. Haken demonstrated this by leveraging a Python notebook system – a convenience service allowing arbitrary code execution – to talk directly to the key service, inject an "admin" header, and obtain administrative credentials. This initial exploit underscored the danger of implicitly trusting internal network segments and the identity assertions made by upstream services.

Haken then clarifies the foundational concepts:

  • Authentication (AuthN): The process of establishing a user's identity, typically involving credentials.
  • Authorization (AuthZ): Determining if an authenticated user or service is permitted to perform a specific action on a resource. This usually results in a binary "yes" or "no" decision, potentially influenced by dynamic factors like roles, MFA status, or IP addresses.

A significant industry trend, as Haken notes, is the centralization of reusable, optimized authorization systems. These systems often feature rich, expressible policy languages and integrate extensive user and role attributes, allowing for sophisticated access control decisions. The challenge, however, is integrating such a centralized authorization service effectively and securely into a sprawling microservice architecture without introducing new vulnerabilities or insurmountable operational complexities. The Netflix ecosystem, with its thousands of microservices and deep call graphs (averaging 7-10 hops per API call), presented a particularly demanding environment for addressing these core security tenets.

Key Findings

▶ Watch: Why fine-grained credential scopes are intractable (9:00)

Netflix's journey through authentication and authorization security was characterized by an iterative process, where each proposed solution addressed a previous vulnerability but often exposed a new set of challenges or threat models.

  1. Initial Problem: X-User Header Injection
  • Finding: Relying on an X-User header for identity propagation in a multi-hop environment is fundamentally insecure. Any compromised internal service can forge identity, leading to privilege escalation.
  • Implication: Trusting identity assertions from internal services without cryptographic verification is a critical flaw.
  1. Solution Attempt 1: Forwardable Bearer Credentials
  • Mechanism: Replace X-User headers with verifiable bearer credentials (e.g., OIDC access tokens, JWE/JWS, Macaroons, Biscuits) passed through each hop. The key service validates the token and extracts the user identity.
  • Finding: This resolved the initial header injection problem, as compromised services could no longer forge arbitrary identities; they would need a valid, verifiable token.
  • New Problem: A vulnerability in an unrelated service (e.g., a travel service with unauthenticated RCE from an old open-source library) could allow an attacker to harvest legitimate user credentials as they flowed through the service. If an admin user's token was harvested, it could be replayed against the key service to gain admin access.
  • Implication: Any single point of compromise in the entire ecosystem could lead to widespread credential harvesting and replay, enabling lateral movement and privilege escalation.
  1. Solution Attempt 2 (Considered): Finely Grained Credential Scopes
  • Mechanism: Embed specific scopes or audiences into bearer credentials, limiting their use to specific services (e.g., a token for the key service, a different token for the travel service). This would prevent a token meant for the travel service from being replayed against the key service.
  • Finding: This approach was deemed intractable for Netflix's dynamic and large microservice ecosystem. With thousands of services and deep, evolving call graphs (averaging 7-10 hops per API call), precisely enumerating all necessary scopes for a given request chain was nearly impossible. Changes in service dependencies would require cascading configuration updates affecting dozens to hundreds of engineers.
  • Implication: Static, finely-grained scoping is not practical in highly agile, large-scale microservice environments where dependencies frequently change.
  1. Solution Attempt 3: Service-to-Service (S2S) Access Control
  • Mechanism: Implement zero-trust principles where each service authenticates to the next service in the call chain. The key service would check if the travel service (the caller) is authorized to talk to it, even if the user credential is valid.
  • Finding 1 (Authentication Technology): S2S authentication must use non-forwardable credentials. If the same forwardable bearer tokens used for users were used for S2S, a compromised service could simply harvest and replay the service's credential. Netflix adopted mTLS certificates for S2S authentication, along with finely-scoped bearer tokens, ensuring credentials cannot be verbatim replayed.
  • Finding 2 (Performance): Adding an authorization check at every hop in a deep call graph (e.g., 10 checks) would introduce unacceptable latency (e.g., 20ms per API call, hundreds of milliseconds for a complex page load). This necessitated a design where S2S authorization could be performed locally (e.g., by pushing down Access Control Lists - ACLs) to achieve zero round-trip authorization.
  • New Problem: Even with S2S access control, the actual user's forwardable bearer credential was still flowing through internal services. A compromised service could harvest this user credential and replay it directly against the internet gateway (front door), bypassing internal S2S checks and accessing the key service as the legitimate user.
  • Implication: S2S controls protect against internal service impersonation but not against replay of end-user credentials against the external entry point.
  1. Solution Attempt 4: End User Context Tickets
  • Mechanism: The internet gateway verifies the incoming end-user credential, then exchanges it for a new, internal-only end user context ticket (a concept inspired by Google's BeyondProd white paper). This ticket contains the same user identity information but is a different form of bearer credential, designed not to be accepted by the internet gateway. This ticket is then forwarded internally.
  • Finding: This final architectural iteration effectively blocked all identified attack vectors. If a service is compromised and harvests an end user context ticket, it cannot replay it against the internet gateway (which only accepts original user credentials) and cannot directly call the key service (due to S2S access controls).
  • New Problem (Human/Operational): This robust architecture involved multiple distinct authentication technologies (external bearer tokens, mTLS, internal context tickets) and multiple authorization tools (centralized policy engine, local ACLs). This complexity became a significant burden for developers.
  • Implication: Technical security solutions, no matter how effective, must be accompanied by developer-friendly abstractions to ensure adoption and correct implementation.
  1. Final Solution: Platform Abstraction Layer
  • Mechanism: Netflix introduced an authorizable context – an opaque object encapsulating all relevant authentication data – and an authorization client. Developers simply pass the authorizable context to the authorization client, which handles the underlying complexity of determining identity and making authorization decisions using the appropriate technology (local ACLs, remote policy services, etc.).
  • Finding: This abstraction layer shielded developers from the intricate details of the multi-faceted security architecture, allowing them to focus on business logic while ensuring security best practices were followed implicitly. It also provided agility for the platform team to evolve underlying security technologies without breaking developer-facing APIs.
  • Implication: In complex security landscapes, abstraction is crucial for developer productivity, correct implementation, and future adaptability.

Technical Deep Dive

▶ Watch: Final solution: Non-forwardable end user context tickets (14:30)

The evolution of Netflix's authentication and authorization architecture is a masterclass in securing a large-scale, dynamic microservice environment, moving from naive trust to a sophisticated zero-trust model.

The initial approach, relying on an X-User HTTP header for identity propagation, was a critical vulnerability. This header, inserted by the internet gateway service after successful SSO, informed downstream services like the key service about the authenticated user. The fundamental flaw was that any other internal service, such as the Python notebook system, could also directly communicate with the key service and inject an arbitrary X-User header. This allowed the red team to impersonate an administrator by simply sending X-User: admin and requesting administrative credentials. This highlights the danger of assuming trust within a network boundary; internal services are just as susceptible to compromise and misuse as external ones.

The first major architectural shift involved adopting forwardable bearer credentials. Instead of a plaintext header, users received cryptographically verifiable tokens—such as OIDC access tokens, JWE/JWS (JSON Web Encryption/Signature), Macaroons, or Biscuits—after SSO. These tokens, containing the user's identity, were then passed along each hop in the request chain. The key service could validate the token's signature, extract the user's identity, and then consult the centralized authorization service. This directly addressed the header injection problem: a compromised service could no longer forge an identity without a valid, signed token. However, it introduced a new vulnerability: if a service like the travel service (which was found to have an unauthenticated RCE due to an old open-source library) was compromised, it could harvest these valid bearer tokens as users interacted with it. An attacker could then replay an administrator's harvested token against the key service to gain administrative access. The problem shifted from identity forgery to credential replay.

The idea of credential scopes was considered to mitigate the replay problem. This approach involves embedding audience or scope claims within the bearer token, explicitly limiting its validity to specific services (e.g., a token for travel-service could not be used for key-service). While conceptually sound, this proved impractical for Netflix's scale. With thousands of microservices and an average of 7-10 service hops for a single API call, defining the exact set of scopes required for every possible call chain was an immense, ever-changing configuration challenge. A new dependency added to a service would necessitate cascading scope updates throughout the entire call graph, affecting potentially hundreds of engineers. This dynamic nature made static, finely-grained scoping unmanageable.

This led to the adoption of Service-to-Service (S2S) Access Control, embodying a true zero-trust philosophy. The principle is that every service must authenticate and authorize itself to the next service in the chain, regardless of whether it's an internal call. This required two critical considerations:

  1. Non-Forwardable S2S Authentication: The S2S credentials themselves could not be easily replayed. If the same forwardable bearer tokens were used for S2S, a compromised service could harvest the internet gateway's S2S token and impersonate it. Netflix opted for mTLS certificates (mutual Transport Layer Security) for S2S authentication, providing strong, non-forwardable cryptographic identity. Finely-scoped bearer tokens (distinct from user tokens) could also serve this purpose, but mTLS offers stronger guarantees against replay.
  2. Local Authorization Evaluation: Implementing authorization checks at every hop (e.g., 10 checks per API call) against a centralized authorization service introduced unacceptable latency (e.g., 1-2 milliseconds per check, totaling 20ms per API call, and hundreds of milliseconds for complex page loads). To overcome this, Netflix implemented a system where authorization decisions for S2S calls could be made locally at the receiving service, often by pushing down Access Control Lists (ACLs) or policy bundles. This eliminated the round-trip latency to a centralized service for every S2S check.

Despite S2S controls, a critical flaw remained: the actual end-user's forwardable bearer credential was still flowing through internal services. A compromised internal service could harvest this user token and replay it directly against the internet gateway (the front door). Since the internet gateway still accepted legitimate user tokens, this bypasses the internal S2S controls and allows the attacker to impersonate the user from the outside.

The solution to this was the introduction of End User Context Tickets. When a user authenticates at the internet gateway, their original, external bearer credential is verified. Instead of forwarding this original credential, the gateway issues a new, internal-only end user context ticket. This ticket contains the user's identity but is specifically designed not to be accepted by the internet gateway. It's a different "flavor" of bearer credential, meant only for internal propagation. Now, if an internal service is compromised, it can only harvest these internal context tickets. An attacker cannot replay these tickets against the internet gateway, and they cannot directly call the key service due to the enforced S2S mTLS and local authorization checks. This architecture effectively segmented user identity from its external presentation, preventing both internal forgery and external replay of harvested internal credentials.

However, this sophisticated architecture—combining external bearer tokens, mTLS for S2S, local S2S authorization, centralized authorization for user-facing policies, and end user context tickets—created significant complexity for developers. To manage this, Netflix introduced a platform abstraction layer. This layer provides an authorizable context (an opaque object representing the user and service identity for the current request) and an authorization client. Developers simply pass the authorizable context to the authorization client, which, under the hood, determines the appropriate authorization mechanism (local ACLs, remote policy service optimized for specific use cases, etc.) and returns a simple "yes/no" decision. This abstraction allows developers to build secure applications without needing deep expertise in the underlying multi-faceted security mechanisms, ensuring consistency and correctness across the ecosystem. It also provides the platform team the agility to evolve the underlying authentication and authorization technologies without impacting developer code.

Demo / Proof of Concept

▶ Watch: Abstracting complex auth for developers (17:00)

The talk itself serves as a detailed narrative of Netflix's real-world "adventures" in authentication and authorization, starting with a concrete proof of concept (PoC) of the initial vulnerability. Ian Haken describes how, acting as a malicious insider during a red team exercise, he exploited a critical flaw in their early identity propagation mechanism.

The target was the internal key service, which was protected by firewalls within their VPC. User interaction with this service was exclusively through the internet gateway, which would proxy requests. The PoC involved exploiting the fact that the internet gateway simply inserted an X-User header to convey the user's identity to the key service.

Haken utilized an existing Python notebook system within the environment. This system was designed for data analysis and queries but crucially allowed users to run arbitrary code. By gaining control over this convenience service, Haken was able to craft a request that directly targeted the key service, bypassing the internet gateway's initial authentication. In this direct request, he explicitly set the X-User header to "admin." The key service, trusting this header, then proceeded to grant administrative credentials to Haken's forged request.

This initial demonstration highlighted the immediate and severe consequences of implicitly trusting identity assertions within the internal network. It provided the foundational problem that spurred Netflix's subsequent, multi-year journey to build a more robust and resilient authentication and authorization architecture, as each iterative solution was designed to prevent a similar, or more sophisticated, attack from succeeding.

Defensive Implications

▶ Watch: Q&A: Handling external services and different trust levels (20:30)

The Netflix journey provides crucial lessons for organizations, particularly those operating large, dynamic microservice architectures:

  1. Never Implicitly Trust Internal Identity Assertions: The initial X-User header vulnerability is a stark reminder that internal network boundaries do not equate to trust boundaries. Any identity information passed between services must be cryptographically verifiable and tied to a validated source. Assume any internal service can be compromised and should not be implicitly trusted to assert identity.
  2. Separate End-User and Service Identities: Distinguish clearly between the credentials used by end-users to access the system and the credentials used by services to communicate with each other. End-user credentials need to be forwardable for authorization decisions, but the actual user credential should not be propagated internally.
  3. Implement Non-Forwardable Service-to-Service (S2S) Authentication: For inter-service communication, use authentication mechanisms that prevent credential replay. mTLS certificates are highly recommended as they bind identity to the transport layer and are inherently non-forwardable. Alternatively, finely-scoped bearer tokens designed for S2S use can be employed, but they must be distinct from user tokens and managed carefully. This is a cornerstone of a zero-trust architecture.
  4. Prioritize Local Authorization for Performance: In deep call graphs, relying on a centralized authorization service for every S2S hop introduces unacceptable latency. Design authorization systems to allow for local evaluation of access policies (e.g., by pushing down ACLs or policy bundles) to achieve near-zero round-trip authorization for common S2S checks. Centralized authorization can still be used for more complex, user-facing policy decisions.
  5. Use End-User Context Tickets for Internal Identity Propagation: After initial user authentication, exchange the external user credential for an internal-only "context ticket." This ticket contains the user's identity but is not accepted by the external entry points (like the internet gateway). This prevents replay attacks against the front door if internal services are compromised and user context tickets are harvested.
  6. Embrace Abstraction for Developer Experience: A robust security architecture involving multiple authentication technologies (e.g., external bearer tokens, mTLS, internal context tickets) and various authorization tools (e.g., centralized policy engines, local ACLs) can overwhelm developers. Provide a platform abstraction layer (e.g., an "authorizable context" and "authorization client") that simplifies the security API, making it easy for developers to correctly implement secure applications without deep security expertise. This also allows the security team to evolve underlying technologies without breaking developer-facing APIs.
  7. Anticipate Multiple AuthN/AuthZ Technologies: Recognize that no single authentication or authorization technology will fit all use cases in a complex ecosystem. Plan for a heterogeneous environment and design your architecture to accommodate different tools and techniques, leveraging abstraction to manage this complexity.
  8. Security is an Iterative Process: The talk underscores that security is not a static state but a continuous cycle of identifying vulnerabilities, implementing solutions, and then discovering new attack vectors or operational challenges. Organizations must be prepared for this ongoing evolution.

Key Takeaways

  • Propagate Verifiable End-User Identity: To enable fine-grained authorization throughout a microservice ecosystem, end-user identity must be propagated. This requires verifiable and forwardable identity, but the actual user credentials should not be passed internally.
  • Utilize End-User Context Tickets: After initial authentication, exchange external user credentials for internal-only "end-user context tickets." These tickets carry user identity internally but are not accepted by external entry points, preventing replay attacks against the front door from compromised internal services.
  • Implement Non-Forwardable Service-to-Service (S2S) Controls: S2S authentication and authorization are crucial for limiting the blast radius of a single point of compromise (zero-trust). This requires non-forwardable S2S credentials, such as mTLS certificates, and local authorization evaluation for performance.
  • Embrace Abstraction for Developer Productivity: Given the complexity of modern authentication and authorization, providing a platform abstraction layer (e.g., an authorizable context and authorization client) is essential. This shields developers from intricate details, ensures correct implementation, and allows for agile evolution of underlying security technologies.
  • No Single Solution Fits All: Acknowledge that a complex ecosystem will require multiple authentication and authorization technologies. Design your architecture to accommodate this diversity, using abstraction to provide a coherent developer experience.

About the Speaker(s)

Ian Haken is a Security Software Engineer at Netflix. With approximately six and a half years of experience at the company, he has primarily focused on the platform and infrastructure security team. His work involves tackling complex challenges in securing Netflix's vast and dynamic microservice environment, including designing and implementing robust authentication and authorization systems. Haken's talk reflects his deep practical experience in identifying, mitigating, and evolving security architectures in a large-scale production setting.

Reviews

Dr. Zero (Offensive Security Researcher) — MUST SEE

Haken actually tells the truth about how Netflix fucked up their internal identity model and the painful, multi-year process of fixing it. It's a masterclass in why theoretical security models collapse under the weight of a thousand microservices. If you are building distributed systems, skip the vendor pitches and watch this instead.

Heather Calloway (CISO) — MUST SEE

This is a masterclass in how to actually build zero-trust architecture at scale without crippling developer velocity. Netflix outlines the brutal reality of multi-hop identity propagation and the exact architectural iterations they used to fix it. Required viewing for your head of platform engineering and your IAM architects.

→ Top-rated talks at USENIX Enigma Conference 2023

All talks from USENIX Enigma Conference 2023