Blog
  • AI Gateway
  • AI Security
  • AIOps
  • API Security
  • API Gateway
|
    • API Management
    • API Development
    • API Design
    • Automation
    • Service Mesh
    • Insomnia
    • View All Blogs
  1. Home
  2. Blog
  3. Engineering
  4. Tightening Bearer Token Authentication with Proof-of-Possession Tokens Using Kong
Engineering
November 15, 2023
5 min read

Tightening Bearer Token Authentication with Proof-of-Possession Tokens Using Kong

Veena Rajarathna
Staff Product Manager, Kong

Access tokens

In token-based architecture, tokens represent the client’s entitlement to access protected resources. Access tokens (or bearer tokens as they're commonly known) are issued by authorization servers after successful user authentication. The tokens are passed as credentials in the request to the target APIs which inform the API that the bearer of the token is authorized to access the API and perform certain actions.

Challenges with access/bearer tokens

In the flows where access tokens grant access to protected resources, the legitimacy of the token bearer is assumed. Access is granted based on the validity of the token. There is no validation that the bearer is in fact the legitimate owner of the token. This is one of the main vulnerabilities of a bearer token.

If the tokens fall into the hands of bad actors, they can be misused. With the stolen or leaked tokens, bad actors can easily impersonate the user and obtain unauthorized access to protected resources.

For any average API provider, this is a major concern. Recently, Sourcegraph experienced a security incident with leaked admin tokens. The malicious users used their privileges to increase API rate limits for a small number of users. For environments with heightened security needs, stolen or leaked tokens are a serious security risk.

A solution to secure access tokens

A solution to this problem is constraining the tokens issued by authorization server to clients (sender-constrained tokens) so only the entity/client to whom a token was issued can use the token to access resources. This approach is also known as holder of key or proof of possession tokens.

The client presenting the access token has to prove that they are authorized to use the token. To achieve this, the authorization servers bind the tokens to the client's cryptographic keys. Resource servers can then validate the clients are in possession of those keys and grant/deny access accordingly. 

Advantages of sender-constrained tokens

The primary security vulnerability of standard bearer tokens is remediated, as the legitimacy of the bearer is verified. Access to the protected resource is granted after successful validation of

  1. The client certificate used in the connection
  2. The thumbprint of the client certificate in the token matching the client certificate in the underlying connection
  3. Token validity

For environments with high security requirements such as financial services, e-health, and e-gov, this added layer of token security mitigates the risk of misuse of tokens as sender-constrained tokens simply cannot be replayed or redirected by an unauthorized party.

Moreover, usage of sender-constrained tokens is a must in open banking. One of the requirements of financial API (FAPI 2.0) is for the resource servers to support and verify sender-constrained access tokens using either of the methods.

Example of an access token with certificate thumbprint

Implementations of sender-constrained tokens

The RFC describes two methods to implement sender-constrained tokens

  1. Using Client Certificates (mTLS ) - Certificate-bound access tokens
  2. The Demonstration of Proof-of-Possession (DPoP) at application layer
Gateway Enterprise 3.5 offers Certificate-Bound Access Tokens via mTLS.

Certificate-bound access tokens

With mTLS, the access tokens are bound to the underlying mutual TLS connection between the client and the authorization server. Such tokens are known as certificate-bound access tokens. This approach uses the Public Key Infrastructure (PKI). The CA is trusted by the Authorization server and Kong.

Figure 1 shows a sample exchange between the client, IDP, and Kong. In a request to obtain a token, the client establishes a mutual TLS session with the authorization server’s token endpoint. After a successful TLS client authentication, the authorization server will mint an access token, encode the thumbprint of (hash) the client certificate either directly in the token (JWT) or in the Introspection Response (when using opaque tokens).

To access resources protected by Kong, the client establishes a TLS connection to Kong Gateway using the same client certificate and presents the access token. The same CA is trusted by Kong as well. Kong validates the client certificate and the certificate thumbprint in the tokens to the underlying mTLS connection. Access to the protected resource is granted after successful validation of all three.

  1. The client certificate used in the connection
  2. The thumbprint of the client certificate in the token matching the client certificate in the underlying connection
  3. Token validity

Kong’s support of certificate-bound access tokens: How it all comes together

To support certificate-bound tokens there are requirements on all parties involved in a typical token-based flow. Following are the prerequisites for each party involved in the flow

Prerequisites

  1. Authorization server that is capable of generating OAuth 2.0 Mutual TLS Certificate Bound Access Tokens
  2. A Certificate Authority(CA) that trusted by both the Authorization Server and Kong. The CA is used to issue client certificates
  3. A client application with an appropriate grant type (example client credentials grant) and ability to handle sender constrained tokens via mTLS
  4. Kong Gateway 3.5 with OIDC and mTLS plugins
  5. Upstream API service to which Kong proxies the request
  6. Client certificates issued to clients

Configuring Kong

Kong can be instructed to handle certificate-bound access tokens with the help of two plugins:

  1. OIDC plugin
  2. mTLS plugin such as TLS modifier or mtls-auth

TLS Modifier plugin does not enforce a mTLS connection. However, for certificate-bound access tokens to work, a client certificate must be presented along with the token

mtls-auth The CN check/validation cannot be disabled in the plugin and hence the plugin requires consumer mapping. Consumer objects should be created and client certificates need to be mapped.

Kong supports the usage of certificate-bound access tokens in three authentication flows. In these flows, the client entity obtains an access token from the authorization server's token endpoint and presents that as a bearer in the request to Kong. If the access token is opaque, Kong exchanges it for a JWT by calling the introspection endpoint.

  1. JWT bearer
  2. Introspection
  3. Session (Session Authentication is only compatible with certificate-bound access tokens when used along with one of the other supported authentication methods)

OIDC plugin configuration options

OIDC plugin offers two new settings to control the behavior of the plugin for certificate-bound tokens.

With all the prerequisites met and the plugins configured to support certificate-bound tokens, Kong Gateway will enforce the incoming requests to establish a mutual TLS connection using a valid client certificate and present an access token. Kong proxies the request after successful validation of the certificate thumbprint in the token to the client certificate in the underlying connection.

For step-by-step instructions on how to enable the feature refer to OpenID Connect | Kong Docs

Conclusion

With this feature, Kong complies with the requirements of financial API (FAPI 2.0) to support and verify sender-constrained access tokens. It's not limited to open banking or financial services. Mutual TLS Sender-Constrained Tokens are a suitable implementation for any environment with high security requirements such as e-gov and e-health. The solution forces the sender to prove they are the rightful owner of the token. This added layer of security mitigates the risk of misuse of tokens as they cannot be used without proof of possession.

API AuthenticationAPI SecurityGovernance

More on this topic

Videos

Moving Beyong the API Gateway to an API Platform

Videos

Secure and Govern APIs

See Kong in action

Accelerate deployments, reduce vulnerabilities, and gain real-time visibility. 

Get a Demo
Topics
API AuthenticationAPI SecurityGovernance
Share on Social
Veena Rajarathna
Staff Product Manager, Kong

Recommended posts

Federated Deployments with Control Plane Groups

Kong Logo
EngineeringSeptember 24, 2025

What are Control Plane Groups? Control Plane Groups in Kong Konnect provide a structured way to manage multiple control planes within a single organization. Think of it as a federated approach: different teams can deploy and manage their own APIs wh

Declan Keane

Kong Cloud Gateways: A Year in Review

Kong Logo
Product ReleasesDecember 17, 2025

A quick refresher: Kong Cloud Gateways Kong Cloud Gateways are fully managed, high-performance data planes running on customer-dedicated infrastructure, orchestrated and operated by Kong through Kong Konnect . Customers can choose between: Serverle

Josh Wigginton

How to Implement Secure Access Control with OPA and Kong Gateway

Kong Logo
EngineeringJanuary 8, 2025

Ensuring secure access to applications and APIs is critical. As organizations increasingly adopt microservices architectures and cloud native solutions, the need for robust, fine-grained access control mechanisms becomes paramount. This is where the

Raja Ravi Varman

Adopt a Zero Trust Approach with OAuth 2.0 Mutual TLS Client Authentication

Kong Logo
EngineeringFebruary 19, 2024

In the modern IT stack, API gateways act as the first line of defense against attacks on backend services by enforcing authentication/authorization policies and validating and transforming requests. When backend services are protected with a token-b

Samuele Illuminati

Understanding Microsegmentation in Zero Trust Security

Kong Logo
EngineeringFebruary 6, 2024

With digital transformation shifting networks into the cloud — from remote workforces to online banking — cyberattacks are growing more prevalent and sophisticated. Legacy security models like VPNs and perimeter-based firewalls are proving inadequat

Kong

Top GraphQL Security Vulnerabilities: Lessons Learned Analyzing 1,500+ Endpoints

Kong Logo
EngineeringJanuary 29, 2024

With its flexible querying capabilities,  GraphQL  makes it easy to combine data from multiple sources into a single endpoint.  GraphQL and API management  go hand in hand to build next-generation API platforms.  However, GraphQL's features can als

Kong

Layered Security Strategy for Managing APIs

Kong Logo
EngineeringDecember 21, 2023

This post is part of a series on becoming a secure API-first company. For a deeper dive, check out the eBook Leading Digital Transformation: Best Practices for Becoming a Secure API-First Company. As APIs have become mission-critical , securing th

Kong

Ready to see Kong in action?

Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.

Get a Demo
Powering the API world

Increase developer productivity, security, and performance at scale with the unified platform for API management, AI gateways, service mesh, and ingress controller.

Sign up for Kong newsletter

    • Platform
    • Kong Konnect
    • Kong Gateway
    • Kong AI Gateway
    • Kong Insomnia
    • Developer Portal
    • Gateway Manager
    • Cloud Gateway
    • Get a Demo
    • Explore More
    • Open Banking API Solutions
    • API Governance Solutions
    • Istio API Gateway Integration
    • Kubernetes API Management
    • API Gateway: Build vs Buy
    • Kong vs Postman
    • Kong vs MuleSoft
    • Kong vs Apigee
    • Documentation
    • Kong Konnect Docs
    • Kong Gateway Docs
    • Kong Mesh Docs
    • Kong AI Gateway
    • Kong Insomnia Docs
    • Kong Plugin Hub
    • Open Source
    • Kong Gateway
    • Kuma
    • Insomnia
    • Kong Community
    • Company
    • About Kong
    • Customers
    • Careers
    • Press
    • Events
    • Contact
    • Pricing
  • Terms
  • Privacy
  • Trust and Compliance
  • © Kong Inc. 2025