From ce1bc7bee6ffbba86493909130aebdf5fc09c5a9 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Thu, 5 Nov 2026 16:21:51 +0000 Subject: [PATCH] security: log every key-feed fetch (audit M2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /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. --- app/main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/main.py b/app/main.py index b84b7c5..ede3be7 100644 --- a/app/main.py +++ b/app/main.py @@ -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)}