| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| @workos-inc/authkit-nextjs | npm | <= 2.11.0 | 2.11.1 |
The vulnerability, GHSA-p8pf-44ff-93gf, stems from authkit-nextjs failing to set anti-caching headers on HTTP responses for authenticated requests. This allows Content Delivery Networks (CDNs) or other proxy caches to store and inadvertently serve responses containing private session information to multiple users. The root cause was the absence of headers like Cache-Control: private, no-cache, no-store and Vary: Cookie.
The analysis of the patch commit 94cf438124993abb0e7c19dac64c3cb5724a15ea reveals that the fix involved adding cache prevention logic to all code paths that generate responses within an authenticated context. A new utility function, setCachePreventionHeaders, was introduced in src/utils.ts to centralize the setting of these crucial headers.
The investigation identified three key functions that were modified to incorporate this fix, and were therefore vulnerable prior to the patch:
handleAuth (src/authkit-callback-route.ts): This function, which manages the OAuth callback, was modified to add cache prevention headers to both redirect and error responses.updateSessionMiddleware (src/session.ts): As the primary session middleware, this function was updated to apply security headers to all responses for authenticated sessions before they are sent.updateSession (src/session.ts): This function for programmatically managing sessions was also patched to ensure any responses it generates include the anti-caching headers.By patching these functions, the library now ensures that any response related to an authenticated user is explicitly marked as private and non-cacheable, mitigating the risk of session leakage in CDN environments.
handleAuthsrc/authkit-callback-route.ts
updateSessionMiddlewaresrc/session.ts
updateSessionsrc/session.ts