LibreChat/api
Marco Beretta 18b6937da3
🧯 fix: Outlast Failed Auth Cache Eviction on Credential Changes (#16435)
* fix: outlast failed auth cache eviction on credential changes

A credential change committed to MongoDB could report success while a
cached auth user document without the new credentialsChangedAt stayed
readable, so an old OpenID access token kept authorizing until the
cache TTL. The Redis-backed auth cache swallowed every failure (Keyv and
KeyvRedis resolve a failed GET as a miss and a failed DEL as a no-op), and
the eviction helpers stopped at the first error.

- The AUTH_USER_DOC namespace opts into throwOnErrors so a failed read or
  delete is visible; every caller of that namespace already catches.
- evictAuthUserDocs attempts every delete even when another fails and
  reports whether a document may still be served; the data-schemas and
  packages/api invalidation paths share it.
- updateUser waits out AUTH_USER_DOC_CACHE_TTL_MS before returning a
  credential change whose eviction was incomplete, so the change is only
  confirmed once no pre-change document can be served. Other updates stay
  best effort, and later revocations are delayed, never skipped.

* fix: record the reverse index before caching an auth user document

A document written before its reverse-index entry was cached without an
index naming it when the index write failed, so eviction could not find
it. Write the index first with a TTL that outlives the documents it names,
and skip the document when the index write fails.

* test: keep real data-schemas helpers in the pinned order spec

* fix: settle the auth cache after revoking reset credentials

Waiting out the cache TTL inside updateUser held the reset before its
session and passkey revocations, so a live refresh token or passkey could
mint an access token issued after credentialsChangedAt during the wait.
updateUser is best effort again; awaitAuthUserDocEviction retries the
eviction and waits one TTL only when it is still incomplete, and both the
web reset controller and the reset CLI call it after revoking sessions and
passkeys, before confirming the reset.

* fix: settle the credential barrier with a margin and on CLI revocation errors

Timers can fire a millisecond early, so the eviction barrier now waits the
cache TTL plus a 100 ms margin. The reset CLI also settles the barrier when
revoking passkeys or sessions throws, since the password is already changed.

* fix: treat an auth cache that cannot delete as not evicted

* fix: keep the reverse index until every document it names is evicted

A failed eviction still deleted the reverse index, so the credential
barrier's retry found no index and reported the cache clear while the
documents an unreadable index or a failed delete left behind stayed
cached. The index is now deleted only after it was read and every document
it names is gone, so a retry can still find what remains.

* fix: treat a malformed auth reverse index as unreadable

* fix: treat a reverse index with a non-string entry as unreadable
2026-09-28 21:21:53 +02:00
..
app 🛶 chore: Include Latest Canary Features in Sync 2026-09-28 01:31:41 +00:00
cache 🧯 fix: Outlast Failed Auth Cache Eviction on Credential Changes (#16435) 2026-09-28 21:21:53 +02:00
config 🛬 fix: Land MCP OAuth Callbacks on Waiting Connections (#15876) 2026-09-13 01:46:41 -04:00
db 🛬 fix: Land MCP OAuth Callbacks on Waiting Connections (#15876) 2026-09-13 01:46:41 -04:00
models 🥢 fix: Fit MCP App Snapshots Within Message Documents (#16299) 2026-09-24 09:56:40 -04:00
server 🧯 fix: Outlast Failed Auth Cache Eviction on Credential Changes (#16435) 2026-09-28 21:21:53 +02:00
strategies 🔑 feat: Passkey Authentication with WebAuthn Sign-In and Management (#14715) 2026-09-23 13:19:32 -04:00
test 🧨 fix: Reject Invalid AES Credentials Before Startup (#16402) 2026-09-26 20:28:47 -04:00
utils ⚡ feat: Add Gemini 3.8 Flash Support (#15519) 2026-09-02 15:06:40 -04:00
jest.config.js 🧩 feat: MCP Apps support (#13831) 2026-09-23 21:24:50 -04:00
jsconfig.json
package.json 📦 chore: bump agents SDK to v3.9.7 (#16425) 2026-09-27 22:13:29 -04:00
typedefs.js 🏦 fix: Reserve Credits for In-Flight Requests (#15879) 2026-09-13 12:53:19 -04:00