CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-2VG6-77G8-24MP

GHSA-2vg6-77g8-24mp: Insufficient Session Expiration via Incomplete Cleanup in Better Auth Ecosystem

Amit Schendel
Amit Schendel
Senior Security Researcher

Jul 7, 2026·5 min read·10 visits

Executive Summary (TL;DR)

Better Auth failed to evict cached sessions from secondary storage (e.g., Redis) when deleting users via admin, anonymous, or SCIM endpoints. Deleted users could continue accessing the system with active cookies for up to 7 days.

A critical session persistence vulnerability exists within the Better Auth framework when configured to use external secondary storage (such as Redis or Cloudflare KV) with default database options. Due to four incomplete user-deletion code paths, active user sessions are not evicted from secondary storage caches during deletion events. As a result, deleted users retain full system access via their pre-existing session cookies until the Session Time-To-Live (TTL) expires.

Vulnerability Overview

The Better Auth ecosystem utilizes an abstraction layer to manage user registration, authentication, and session handling. To optimize session verification latency, developers frequently deploy a double-tier storage strategy. In this architecture, relational databases host long-term user records, while memory-efficient 'secondaryStorage' systems (such as Redis or Cloudflare KV) handle active session tokens.

By default, the session.storeSessionInDatabase configuration parameter is set to false. When configured in this manner, session data resides exclusively in secondary memory-based storage. In database-centric configurations, relational foreign-key cascading deletes automatically eliminate active session rows when a parent user row is deleted. However, when sessions reside exclusively in cache tiers, session eviction must be explicitly handled by application-level logic.

This vulnerability stems from a logical discrepancy in four separate user-deletion handlers. While core self-deletion routes safely trigger the required two-stage cleanup sequence, the Admin, Anonymous, and SCIM plugin endpoints execute the database-level user deletion without purging the active session cached inside the secondary storage system. This allows unauthorized API access via orphaned sessions.

Root Cause Analysis

The underlying cause is categorized under CWE-613 (Insufficient Session Expiration) and CWE-459 (Incomplete Cleanup). The Better Auth database adapter interface exposes two key operations: internalAdapter.deleteUser(userId) and internalAdapter.deleteSessions(userId). In standard deployment topologies using external Key-Value stores, these endpoints must be chained sequentially during deletion routines.

An investigation of the codebase reveals that four operational endpoints failed to orchestrate this chain. Specifically, the framework invoked the database layer to drop the user record but completely bypassed session revocation inside the cache. Because the external session store lacks transactional integrity with the main database, the session token remains active inside the Redis cache.

When a request containing a stale cookie reaches the authentication middleware, getSessionFromCtx queries the secondary storage via internalAdapter.findSession(token). Because the cached session is not deleted, the validation checks succeed. The framework reconstructs a valid user session context without referencing the primary database, permitting unauthorized read/write access until the cache item reaches its natural expiration (TTL), which defaults to 7 days.

Code Analysis

An analysis of the vulnerable code paths demonstrates the implementation gap. In the Admin plugin (packages/better-auth/src/plugins/admin/routes.ts), the removeUser API route executed user deletion directly without clearing active cache entries.

// VULNERABLE IMPLEMENTATION (routes.ts)
const removeUser = createAuthRoute("/admin/remove-user", {
  method: "POST",
  // ... validation schema
}, async (ctx) => {
  const { userId } = ctx.body;
  // Missing session eviction step
  await ctx.context.internalAdapter.deleteUser(userId);
  return ctx.json({ success: true });
});

The patched version integrates explicit, blocking session revocation prior to deleting user relational rows. This prevents orphaned session records from residing in secondary memory structures.

// PATCHED IMPLEMENTATION (routes.ts)
const removeUser = createAuthRoute("/admin/remove-user", {
  method: "POST",
  // ... validation schema
}, async (ctx) => {
  const { userId } = ctx.body;
  // Explicitly evict cached sessions first to guarantee cleanup
  await ctx.context.internalAdapter.deleteSessions(userId);
  await ctx.context.internalAdapter.deleteUser(userId);
  return ctx.json({ success: true });
});

