security: log every key-feed fetch (audit M2)

/admin/librechat/keys deliberately serves every member's chat key on one
sync token (the LibreChat sandbox seeds from it; a per-member fetch would
require changing the sandbox's identity model — decision recorded in
ops-docs maintenance/librechat-key-feed.md). Every fetch now logs a
count-only WARNING (no key material; the email redactor strips addresses)
with caller + user-agent, and the daily digest watches the rate against
the sandbox's ~10-min poll cadence.
This commit is contained in:
inference-bot committed 2026-11-05 16:21:51 +00:00
1 parent 8a9222033d
commit ce1bc7bee6
1 file changed
+16
+16
View File
@@ -5585,6 +5585,17 @@ async def admin_librechat_keys(request: Request):
can seed LibreChat's user-key store and members never see an API-key can seed LibreChat's user-key store and members never see an API-key
prompt (chat bills to the member's own LiteLLM team/budget). Auth is the prompt (chat bills to the member's own LiteLLM team/budget). Auth is the
dedicated X-Sync-Token header — NOT the admin token. dedicated X-Sync-Token header — NOT the admin token.
DELIBERATE DESIGN (audit M2, 2026-11-05): one static token returns every
member's decrypted chat key — a total-member-key blast radius. Kept (not
per-member fetch) because the only consumer is the LibreChat sandbox's
in-app key-sync, and scoping the feed per member would require changing
the sandbox's sync identity model; a wrong change there stops key seeding
for every member at once. Recorded in ops-docs
(maintenance/librechat-key-feed.md). Monitoring: every fetch is logged
(count only, never key material) and the daily digest watches the rate —
the sandbox polls ~every 10 min, so anything far above that cadence (or a
401 burst on this route) is surfaced as an anomaly.
""" """
_verify_sync_token(request) _verify_sync_token(request)
@@ -5593,6 +5604,11 @@ async def admin_librechat_keys(request: Request):
"SELECT email, key_token FROM members WHERE active = 1 AND key_token != ''" "SELECT email, key_token FROM members WHERE active = 1 AND key_token != ''"
).fetchall() ).fetchall()
conn.close() conn.close()
logger.warning(
"librechat key feed served: %d member key(s) to %s (ua=%s)",
len(rows), request.client.host if request.client else "?",
(request.headers.get("user-agent") or "?")[:60],
)
return { return {
"members": [ "members": [
{"email": email, "key": decrypt_key(key_token)} {"email": email, "key": decrypt_key(key_token)}