JWT Authentication Token Segmentation for Cookie Size Limits

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing stateless authentication methods using JSON Web Tokens (JWTs) face limitations when the payload exceeds cookie size limits, leading to incomplete authentication information being stored in cookies, making them vulnerable to attacks and unable to securely authenticate clients across multiple server instances.

Innovation Solution

Generating a JWT with a header and signature in an HTTP-only secure cookie and an encrypted payload, allowing the client to reconstruct the JWT for authentication, thereby preventing XSS and CSRF attacks and enabling secure communication with multiple server instances.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of information

If the JWT payload includes complete authentication information (users, roles, groups), then the authentication information is comprehensive, but the JWT size exceeds the cookie size limit

Engineering Contradiction:
Improveauthentication information completenessVSAvoidJWT size
Core Design Contradiction:
Loss of informationVSLength of stationary object

Solution Approach 1:

The JWT is segmented into three separate components: (1) a header containing token type and algorithm information, (2) a payload containing authentication data (users, roles, groups), and (3) a signature for verification. These components are distributed across different storage locations - header and signature in HTTP-only cookie, payload in encrypted form in response body - allowing complete authentication information to be preserved while avoiding single-cookie size limits

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The solution moves from a single-dimension approach (storing complete JWT in one cookie) to a multi-dimensional approach by distributing JWT components across multiple dimensions: cookie storage for header and signature, response body for encrypted payload, and client-side assembly. This dimensional transformation allows the system to bypass cookie size constraints while maintaining information completeness

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Reliability

If the JWT is stored in a cookie, then the authentication state can be maintained, but the cookie size limit prevents storing complete JWT payloads

Engineering Contradiction:
Improveauthentication state maintenanceVSAvoidcookie capacity
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The authentication state is maintained by segmenting the JWT storage: the critical header and signature components are placed in the HTTP-only cookie for secure state maintenance, while the variable-sized payload is stored separately in encrypted form in the response body, allowing the cookie to remain within size limits while preserving authentication reliability

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

An encrypted payload intermediary is introduced between the server and client. The payload is encrypted using a key derived from the JWT header, allowing it to be safely transmitted in the response body while the cookie contains only the compact header and signature needed for state maintenance and verification

Inventive Principle:
Principle #24Intermediary (Mediator)

3Object-affected harmful factors

If the JWT payload is encrypted and sent in the response body, then the authentication information security is improved, but the client must reconstruct the JWT which adds processing complexity

Engineering Contradiction:
Improveauthentication information exposureVSAvoidJWT reconstruction process
Core Design Contradiction:
Object-affected harmful factorsVSDevice complexity

Solution Approach 1:

An encrypted payload intermediary is introduced that simplifies the overall process. The payload is encrypted using a key derived from the JWT header (which is in the cookie), creating a self-contained encrypted blob that the client can decrypt and assemble with the header and signature from the cookie, reducing server processing complexity while maintaining security

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The client is empowered to perform the JWT reconstruction and verification process itself using the components provided in the cookie and response body. The server only needs to generate and distribute the components, while the client handles the decryption, assembly, and verification, reducing server-side processing complexity

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS12101307B2Systems and methods for stateless authentication and authorization using JWT access tokens
Publication Date: 2024.09.24 OPEN TEXT CORP
  • US12101307B2 patent drawing
  • US12101307B2 patent drawing
  • US12101307B2 patent drawing

AI summary

Systems and methods for secure stateless client-server communication. User credentials in a client authorization request are authenticated and used to generate a JSON web token (JWT). The JWT header and signature are encrypted and included in an HTTP-only cookie. The JWT payload is encrypted and sent to the client in a response body along with the HTTP-only cookie. Each subsequent client request includes the cookie and has the encrypted JWT payload in the request header. Upon receiving the request, the server decrypts the encrypted JWT payload from the header and decrypts the encrypted JWT header and signature from the cookie, then reconstructs the JWT from the JWT header, payload and signature. The server validates the JWT and, if valid, processes the request according to authorizations in the JWT payload.