This same programmatic deficiency was present across three other handlers. In @better-auth/scim (routes.ts), the SCIM deprovisioning endpoint DELETE /scim/v2/Users/:userId deleted user profiles but left their enterprise sessions intact. Additionally, within the Anonymous plugin, both the /delete-anonymous-user route and the post-link account hook failed to evict temporary sessions, leaving unauthenticated persistent endpoints exposed.

Exploitation Methodology

Exploiting this flaw does not require active technical bypasses or complex payload payloads. Instead, it relies on timing and state discrepancies during standard account deprovisioning sequences. The primary threat scenario involves insider threat actors, compromised accounts, or deprovisioned employees.

To demonstrate this flow, consider an enterprise setting using SCIM synchronization. An identity provider detects a terminated employee and issues an automated SCIM deletion request. The application processes the delete operation successfully, removing the database record. However, because the employee's browser has an active session cookie, the employee can continue to query internal API endpoints. The underlying cached session remains untouched, authorizing access to confidential resources until the session TTL expires.

Impact Assessment

The security implications of this session persistence vulnerability are significant, especially within enterprise environments. A CVSS v3.1 base score of 3.8 (Low) is assigned primarily due to the privileges required to trigger deletion flows (e.g., an Administrator or Identity Provider). However, the actual impact on confidentiality and integrity can be high depending on the application context.

If a malicious insider is terminated, or if an administrator deletes a compromised user account to contain an ongoing incident, the containment will fail. The attacker will maintain access to operational APIs and database records. The vulnerability also directly undermines compliance standards (such as SOC 2 or ISO 27001) that mandate immediate, absolute termination of logical access upon employee deprovisioning.

Remediation and Defensive Strategy

The primary resolution is to upgrade all dependencies to the patched version. The maintainers resolved these session lifecycle bugs in the official v1.6.11 release. Security teams should perform immediate package updates across affected microservices.

In scenarios where immediate upgrades are blocked by regression testing pipelines, developers can apply targeted database configuration changes. Setting session.storeSessionInDatabase to true acts as a highly effective workaround. This transfers session states to the primary database, where cascading foreign-key rules enforce session destruction at the schema layer.

Alternatively, custom middleware or wrappers around user-deletion tasks can explicitly invoke session revocation via auth.api.revokeUserSessions prior to calling deletion methods. For the Anonymous plugin, implementing manual token clearing inside the onLinkAccount lifecycle hook prevents leftover credentials from persisting.

Technical Appendix

CVSS Score
3.8/ 10
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N

Affected Systems

Applications utilizing Better Auth with secondary session storage configuration (Redis, Cloudflare KV, memory-caches)Applications utilizing the Better Auth Admin pluginApplications utilizing the @better-auth/scim plugin for automated identity managementApplications utilizing the Better Auth Anonymous user plugin

Affected Versions Detail

Product
Affected Versions
Fixed Version
better-auth
Better Auth
>= 0.3.4, < 1.6.111.6.11
@better-auth/scim
Better Auth
>= 1.6.0, < 1.6.111.6.11
AttributeDetail
Vulnerability IDGHSA-2vg6-77g8-24mp
CWE IDCWE-613, CWE-459, CWE-672
Attack VectorNetwork
CVSS v3.1 Score3.8 (Low)
Exploit StatusConceptual / Logic Defect
Remediation StatusPatched in v1.6.11

MITRE ATT&CK Mapping

T1550.004Use Alternate Authentication Material: Web Session Cookie
Defense Evasion
T1078Valid Accounts
Initial Access
CWE-613
Insufficient Session Expiration

The application does not invalidate the session cache inside secondary storage when the corresponding user account is deleted.

Vulnerability Timeline

