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:
1 parent
8a9222033d
commit
ce1bc7bee6
1 file changed
+16
+16
@@ -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
|
||||
prompt (chat bills to the member's own LiteLLM team/budget). Auth is the
|
||||
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)
|
||||
|
||||
@@ -5593,6 +5604,11 @@ async def admin_librechat_keys(request: Request):
|
||||
"SELECT email, key_token FROM members WHERE active = 1 AND key_token != ''"
|
||||
).fetchall()
|
||||
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 {
|
||||
"members": [
|
||||
{"email": email, "key": decrypt_key(key_token)}
|
||||
|
||||
Reference in new issue
Block a user