Vulnerability Advisory GHSA-2vg6-77g8-24mp Published
2025-02-18
Official Patch Released in v1.6.11
2025-02-18

References & Sources

  • [1]GHSA-2vg6-77g8-24mp Advisory
  • [2]GitHub Security Advisory Database Reference
  • [3]Official Release v1.6.11 Notes & Diff

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•39 minutes ago•CVE-2026-77354
8.7

CVE-2026-77354: Uncontrolled Resource Consumption (OOM) via Sparse Array Indexes in kin-openapi

An uncontrolled resource consumption vulnerability (CWE-400/CWE-789) exists within the kin-openapi Go library prior to version 0.142.0. The vulnerability occurs during the processing of highly sparse array indexes inside query parameters defined in deepObject style. An unauthenticated remote attacker can exploit this flaw to cause an immediate Out-of-Memory (OOM) crash of the target application.

Amit Schendel
Amit Schendel
0 views•8 min read
•about 2 hours ago•CVE-2026-77413
9.3

CVE-2026-77413: Remote Code Execution via Prototype Chain Bypass in JSONata Evaluator

A critical prototype pollution and sandbox escape vulnerability was discovered in the JSONata query and transformation library before versions 1.8.8 and 2.2.0. By providing a malicious JSONata expression that bypasses ownership checks on object properties, remote attackers can execute arbitrary code in the context of the host Node.js application.

Alon Barad
Alon Barad
0 views•6 min read
•about 3 hours ago•CVE-2026-63135
8.2

CVE-2026-63135: Stored Cross-Site Scripting (XSS) via Referer Header in YOURLS

CVE-2026-63135 is a critical stored Cross-Site Scripting (XSS) vulnerability affecting YOURLS (Your Own URL Shortener) versions 1.5.1 up to (but not including) 1.10.4. Unauthenticated remote attackers can inject malicious JavaScript arrays by crafting an HTTP Referer header sent to a short URL redirect. This value is saved in the database logs and executed without context-aware escaping when an administrative user views the corresponding statistics visualization page.

Amit Schendel
Amit Schendel
1 views•6 min read
•about 4 hours ago•CVE-2026-68508
7.8

CVE-2026-68508: Arbitrary Code Execution via Unsafe Dynamic Instantiation in Hydra Core

CVE-2026-68508 is a high-severity arbitrary code execution vulnerability in facebookresearch/hydra (hydra-core) prior to version 1.3.4. The vulnerability exists within the dynamic instantiation system hydra.utils.instantiate(), which resolves and executes arbitrary Python callables from configuration files. An attacker capable of submitting untrusted configurations can achieve arbitrary code execution in the context of the consuming process.

Alon Barad
Alon Barad
4 views•7 min read
•about 5 hours ago•CVE-2026-77415
9.3

CVE-2026-77415: Sandbox Escape and Arbitrary Code Execution in JSONata Engine

A critical sandbox escape vulnerability in JSONata versions prior to 1.8.8 and 2.2.1 allows unauthenticated remote attackers to execute arbitrary code on the host machine. By submitting crafted JSONata expressions, an attacker can manipulate internal AST structures, bypass object clone helpers, spoof native function flags, and escape the evaluation environment to execute system commands through the Node.js runtime.

Alon Barad
Alon Barad
9 views•6 min read
•about 6 hours ago•CVE-2026-77414
9.3

CVE-2026-77414: Critical Sandbox Escape and Remote Code Execution in JSONata via Prototype Pollution

CVE-2026-77414 (GHSA-2943-5xfg-gq5f) is a critical sandbox escape and remote code execution vulnerability in the JSONata package. When JSONata processes untrusted expressions, it uses a vulnerable environment lookup check that can be shadowed by user-defined variables. Attackers can leverage this to traverse the prototype chain, reach the global Function constructor, and execute arbitrary system commands on the host machine.

Alon Barad
Alon Barad
9 views•7 min read